<@ULVA73B9P> is it possible to display the value o...
# ask-marvin
j
@Marvin is it possible to display the value of persisted results in the results tab in prefect ui, and how can this be done?
m
Persisting results in Prefect is typically done by storing the data at a location in your infrastructure, and Prefect then keeps a reference to this result. By default, the Prefect API does not store your results except in special cases. Some features, such as task cache keys, require the results to be persisted. If you want to view these persisted results in the Prefect UI, you would usually need to go to the storage location where the results are kept. The Prefect UI itself does not store the actual results but may provide you with information related to the execution of tasks and flows, such as statuses and logs. It's worth noting that the UI could allow users to navigate and potentially view details about the persisted results if the references to the results are properly stored and accessible. However, direct viewing of result values in the UI (especially for large data) is not typical, and there is no direct reference in the documentation mentioning a dedicated results tab for this purpose. Instead, users will need to rely on their storage backend and any logging or references captured in the Prefect tasks to access the results. For further information or updates, it might be useful to look at the official Prefect documentation or the GitHub repository for any recent changes or feature enhancements related to this topic.
n
plus1 this is not done by design to avoid exposing potentially sensitive result values i would recommend checking out artifacts that you can create in a flow run and would then be linked on the corresponding flow run page @Marvin please give a tldr on artifacts
upvote 1
m
Artifacts in Prefect are persisted outputs like tables, Markdown, or links. These outputs are stored in Prefect Cloud or on a Prefect server instance and are displayed within the Prefect UI. Artifacts serve as a mechanism to easily track and monitor the products of your flows as they are created or updated over time. Published artifacts can be linked to a specific task or flow run, but it's also possible to create them independently of any flow run context. They essentially enable better tracking and visibility of outputs directly within the UI, without exposing possibly sensitive result values that are part of the task or flow execution. In summary, artifacts provide a safe and convenient way to monitor and access the outputs of your workflows in the Prefect UI.
n
@Marvin code example dude cmon
😂 1
m
Artifacts in Prefect are a way to persist and showcase outputs such as Markdown, tables, or links, which can be stored on Prefect Cloud or a Prefect server instance. Here is an example of how to create an artifact in a Prefect flow:
Copy code
python
from prefect import flow, task
from prefect.artifacts import create_link, create_markdown

@task
def generate_data():
    # Your logic to generate data
    data = {"example": "data"}
    return data

@task
def process_data(data):
    # Your logic to process data
    processed_data = f"Processed: {data}"
    return processed_data

@flow
def my_flow():
    data = generate_data()
    processed_data = process_data(data)

    # Create a Markdown artifact
    create_markdown("# This is a Markdown artifact\nThis flow processed the following data:\n```\n" + str(processed_data) + "\n```")

    # Suppose you have a link to a dashboard or external resource
    dashboard_url = "<http://example.com/dashboard>"
    # Create a link artifact
    create_link(dashboard_url)

# Run the flow
my_flow()
In this code example: - The
generate_data
task simulates generating some data. - The
process_data
task simulates processing that data. - In the
my_flow
flow, after processing the data, we create a Markdown artifact using
create_markdown
, which contains a description and the processed data. - We also create a link artifact using
create_link
, which could, for example, point to a dashboard related to the flow. These artifacts will be stored and rendered in the Prefect UI, making it easy to monitor and share information with your team or stakeholders.