prefect deployment run '<flow-name>/<deployment-name>
in python
m
Marvin
09/10/2024, 11:13 AM
Ah, you want the Python equivalent of firing up a specific deployment in Prefect. Let's get your Prefect version to give you the most accurate help. Could you please share if you are using Prefect 2.x or 3.x?
a
Alireza
09/10/2024, 11:14 AM
@Marvin 2.x
m
Marvin
09/10/2024, 11:14 AM
You can run a deployment in Prefect 2.x using Python by utilizing the
run_deployment
API method. Here's a concise example:
Copy code
python
from prefect.deployments import run_deployment
# Replace with your flow and deployment names
flow_name = "<flow_name>"
deployment_name = "<deployment_name>"
# Initiate the deployment run
flow_run = run_deployment(f"{flow_name}/{deployment_name}")
# Optionally, wait for the flow run to complete and get the result
flow_run_state = flow_run.wait()
print(flow_run_state)
This code snippet runs a specified deployment and waits for its completion.
Sources:
- Prefect Deployments Concept: Prefect Deployments
- GitHub Issues and Docs examples: GitHub Issue 15276
Feel free to ask if you need further assistance!
Bring your towel and join one of the fastest growing data communities. Welcome to our second-generation open source orchestration platform, a completely rethought approach to dataflow automation.