atemaguer/ray-jina

[Feature Request] A way for streamlining and scaling Jina executors

Opened this issue · 0 comments

Leverage the composability of ray serve deployment instances to construct another way of streamlining and scaling Jina executors. Currently, the way to streamline and scale Jina executors is through an abstraction called a flow. I feel like this abstraction and its runtimes reinvent a lot of things that ray's distributed runtime can easily solve. Also, the runtimes are written in python unlike ray's which are written in C++. This implies using ray to scale Jina executors would probably increase performance.

The following code shows how Jina's Flow works.

from jina import Executor, Flow, Document, requests

class MyExecutor(Executor):

    @requests(on='/index')
    def foo(self, **kwargs):
        print(f'foo is called: {kwargs}')

    @requests(on='/random_work')
    def bar(self, **kwargs):
        print(f'bar is called: {kwargs}')


f = Flow().add(uses=MyExecutor)

with f:
    f.post(on='/index', inputs=Document(text='index'))
    f.post(on='/random_work', inputs=Document(text='random_work'))

The primitive that would replace Flow would be called Pipeline and its API would resemble something like this:

from ray_jina import Pipeline
import requests

p = Pipeline([("indexer", MyExecutor)])

#deploys the pipeline onto a ray serve instance.
p.deploy()

# access the executors through regular HTTP requests
requests.post("https://localhost:8000/index", data={inputs:Document(text='index')})
requests.post("https://localhost:8000/random_work", data={inputs:Document(text='random_walk')})

The API is inspired by scikit-learn's Pipeline class API.