Flows compose work into a workflow.
explain_flows
is an instance of a flow.
Flows accept inputs, perform work, and potentially return a result.
Generally, flows behave like Python functions, but they have some additional capabilities:
@flow
decorated function (i.e. __call__
), just like a normal Python function.
cron
or Modal) to invoke flows among vanilla Python codeView the parameter schema for a flow
BaseModel
instance.Pending
state to a Failed
state without entering a Running
state.
512kb
in size.When possible, prefer passing a reference to a large object and load it during your flow run.state_details
field of the task run representing the child flow run includes a child_flow_run_id
.
The state_details
field of the nested flow run includes a parent_task_run_id
.
You can define multiple flows within the same file.
Whether running locally or through a deployment, you must indicate which flow is the entrypoint for a flow run.
@flow
decorator.
In particular, Prefect supports:
yield
it instead of using return
.
Values yielded from generator flows are not considered final results and do not face the same serialization constraints:FAILED
.FAILED
state will cause the run to be marked as FAILED
.COMPLETED
.
state
were returned from the flow function, the run would be marked as FAILED
.COMPLETED
.
always_fails_flow
fails because one of the three returned futures fails.
If multiple states are returned, they must be contained in a set
, list
, or tuple
.
COMPLETED
Skipped
state to indicate that a flow run was skipped.