You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hey there,
I've got a question about the usage of case conditions:
Scenario:
2 tasks, B follows A, but B could be executed without execution A
2 parameters to handle the execution of A (exec_a) and B (exec_b)
If parameter exec_a is True execute task A
If parameter exec_b is True execute task B
Task B uses skip_on_upstream_skip = False to execute if exec_a was False
This works if both execution parameter are True or exec_a is False and exec_b is True. But it don't work if it's vice versa. In that case task B will be executed as well.
from prefect import Flow, Parameter, task
from prefect.tasks.control_flow.case import case
@task
def a(a=None):
if not a:
raise ValueError("a missing")
else:
print(a)
@task(skip_on_upstream_skip=False)
def b(b=None):
if not b:
raise ValueError("b missing")
else:
print(b)
with Flow("ab_flow") as flow:
exec_a = Parameter(name="exec_a", default=True)
exec_b = Parameter(name="exec_b", default=False)
with case(exec_a, True):
t_a = a("hello")
with case(exec_b, True):
t_b = b(b="world", upstream_tasks=[t_a])
if __name__ == "__main__":
flow_state = flow.run()
How could I prevent task B from running if exec_b is set to False?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hey there,
I've got a question about the usage of case conditions:
Scenario:
exec_a
) and B (exec_b
)exec_a
isTrue
execute task Aexec_b
isTrue
execute task Bskip_on_upstream_skip = False
to execute ifexec_a
wasFalse
This works if both execution parameter are
True
orexec_a
isFalse
andexec_b
isTrue
. But it don't work if it's vice versa. In that case task B will be executed as well.How could I prevent task B from running if
exec_b
is set toFalse
?Beta Was this translation helpful? Give feedback.
All reactions