jpuris
02/28/2023, 2:09 PMtask_1 >> task_2
task_2 >> task_3
task_2 >> task_4
...
Now prefect determines this implicitly by the "parameter" direction from task to task i.e.
result_1 = task_1
result_2 = task_2(result_1)
result_3 = task_3(result_2)
result_4 = task_4(result_2)
Which is fine, no problems there.. but what do we do when there is task 5, that does not require any result from the tasks it is dependent on? For example task 5 absolutely must run, if task 4 is done, but has no other relationship with it, like
result_1 = task_1
result_2 = task_2(result_1)
result_3 = task_3(result_2)
result_4 = task_4(result_2)
result_5 = task_5()
With sequential task runner (default), this is OK, but if I were to use concurrent one (I want to have the tasks 3 and 4 run at the same time, but 5 must not run before task 4 is done?wait_for
arg added by @task
decorator? For example
result_5 = task_5(wait_for=[result_4])
But what do we do then, when task_4 returns nothing? i.e.
@task
def task_4():
pass
@flow
def my_flow():
result_1 = task_1
result_2 = task_2(result_1)
result_3 = task_3(result_2)
result_4 = task_4(result_2) # It does not return anything?
result_5 = task_5(wait_for=result_4)
Christopher Boyd
02/28/2023, 2:15 PMjpuris
02/28/2023, 2:20 PM@task
def task_4(some_param):
pass
result_2 = None
result_4 = task_4(result_2) # It does not return anything?
I'd then think it is obligatory to return something by every task function ever i.e.
@task
def task_4(some_param):
print('I did nothing and returning None')
return None
result_2 = None
result_4 = task_4(result_2)
Which then works OKdef returns_nothing():
pass
nothing = returns_nothing()
print(nothing)
outputs
None
👍