Idan
06/09/2023, 2:57 PMRayTaskScheduler
, but it could be applied to any, I suppose.
Assume there is only one worker (node, process, or whatever fits the Scheduler
class), and the computation graph consists of multiple identical branches (A -> B -> C
x3).
Is there a way to tell Prefect to prefer to go DFS and complete one such branch, before attempting to continue to the other branches?
I’m aware of the wait_for
argument, is there anything else one can do?Nate
06/09/2023, 3:08 PMIn [4]: from prefect import flow, task
In [5]: @task
...: def a():
...: pass
...:
In [6]: @task
...: def b():
...: pass
...:
In [7]: @task
...: def c():
...: pass
...:
In [8]: @flow
...: def branch():
...: a_result = a()
...: b_result = b(wait_for=[a_result])
...: c(wait_for=[b_result])
...:
In [9]: @flow
...: def foo():
...: for _ in range(3):
...: branch()
...:
In [10]: foo()
Nate
06/09/2023, 3:09 PM.submit()
to leverage your task runner, but otherwise should be the same, and if you pass data between a, b and c then you dont need to explicitly use wait_for
Idan
06/09/2023, 3:24 PMNate
06/09/2023, 3:25 PMNate
06/09/2023, 3:26 PMbranch
could instead be its own deployment that you could create flow runs for with run_deployment
and then your prefect worker would pick up those flow runs and execute themIdan
06/09/2023, 3:29 PMIdan
06/09/2023, 3:29 PM