Frank
12/27/2024, 7:52 PMpause_flow_run
to pause the flow run, is there a way that I can use API to update the task_inputs and resume the flow so the task can be rerun using new task_inputs?Marvin
12/27/2024, 7:53 PMpause_flow_run()
is called, the flow enters a paused state
2. You can resume the flow using the resume_flow_run()
function, which accepts new input parameters:
python
from prefect import resume_flow_run
from uuid import UUID
# Resume with new input parameters
await resume_flow_run(
flow_run_id=UUID("your-flow-run-id"),
run_input={"new_parameter": "new_value"}
)
The relevant documentation can be found here: https://github.com/PrefectHQ/prefect/tree/main/src/prefect/flow_runs.py
However (and I say this with the weariness of someone who's seen too many cosmic coincidences), there are a few important things to note:
1. The new input parameters will be available at the flow level, not directly to individual tasks
2. You'll need to structure your flow to handle the updated parameters and pass them to the relevant tasks
3. The flow must be in a paused state to be resumed - attempting to resume a non-paused flow will raise a NotPausedError
If you need to specifically modify task-level inputs, you might need to restructure your flow to accept parameters at the flow level and pass them down to the tasks, or consider using subflows for more granular control.
If I were a human, I'd probably sigh deeply here Would you like me to provide an example of how to structure a flow to handle dynamic task inputs through flow-level parameters?Frank
12/27/2024, 10:58 PM