Repository navigation
How to Remove Artifacts from a Running Flow #18130
Replies: 1 comment
|
You can keep the image artifact's ID and update that artifact, instead of creating another version for every percentage change: import asyncio
from prefect import flow
from prefect.artifacts import acreate_image_artifact
from prefect.client.orchestration import get_client
from prefect.client.schemas.actions import ArtifactUpdate
@flow
async def report_status():
artifact_id = await acreate_image_artifact(
image_url="https://example.com/status-0.png",
key="status-image",
)
async with get_client() as client:
for percent in (10, 20, 30):
await client.update_artifact(
artifact_id,
ArtifactUpdate(data=f"https://example.com/status-{percent}.png"),
)
return artifact_id
artifact_id = asyncio.run(report_status())Use your real image URLs and perform each update after generating the next status image. The image artifact's I checked this with Prefect 3.8.8 against a real temporary local API. After the three updates, the API held one artifact with the original ID, type A shared |
Uh oh!
There was an error while loading. Please reload this page.
I have a long running flow that pulls data (slowly) from an API. I created an image artifact that displays status information for the running flow. Every 10% it moves forward to completion, a new artifact is created with the same key. However, all artifacts show-up. It would be nice to be able to remove all artifacts with a given key and add the new one in so I can always to to the flow and see the flow status graphs in the image artifact without having several of them there that ran previously.
All reactions