Skip to content

Commit

Permalink
Adds script for updating deployment concurrency limits via the API
Browse files Browse the repository at this point in the history
EmilRex committed Dec 16, 2024
1 parent 7a62c16 commit 1db630a
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions scripts/update-deployment-concurrency-limit.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
"""
Update a deployment's concurrency limit via the API. This is a workaround
for instances where Prefect 2.x is installed and models do not directly support
updating the concurrency limit.
"""

import uuid

import typer
from prefect import get_client


def main(
deployment_id: uuid.UUID, limit: int | None = None, strategy: str = "CANCEL_NEW"
):
with get_client(sync_client=True) as client:
client._client.patch(
f"/deployments/{deployment_id}",
json={
"concurrency_limit": limit,
"concurrency_options": {"collision_strategy": strategy},
},
)


if __name__ == "__main__":
typer.run(main)

0 comments on commit 1db630a

Please sign in to comment.