Joshua Caskie
03/05/2025, 6:10 PMMarvin
03/05/2025, 6:11 PMget_client
function to interact with the Prefect API. Here's a concise example:
python
from prefect import get_client
async def get_deployment_id(flow_name, deployment_name):
async with get_client() as client:
deployments = await client.read_deployments()
for deployment in deployments:
if deployment.flow_name == flow_name and deployment.name == deployment_name:
return deployment.id
return None
# Example usage
flow_name = "my_flow"
deployment_name = "my_deployment"
deployment_id = await get_deployment_id(flow_name, deployment_name)
print(deployment_id)
This code asynchronously fetches all deployments and checks for a match with the given flow and deployment names, returning the deployment ID if found.
For more details, you can explore the Prefect documentation on deployments.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.
Powered by