Didier Marin
08/11/2021, 10:26 AMfrom prefect import task, Flow, Parameter
from prefect.engine.signals import PAUSE
@task
def dummy_task(x):
confirmed = ???
if x > 100 and not confirmed:
raise PAUSE("Are you sure ?")
return x + 1
with Flow("dummy") as flow:
x = Parameter('x', default=1)
dummy_task(x)
Is there a clean way of getting previous states of a task, maybe from prefect.context
, such that I know confirmation happened ?
Or do I have to add some branching to handle this ?Sam Cook
08/11/2021, 1:26 PMDidier Marin
08/11/2021, 2:11 PMDidier Marin
08/11/2021, 4:31 PMimport prefect
from prefect import task, Flow, Parameter
from prefect.engine.signals import PAUSE
@task
def dummy_task(x):
confirmed = prefect.context.get("resume")
if x > 100 and not confirmed:
raise PAUSE("Are you sure ?")
return x + 1
with Flow("dummy") as flow:
x = Parameter('x', default=1)
dummy_task(x)
flow.run()
Taking inspiration from the manual_only
trigger :)