-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(flow): pea/pod start on the Flow level should not block (#1902)
* fix(flow): pea/pod start on the Flow level should not block
- Loading branch information
Showing
10 changed files
with
99 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 4 additions & 8 deletions
12
tests/distributed/test_against_external_daemon/delayed_executor.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,15 @@ | ||
import time | ||
from typing import Any | ||
|
||
|
||
from jina.executors.decorators import as_ndarray | ||
from jina.executors.encoders import BaseEncoder | ||
|
||
|
||
class DelayedExecutor(BaseEncoder): | ||
|
||
def __init__(self, *args, **kwargs): | ||
super().__init__(*args, **kwargs) | ||
self.name = 'delayed-executor' | ||
|
||
def post_init(self): | ||
self.logger.info('sleeping for 8 secs') | ||
time.sleep(8) | ||
|
||
def encode(self, data: Any, *args, **kwargs) -> Any: | ||
return data | ||
@as_ndarray | ||
def encode(self, data, *args, **kwargs): | ||
return [[1, 2]] * len(data) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import time | ||
|
||
import pytest | ||
|
||
from jina.excepts import RuntimeFailToStart | ||
from jina.executors import BaseExecutor | ||
from jina.flow import Flow | ||
from jina.logging.profile import TimeContext | ||
|
||
|
||
class SlowExecutor(BaseExecutor): | ||
|
||
def post_init(self): | ||
time.sleep(4) | ||
|
||
|
||
def test_flow_slow_executor_intra(): | ||
f = Flow().add(uses='SlowExecutor', parallel=2) | ||
|
||
with f, TimeContext('start flow') as tc: | ||
assert tc.now() < 8 | ||
|
||
|
||
def test_flow_slow_executor_inter(): | ||
f = (Flow().add(uses='SlowExecutor', parallel=3) | ||
.add(uses='SlowExecutor', parallel=3)) | ||
|
||
with f, TimeContext('start flow') as tc: | ||
assert tc.now() < 8 | ||
|
||
|
||
def test_flow_slow_executor_bad_fail_early(): | ||
f = (Flow().add(uses='SlowExecutor', parallel=3) | ||
.add(uses='BADNAME_EXECUTOR', parallel=3)) | ||
|
||
with pytest.raises(RuntimeFailToStart): | ||
with f, TimeContext('start flow') as tc: | ||
assert tc.now() < 8 |