Darin Douglass
06/09/2022, 8:30 PMcreate_flow_run
that will cause two flows to spawn from the one call?flow.terminal_state_handler = cycle_state_handler(...)
where cycle_state_handler
looks like this:
def cycle_state_handler(project, **kwargs):
"""Re-runs `flow` once it reaches a finished state.
Must be used as a `terminal_state_handler`."""
def _handler(flow, final_state, _reference_task_states):
if not isinstance(final_state, state.Cancelled):
# set this to None to force the backend to make a new name for us
prefect.context["flow_run_name"] = None
create_flow_run.run(
project_name=project,
flow_name=flow.name,
parameters=prefect.context.parameters,
**kwargs
)
return final_state
return _handler
Kevin Kho
06/09/2022, 8:34 PMDarin Douglass
06/09/2022, 8:35 PMcreate_flow_run
task does that
07:25:16 INFO prefect Creating flow run '<generated-name>' for flow 'main'...
07:25:33 INFO prefect Created flow run '<generated-name>': <a url>
Kevin Kho
06/09/2022, 8:37 PMDarin Douglass
06/09/2022, 8:39 PMKevin Kho
06/09/2022, 8:40 PMDarin Douglass
06/09/2022, 8:42 PM