<@ULVA73B9P> is it possible to suspend a flow, upd...
# ask-marvin
m
@Marvin is it possible to suspend a flow, update its parameters, and then resume it with the new parameters?
m
In Prefect 3.x, you can suspend and resume flow runs, but there's a catch. When you suspend a flow run using
suspend_flow_run
, the flow exits completely, and the infrastructure running it is torn down. This means that when you resume the flow with
resume_flow_run
, it starts executing from the beginning. This behavior is useful for cost-saving but doesn't directly allow you to resume with new parameters without restarting the flow. If you want to update parameters, you would need to restart the flow with the new parameters. You can manage variables through the Prefect API, CLI, or UI to facilitate this process. For more detailed information, you can refer to the Prefect documentation on pause and resume and Prefect variables management. If you need further guidance on implementing this with your specific stack, feel free to ask!
m
@Marvin I specifically want to adjust the flow run parameters, not use variables.
m
In Prefect 3.x, you can resume a paused flow run with new parameters using the
resume_flow_run
function. This function allows you to provide a
run_input
dictionary, which can contain the new parameters you wish to use when resuming the flow. Here's a brief overview of how it works: - resume_flow_run: - Parameters: - `flow_run_id`: The ID of the flow run you want to resume. - `run_input`: A dictionary of inputs to provide to the flow run. This is where you can specify the new parameters. Here's a simplified example of how you might use it:
Copy code
python
from prefect import resume_flow_run

flow_run_id = "your-flow-run-id"
new_parameters = {
    "param1": "new_value1",
    "param2": "new_value2"
}

resume_flow_run(flow_run_id, run_input=new_parameters)
For more details, you can check the Prefect documentation on writing flows and the source code for `resume_flow_run`.
m
@Marvin how can I update flow parameters on a flow run
m
In Prefect 3.x, updating the parameters of a running flow is not directly supported. Flow parameters are set at the start of the flow run and are immutable during execution. They are specified when you initiate a flow run, typically using the Prefect API, CLI, or UI. Here's a summary of how parameters work: - Parameter Specification: When you create a flow run, you provide parameter values. These are set as keyword arguments and are validated before the flow starts. - Immutability: Once a flow run begins, its parameters cannot be changed. This ensures consistency and predictability of the flow execution. - Flow Restart: If you need to change parameters, you must restart the flow with the new parameters. For more details on managing flow parameters, you can refer to the Prefect documentation on writing flows. If you have any further questions or need assistance with a specific use case, feel free to ask!