Let me break down the available parameters for Prefect flows in 3.x:
1.
Task Runner Configuration:
- `task_runner`: Specify a custom TaskRunner for flow execution
2.
Retry and Timeout Settings:
- `retries`: Number of times to retry the flow on failure
- `retry_delay_seconds`: Delay between retry attempts
- `timeout_seconds`: Maximum allowed runtime for the flow
3.
Result Handling:
- `result_storage`: Specify where to store flow results
- `result_serializer`: Define how to serialize flow results
- `persist_result`: Whether to persist the flow result
- `cache_result_in_memory`: Whether to cache the result in memory
4.
Parameter Validation:
- `validate_parameters`: Enable/disable parameter validation
5.
Flow State Hooks:
- `on_completion`: Hook that runs when flow completes successfully
- `on_failure`: Hook that runs when flow fails
- `on_cancellation`: Hook that runs when flow is cancelled
- `on_running`: Hook that runs when flow starts running
Here's a comprehensive example showing several parameters in use:
python
from prefect import flow
@flow(
name="my-flow",
task_runner=SequentialTaskRunner(),
retries=3,
retry_delay_seconds=60,
timeout_seconds=3600,
persist_result=True,
validate_parameters=True
)
def my_flow():
pass
You can find detailed documentation about these parameters in the
Prefect 3.x API reference.
These parameters give you fine-grained control over flow execution, error handling, and result management. They can be mixed and matched based on your specific needs, and all are optional with sensible defaults.