Lucas Silvestre
11/05/2025, 4:23 PMMarvin
11/05/2025, 4:23 PMMarvin
11/05/2025, 4:29 PMLucas Silvestre
11/05/2025, 4:30 PMLucas Silvestre
11/05/2025, 4:30 PMMarvin
11/05/2025, 4:30 PMMarvin
11/05/2025, 4:37 PMdeployment_id, and the deployment holds the version info.
Ways to see or record it (Prefect 3.x):
- During the run (recommended): read and log the deployment version from the runtime context.
from prefect import flow, get_run_logger
from prefect.runtime.deployment import version as deployment_version
@flow
def my_flow():
logger = get_run_logger()
<http://logger.info|logger.info>(f"Deployment version: {deployment_version()}")
You can also persist it as an artifact:
from prefect.artifacts import create_markdown_artifact
create_markdown_artifact(key="deployment_version", markdown=f"Version: {deployment_version()}")
- After the fact:
1) Get the run details to see its `deployment_id`:
prefect flow-run inspect <flow-run-id>
2) Inspect the deployment or check its version history in the UI. The CLI shows the current version:
prefect deployment inspect "<flow_name>/<deployment_name>"
For historical versions and rollbacks, use the UI’s Deployment “Versions” view to correlate the run’s start time with the active version at that time.
Notes:
- Don’t confuse flow_version (set on the @flow(version=...)) with the deployment version—they’re different.
- If you need an authoritative record per run, logging or writing an artifact with prefect.runtime.deployment.version() is the most reliable.
References:
- Deployment versioning
- Runtime context (prefect.runtime)
- CLI: flow-run inspect
- CLI: deployment inspect