Prefect Deployments Toolkit
A lightweight CLI toolkit for managing Prefect deployment lifecycles in CI/CD pipelines. It detects deployments that were added, modified, or removed between two git references, and applies (creates, updates, or deletes) those deployments against Prefect Cloud or a self-hosted Prefect server — via either the Prefect CLI or direct REST API calls.
Built for teams running many Prefect flows out of a monorepo, where each deployment is defined in its own YAML file alongside a shared prefect_base.yaml, and CI needs to figure out which deployments actually changed before re-registering them.
Features
- Change detection — diff deployments between two git refs (a merge request source vs. target branch, or
HEAD~1vs.HEADafter a merge) and get back exactly which deployments were added, modified, or removed. - Unified push / pull-request logic — one code path handles both
pull_request(compare local files against a fetched base branch) andpush/pull_request_target(compareHEAD~1againstHEAD) event styles. - Dual deploy backends — apply deployments using the
prefectCLI as a subprocess, or bypass it entirely with direct REST API calls for faster, more controllable deploys. Both backends work against Prefect Cloud and self-hosted/OSS Prefect servers. - Dev/prod environment overrides — automatic name prefixing, work pool substitution, and schedule pausing for dev environments.
- Concurrent deployment application — apply multiple deployments in parallel with clean, non-interleaved log output per deployment.
- Duplicate deployment name detection — warns (or optionally cleans up) when the same deployment name resolves to more than one flow.
Installation
pip install prefect-deployments-toolkit
Requires Python >= 3.9.
Usage
1. Detect modified deployments
python -m prefect_deployments_toolkit.get_modified_deployments \
--modified-by push \
--base-ref main \
--deployments-dir deployments
Prints a comma-separated list of changed deployment names to stdout, and (if running inside GitHub Actions) writes DEPLOYMENT_NAMES, NEW_OR_MODIFIED_DEPLOYMENT_NAMES, and REMOVED_DEPLOYMENT_NAMES to GITHUB_ENV.
--modified-by accepts:
pull_request— compares your local working tree against the fetched base branch (use during an open MR/PR).pushorpull_request_target— comparesHEAD~1againstHEAD(use after a merge to a protected branch).
2. Apply deployments
python -m prefect_deployments_toolkit \
--deployment-names "flow_a,flow_b" \
--enable-schedule false \
--tag dev \
--reference feature-branch-1 \
--repo-name my-flows-repo \
--custom-image "" \
--deployments-dir deployments \
--dev-work-pool my-dev-work-pool \
--backend rest \
--enforce-unique-deployment-names false
Expected Repository Layout
deployments/
├── prefect_base.yaml # shared config merged into every deployment
├── flow_a.yaml
├── flow_b.yaml
└── ...
Each deployment YAML file must declare a deployments: list with at least a name and entrypoint key, following the standard Prefect deployment YAML schema.
Backends
| Backend | How it works | When to use |
|---|---|---|
cli |
Shells out to prefect deploy |
Simplest, matches local prefect deploy behavior exactly |
rest |
Talks directly to the Prefect REST API | Faster for many concurrent deployments, avoids CLI subprocess overhead |
Both backends work against Prefect Cloud (api.prefect.cloud) and self-hosted/OSS Prefect servers — the target is determined entirely by PREFECT_API_URL.
Environment Variables
| Variable | Required | Purpose |
|---|---|---|
PREFECT_API_URL |
Yes | Full API base URL. Cloud: https://api.prefect.cloud/api/accounts/<id>/workspaces/<id>. Self-hosted: e.g. https://your-prefect-server.company.com/api |
PREFECT_API_KEY |
Only for Prefect Cloud | Cloud API key, sent as a Bearer token |
PREFECT_API_AUTH_STRING |
Only for self-hosted servers with Basic auth enabled | Sent as HTTP Basic auth (base64-encoded) |
Neither PREFECT_API_KEY nor PREFECT_API_AUTH_STRING is required if your self-hosted Prefect server has no authentication configured — only PREFECT_API_URL is mandatory in every setup.
License
Licensed under PolyForm Noncommercial 1.0.0. You may view, use, and modify this software for noncommercial purposes. Commercial use — including building products, services, or automation on top of it — requires a separate license. Contact kwolski@dyvenia.com for commercial licensing inquiries.
Contributing
Issues and pull requests are welcome for noncommercial use cases. Please open an issue before submitting a large PR to discuss scope.
Metadata
Release files for prefect-deployments-toolkit 0.1.8
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| prefect_deployments_toolkit-0.1.8.tar.gz | 312.2 kB | With provenance | Details for prefect_deployments_toolkit-0.1.8.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| prefect_deployments_toolkit-0.1.8-py3-none-any.whl | Python 3 | none | any | Details for prefect_deployments_toolkit-0.1.8-py3-none-any.whl |
Total release size: 338.2 kB
Release files / prefect_deployments_toolkit-0.1.8.tar.gz
| Download URL | prefect_deployments_toolkit-0.1.8.tar.gz |
|---|---|
| Size | 312.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bab870a31d8ec0a61cb5cd87ac2ec0c8d6169d6c9851d7429c717c8cccc688b3
|
|
BLAKE2b-256 checksum How to use checksums |
53e4221d80334b51a5b311a61fc983c64bd5f8df517cf2a81ef1b8664afbb748
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 28, 2026.
Transparency logRelease files / prefect_deployments_toolkit-0.1.8-py3-none-any.whl
| Download URL | prefect_deployments_toolkit-0.1.8-py3-none-any.whl |
|---|---|
| Size | 26.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5d661f7877ae13e64f347f50ece6d525aff35c405ff519eee3618c28ebace657
|
|
BLAKE2b-256 checksum How to use checksums |
e87328c1c516c1b19eabbab457373d44195fe7a185abc0829f1d2e858bd6ce5b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 28, 2026.
Transparency logSecurity for prefect-deployments-toolkit 0.1.8
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for prefect_deployments_toolkit-0.1.8.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 28, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.