Skip to content

feat: add update methods for artifacts to support mid-flow updates#19994

Closed
majiayu000 wants to merge 1 commit intoPrefectHQ:mainfrom
majiayu000:feat/update-artifacts-mid-flow-10955
Closed

feat: add update methods for artifacts to support mid-flow updates#19994
majiayu000 wants to merge 1 commit intoPrefectHQ:mainfrom
majiayu000:feat/update-artifacts-mid-flow-10955

Conversation

@majiayu000
Copy link
Copy Markdown
Contributor

Summary

Fixes #10955

This PR adds the ability to update existing artifacts during a flow run, addressing the use case where users have long-running flows and want to update artifact data progressively rather than creating new versions.

Changes:

  • Added update() and aupdate() methods to the Artifact base class
  • Added convenience functions for updating specific artifact types:
    • update_markdown_artifact / aupdate_markdown_artifact
    • update_table_artifact / aupdate_table_artifact
    • update_link_artifact / aupdate_link_artifact
    • update_image_artifact / aupdate_image_artifact

These complement the existing update_progress_artifact function.

Example Usage

from prefect import flow
from prefect.artifacts import create_table_artifact, update_table_artifact

@flow
def my_long_running_flow():
    # Create initial artifact
    artifact_id = create_table_artifact(
        key="processing-status",
        table=[{"item": "A", "status": "pending"}],
    )
    
    # ... do some work ...
    
    # Update artifact mid-flow
    update_table_artifact(
        artifact_id=artifact_id,
        table=[
            {"item": "A", "status": "complete"},
            {"item": "B", "status": "pending"},
        ],
    )

Test plan

  • Added tests for update_markdown_artifact and update_table_artifact in flow context
  • Verified existing tests still pass

Signed-off-by: majiayu000 1835304752@qq.com

This adds the ability to update existing artifacts during a flow run,
addressing the use case where users have long-running flows and want
to update artifact data progressively rather than creating new versions.

Changes:
- Add `update()` and `aupdate()` methods to the `Artifact` base class
- Add convenience functions for updating specific artifact types:
  - `update_markdown_artifact` / `aupdate_markdown_artifact`
  - `update_table_artifact` / `aupdate_table_artifact`
  - `update_link_artifact` / `aupdate_link_artifact`
  - `update_image_artifact` / `aupdate_image_artifact`

These complement the existing `update_progress_artifact` function.

Closes PrefectHQ#10955

Signed-off-by: majiayu000 <1835304752@qq.com>
@github-actions github-actions Bot added enhancement An improvement of an existing feature labels Dec 29, 2025
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Dec 29, 2025

CodSpeed Performance Report

Merging #19994 will not alter performance

Comparing majiayu000:feat/update-artifacts-mid-flow-10955 (0dbef57) with main (8f441a4)

Summary

✅ 2 untouched

@github-actions
Copy link
Copy Markdown
Contributor

This pull request is stale because it has been open 14 days with no activity. To keep this pull request open remove stale label or comment.

@github-actions
Copy link
Copy Markdown
Contributor

This pull request was closed because it has been stale for 14 days with no activity. If this pull request is important or you have more to add feel free to re-open it.

@github-actions github-actions Bot closed this Jan 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement An improvement of an existing feature status:stale

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update artifacts mid flow run

1 participant