-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
Adds script for updating deployment concurrency limits via the API
Showing
1 changed file
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |