prefect.engine.flow_runner.FlowRunner(flow, task_runner_cls=None, state_handlers=None)[source]
FlowRunners handle the execution of Flows and determine the State of a Flow before, during and after the Flow is run.
In particular, through the FlowRunner you can specify which tasks should be the first tasks to run, which tasks should be returned after the Flow is finished, and what states each task should be initialized with.
flow (Flow): the
Flowto be run
task_runner_cls (TaskRunner, optional): The class used for running individual Tasks. Defaults to TaskRunner
state_handlers (Iterable[Callable], optional): A list of state change handlers that will be called whenever the flow changes state, providing an opportunity to inspect or modify the new state. The handler will be passed the flow runner instance, the old (prior) state, and the new (current) state, with the following signature:
state_handler(fr: FlowRunner, old_state: State, new_state: State) -> Optional[State]If multiple functions are passed, then the
new_stateargument will be the result of the previous handler.
Flow.run()and in general, this is the endpoint through which FlowRunners will be interacted with most frequently.
@task def say_hello(): print('hello') with Flow("My Flow") as f: say_hello() fr = FlowRunner(flow=f) flow_state = fr.run()
A special state handler that the FlowRunner uses to call its flow's state handlers. This method is called as part of the base Runner's
Checks if the flow is in either a Pending state or Running state. Either are valid starting points (because we allow simultaneous runs of the same flow run).
Checks if the Flow is in a Scheduled state and, if it is, ensures that the scheduled time has been reached.
Contextmanager used to wrap a cancellable section of a flow run.
prefect.engine.flow_runner.FlowRunner.determine_final_state(state, key_states, return_states, terminal_states)[source]
Implements the logic for determining the final state of the flow run.
prefect.engine.flow_runner.FlowRunner.get_flow_run_state(state, task_states, task_contexts, return_tasks, task_runner_state_handlers, executor)[source]
Runs the flow.
prefect.engine.flow_runner.FlowRunner.initialize_run(state, task_states, context, task_contexts, parameters)[source]
Initializes the Task run by initializing state and context appropriately.
prefect.engine.flow_runner.FlowRunner.run(state=None, task_states=None, return_tasks=None, parameters=None, task_runner_state_handlers=None, executor=None, context=None, task_contexts=None)[source]
The main endpoint for FlowRunners. Calling this method will perform all computations contained within the Flow and return the final state of the Flow.
Puts Pending flows in a Running state; leaves Running flows Running.
This documentation was auto-generated from commit ad73429
on May 24, 2022 at 22:55 UTC