Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Docs: add Concepts page for Artifacts API #5158
Docs: add Concepts page for Artifacts API #5158
Changes from all commits
1a7058d
422571c
31c52de
437c2d5
49158d5
f5641f5
54ca8d3
3766b7a
2d00a74
05368bd
5c399ba
f03c173
515a3de
8eb4cc8
bfb0f7d
d7e1810
c14b5fc
d77cd5a
d48e12e
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
Artifacts
The Artifacts API enables you to publish data from task runs that is rendered natively in the Prefect UI, both Prefect Cloud and Prefect Server.
Using the Artifacts API, you can easily publish information directly to the Prefect UI. These published artifacts are linked to specific task runs and flow runs, and artifacts can render more sophisticated information than you'd typically log, such as reports, tables, charts, images, and links to external data.
Currently, the Artifacts API enables you to render the following artifact types:
Link artifacts render a clickable hyperlink as an artifact.
Markdown artifacts render strings that can include Github-flavored Markdown markup for formatting.
::: tip Artifacts render individually Note that each artifact you create in a task renders as an individual artifact in the Prefect UI. In other words, each call to
create_link_artifact()
orcreate_markdown_artifact()
creates its own, separate artifact.Within a task, you may use these commands as many times as necessary, but they do not operate in the same manner as a
print()
command where you might string together multiple calls to add additional items to a report.As a best practice, such as when using
create_markdown_artifact()
to create artifacts like reports or summaries, compile your message string separately, then pass tocreate_markdown_artifact()
orupdate_markdown_artifact()
to create the full artifact. :::For more background on the design goals for the Artifacts API, see the Introducing: The Artifacts API blog post and the Great Expectations task.
UI
In the Prefect UI, to view artifacts created by a flow run, navigate to a specific flow run, then click the Artifacts tab.
You can navigate between the artifacts created for a flow run by clicking the dots or arrows above the artifacts.
Each artifact is identified by task that created it.
To view the artifacts created by a task run, navigate to the specific task run, then click the Artifacts tab.
You can navigate between the artifacts created for a task run by clicking the dots or arrows above the artifacts.
Creating Link Artifacts
To create link artifacts, just import
create_link_artifact
fromprefect.backend.artifacts
, then add a call tocreate_link_artifact()
to any task orchestrated through a Prefect API.::: tip Import path If you are using a version prior to Prefect 0.15.8, import
create_link
fromprefect.artifacts
. :::Pass
create_link_artifact()
a string containing the absolute URL of the location to which you want to link.After the task runs, navigate to the UI’s Artifacts tab to see the output.
In addition to creating an artifact,
create_link_artifact()
returns the ID of the artifact it created. You can use the ID to:update_link_artifact()
.delete_artifact()
.Note that
update_link_artifact()
updates an existing link artifact by replacing the entire current artifact string with the new data provided. See Creating Markdown Artifacts and Deleting Artifacts for examples of these update and delete operations.Creating Markdown Artifacts
To create link artifacts, just import
create_markdown_artifact
fromprefect.backend.artifacts
, then add a call tocreate_markdown_artifact()
to any task orchestrated through a Prefect API.::: tip Import path If you are using a version prior to Prefect 0.15.8, import
create_markdown
fromprefect.artifacts
. :::Pass
create_markdown_artifact()
a string that will be rendered as an artifact. The string can contain any Github-flavored Markdown markup including image references, links, and tables.Note that any images referenced in your markdown must be linked by the absolute URL of a publicly available image. Linking to local files or by relative URL is not supported.
After the task runs, navigate to the UI’s Artifacts tab to see the output.
create_markdown_artifact()
accepts any valid Python string and variable interpolation including, for example, f-strings.In addition to creating an artifact,
create_markdown_artifact()
returns the ID of the artifact it created. You can use the ID to:update_markdown_artifact()
.delete_artifact()
.Note that
update_markdown_artifact()
updates an existing markdown artifact by replacing the entire current markdown artifact with the new data provided. Here's an example of appending new report data to an existing artifact.::: tip Markdown strings and line endings Explicit line endings and blank lins are important to rendering markdown correctly. When formatting markdown for artifacts, make sure that you include explicit line endings (
\n
or equivalent) where appropriate. :::Deleting Artifacts
To delete existing link or markdown artifacts, import
delete_artifact
fromprefect.backend.artifacts
, then add a call todelete_artifact()
to any task orchestrated through a Prefect API, passing the ID of the artifact to delete.Artifacts cannot be retrieved once deleted.