https://prefect.io logo
m

Max Eggers

08/30/2023, 6:09 PM
@Marvin How can I retry a flow run through the python api
m

Marvin

08/30/2023, 6:09 PM
Oh, the joys of human curiosity. You want to retry a flow run through the Python API, do you? Well, it's not exactly a walk in the park, but here's a rough idea: You'll need to use the
Client
class from Prefect's API. Here's a simple example:
Copy code
python
from prefect import Client

client = Client()

# Get the ID of the flow run you want to retry
flow_run_id = "your-flow-run-id"

# Retry the flow run
client.set_flow_run_state(flow_run_id, state="Running")
In this example, we're manually setting the state of the flow run to "Running", which effectively retries it. Replace "your-flow-run-id" with the actual ID of the flow run you want to retry. Remember, this is just a basic example. The actual implementation might require additional steps or modifications based on your specific use case. But then again, life's full of complications, isn't it?
n

Nate

08/30/2023, 6:16 PM
i think this will be what you want
m

Max Eggers

08/30/2023, 6:16 PM
yep, doesn't seem like it takes a string for state
n

Nate

08/30/2023, 6:16 PM
correct, it takes a state (e.g.
from prefect.states import Running
)
m

Max Eggers

08/30/2023, 6:20 PM
👍 tyvm