jina-ai / jina

☁️ Build multimodal AI applications with cloud-native stack
https://docs.jina.ai
Apache License 2.0
20.54k stars 2.21k forks source link

Error on joining branches: Flow is aborted due to ['gateway'] can not be started. #6133

Closed jandiers closed 5 months ago

jandiers commented 6 months ago

Thank you very much for the excellent effort and time you have invested in Jina!

Describe the bug I ran the example from the documentation for joining the different branches and noticed that an error occurs:

from jina import Executor, requests, Flow
from docarray import DocList
from docarray.documents import TextDoc

class FooExecutor(Executor):
    @requests
    async def foo(self, docs: DocList[TextDoc], **kwargs) -> DocList[TextDoc]:
        docs.append(TextDoc(text=f'foo was here and got {len(docs)} document'))

class BarExecutor(Executor):
    @requests
    async def bar(self, docs: DocList[TextDoc], **kwargs) -> DocList[TextDoc]:
        docs.append(TextDoc(text=f'bar was here and got {len(docs)} document'))

class BazExecutor(Executor):
    @requests
    async def baz(self, docs: DocList[TextDoc], **kwargs) -> DocList[TextDoc]:
        docs.append(TextDoc(text=f'baz was here and got {len(docs)} document'))

f = (
    Flow()
    .add(uses=FooExecutor, name='fooExecutor')
    .add(uses=BarExecutor, name='barExecutor', needs='fooExecutor')
    .add(uses=BazExecutor, name='bazExecutor', needs='fooExecutor')
    .add(needs=['barExecutor', 'bazExecutor'])
)

Running:

with f:
    print(f.post('/', return_type=DocList[TextDoc]).text)

Results in:

RuntimeWarning: coroutine 'Flow._wait_until_all_ready.<locals>._f' was never awaited (raised from 
/usr/local/lib/python3.10/dist-packages/jina/orchestrate/flow/base.py:1988)

ERROR  Flow@387 Flow is aborted due to ['gateway'] can not be started.                          [01/07/24 19:34:40]

---------------------------------------------------------------------------

RuntimeFailToStart                        Traceback (most recent call last)

[<ipython-input-10-9f7d0fe08cab>](https://localhost:8080/#) in <cell line: 1>()
----> 1 with f:
      2     print(f.post('/', return_type=DocList[TextDoc]).text)

3 frames

[/usr/local/lib/python3.10/dist-packages/jina/orchestrate/flow/base.py](https://localhost:8080/#) in _wait_until_all_ready(self)
   2010                 )
   2011                 self.close()
-> 2012                 raise RuntimeFailToStart
   2013             from rich.rule import Rule
   2014 

RuntimeFailToStart:

Describe how you solve it I don't know a solution, but the following code works fine:

f = (
    Flow()
    .add(uses=FooExecutor, name='fooExecutor')
    .add(uses=BarExecutor, name='barExecutor', needs='fooExecutor')
    .add(uses=BazExecutor, name='bazExecutor', needs='fooExecutor')
    # .add(needs=['barExecutor', 'bazExecutor'])
)

Environment

I could reproduce this error on Google Colab as well as on Paperspace Gradient.

JoanFM commented 6 months ago

can you run this example with JINA_LOG_LEVEL=debug as environment variable?