Robert Szomolanyi
03/27/2026, 10:12 AMMarvin
03/27/2026, 10:12 AMMarvin
03/27/2026, 10:14 AMfrom prefect import flow
from prefect.artifacts import create_progress_artifact, update_progress_artifact
@flow
def run():
prog_id = create_progress_artifact(progress=0.0, key="my-progress", description="Processing")
for i in range(1, 6):
# ... do work ...
update_progress_artifact(artifact_id=prog_id, progress=i * 20.0)
- Markdown, link, table, image artifacts: There’s no in-place update. Create a new artifact with the same key; Prefect will version them and mark the newest as “latest” in the UI.
from prefect import flow
from prefect.artifacts import create_markdown_artifact
@flow
def run():
create_markdown_artifact(key="daily-report", markdown="# Report v1")
# later in the same flow
create_markdown_artifact(key="daily-report", markdown="# Report v2") # new version; same key
Notes:
- Using the same key groups versions and ensures the UI shows the latest; history is preserved.
- Async variants exist (acreate_*, aupdate_progress_artifact) if you’re writing async flows.Robert Szomolanyi
03/27/2026, 10:17 AMMarvin
03/27/2026, 10:17 AMMarvin
03/27/2026, 10:21 AMfrom prefect.artifacts import create_markdown_artifact, Artifact
from prefect.client.orchestration import get_client
from prefect.client.schemas.actions import ArtifactUpdate
# Create once (returns the artifact UUID)
artifact_id = create_markdown_artifact(key="my-report", markdown="# Initial", description="Latest report")
# Update in place (no history/version created)
client = get_client(sync_client=True)
client.update_artifact(
artifact_id=artifact_id,
artifact=ArtifactUpdate(data="# Updated content", description="Latest report")
)
2) Update by key (if you don’t have the ID yet) — async flow example
from prefect import flow
from prefect.artifacts import Artifact, MarkdownArtifact
from prefect.client.orchestration import get_client
from prefect.client.schemas.actions import ArtifactUpdate
@flow
async def upsert_markdown(md: str):
async with get_client() as client:
latest = await Artifact.aget(key="my-report")
if latest:
await client.update_artifact(
artifact_id=latest.id,
artifact=ArtifactUpdate(data=md, description="Latest report"),
)
else:
await MarkdownArtifact(key="my-report", markdown=md, description="Latest report").acreate()
If you previously created multiple versions with the same key and want to keep only one, you can delete the older ones via client.delete_artifact(old_id).