View in #prefect-community on Slack
@Rajan_Subramanian: is there a way programmatically to get a list of deployments in prefect?
i know we can do
prefect deployment ls
but i want to get all my created deployments…1000 of them and run them all. so im assuming i have to programatically execute prefect deployment run deploymenet_name for each deployment in my deployments
@Kevin_Kho: The deployments endpoint doesn’t seem to have a “list all”. I’d need to ask someone
You would do:
async with get_client() as client:
deployments = await client.read_deployments(
flow_filter=FlowFilter(name={"any_": flow_name}) if flow_name else None
)
and they also you will need to paginate through the deployments (pass limit
and offset
to client.read_deployments
) because the default limit is 200 objects
@Rajan_Subramanian: oh it only reads 200?
@Kevin_Kho: Returns 200 at a time so you need to add offset to get the next 200
@Rajan_Subramanian: ah got it