Skip to content

Commit

Permalink
feat: 2.0 (#2406)
Browse files Browse the repository at this point in the history
  • Loading branch information
hanxiao authored May 18, 2021
1 parent abf7f8a commit c7e4599
Show file tree
Hide file tree
Showing 856 changed files with 7,656 additions and 40,206 deletions.
1 change: 0 additions & 1 deletion .github/.is_A

This file was deleted.

Binary file removed .github/1500x667new.gif
Binary file not shown.
Binary file removed .github/1500х667.gif
Binary file not shown.
40 changes: 40 additions & 0 deletions .github/2.0/1.xvs2.0BaseExecutor.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
84 changes: 84 additions & 0 deletions .github/2.0/cookbooks/CleanCode.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# Temporary Cookbook on Clean Code

Jina is designed as a lean and efficient framework. Solutions built on top of Jina also mean to be so. Here are some
tips to help you write clean & beautiful code.

<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->



<!-- END doctoc generated TOC please keep comment here to allow auto update -->

1. `from jina import Document, DocumentArray, Executor, Flow, requests` is all you need. Copy-paste it as the first line of your code.

1. No need to implement `__init__` if your `Executor` does not contain initial states.

✅ Do:
```python
from jina import Executor

class MyExecutor(Executor):
def foo(self, **kwargs):
...
```
😔 Don't:
```python
from jina import Executor

class MyExecutor(Executor):
def __init__(**kwargs):
super().__init__(**kwargs)

def foo(self, **kwargs):
...
```

1. Use `@requests` without specifying `on=` if your function mean to work on all requests. You can use it for catching all requests that are not for this Executor.

✅ Do:
```python
from jina import Executor, requests

class MyExecutor(Executor):

@requests
def _skip_all(self, **kwargs):
pass
```
😔 Don't:
```python
from jina import Executor

class MyExecutor(Executor):
@requests(on='/index')
def _skip_index(self, **kwargs):
pass

@requests(on='/search')
def _skip_search(self, **kwargs):
pass
```

1. Fold unnecessary arguments into `**kwargs`, only get what you need.

✅ Do:
```python
from jina import Executor, requests

class MyExecutor(Executor):

@requests
def foo_need_pars_only(self, parameters, **kwargs):
print(parameters)
```
😔 Don't:
```python
from jina import Executor, requests

class MyExecutor(Executor):

@requests
def foo_need_pars_only(self, docs, parameters, docs_matrix, groundtruths_matrix, **kwargs):
print(parameters)
```
Loading

0 comments on commit c7e4599

Please sign in to comment.