Sam Werbalowsky
01/03/2022, 10:26 PMval = Parameter("param", False):
case(val, True):
do_stuff()
case(val, False):
dont_do_stuff()
If my paramter is an actual value, i.e. “value”, it skips both because it’s neither True nor False. So I’m left to make another task to check the value. Is this correct?Sam Werbalowsky
01/03/2022, 10:28 PM[2022-01-03 17:21:27-0500] INFO - prefect.TaskRunner | SKIP signal raised: SKIP('Provided value "VALUE" did not match "False"')
[2022-01-03 17:21:27-0500] INFO - prefect.TaskRunner | Task 'case(True)': Starting task run...
[2022-01-03 17:21:27-0500] INFO - prefect.TaskRunner | Task 'case(False)': Finished task run for task with final state: 'Skipped'
[2022-01-03 17:21:27-0500] INFO - prefect.TaskRunner | SKIP signal raised: SKIP('Provided value "VALUE" did not match "True"')
Kevin Kho
case
is not limited to True or False. It can be a constant number for example:
from prefect import Flow, task, case, Parameter
import prefect
@task
def do_something():
<http://prefect.context.logger.info|prefect.context.logger.info>("this ran")
return 1
with Flow("conditional-branches") as flow:
cond = Parameter("cond", 3)
with case(cond, 3):
val = do_something()
flow.run()
Kevin Kho
Sam Werbalowsky
01/03/2022, 10:38 PMKevin Kho