# FlowRunner
# FlowRunner
class
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.
Args:
flow (Flow)
: theFlow
to be runtask_runner_cls (TaskRunner, optional)
: The class used for running individual Tasks. Defaults to TaskRunnerstate_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 thenew_state
argument 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. Example:
@task
def say_hello():
print('hello')
with Flow("My Flow") as f:
say_hello()
fr = FlowRunner(flow=f)
flow_state = fr.run()
methods: |
---|
prefect.engine.flow_runner.FlowRunner.call_runner_target_handlers (old_state, new_state)[source] |
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
|
prefect.engine.flow_runner.FlowRunner.check_flow_is_pending_or_running (state)[source] |
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).
|
prefect.engine.flow_runner.FlowRunner.check_flow_reached_start_time (state)[source] |
Checks if the Flow is in a Scheduled state and, if it is, ensures that the scheduled time has been reached.
|
prefect.engine.flow_runner.FlowRunner.check_for_cancellation ()[source] |
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.
|
prefect.engine.flow_runner.FlowRunner.set_flow_to_running (state)[source] |
Puts Pending flows in a Running state; leaves Running flows Running.
|
This documentation was auto-generated from commit bd9182e
on July 31, 2024 at 18:02 UTC