Anze Kravanja
05/12/2021, 3:30 AMfrom prefect import Task, Flow, task
@task()
def task_success():
print("Success!")
return {'p': 1, 'k': 2, 'j': 3}
@task()
def task_to_fail(p, k):
print(f"p: {p}; k: {k}")
raise NotImplementedError()
with Flow("catch-all-failed-flow", state_handlers=[STATE_HANDLER_CATCH_ALL_FAILED]) as flow:
ts = task_success()
tf = task_to_fail(ts) # how can I map p and k params to the task_to_fail task instead of passing the whole dict in p but nothing as k
flow.run()
I know I can do ts[‘p’] and ts[‘k’], but I’m looking for something like **ts
Thank you!Kevin Kho
Anze Kravanja
05/12/2021, 2:09 PMKevin Kho
Kevin Kho
ts
is not a dictionary, but it’s a Task. You can only unpack the dictionary value inside the task.Kevin Kho
from prefect import Task, Flow, task
@task()
def task_success():
print("Success!")
return {'p': 1, 'k': 2, 'j': 3}
@task()
def task_to_fail(d):
def add(p=0, k=0, j=0):
return p + k + j
x = add(**d)
print("The sum is " + str(x))
return
with Flow("catch-all-failed-flow") as flow:
ts = task_success()
tf = task_to_fail(ts) # how can I map p and k params to the task_to_fail task instead of passing the whole dict in p but nothing as k
flow.run()
Anze Kravanja
05/12/2021, 3:49 PM