Tim-Oliver
03/31/2023, 11:13 AMTim-Oliver
03/31/2023, 11:34 AMSerina
03/31/2023, 8:09 PMIs there a way to link artifacts from the flow-run view? Such that I can go from a task-run to the artifact?This is definitely on our radar and we are actively working on it 🙂
Serina
03/31/2023, 8:13 PMCould I create an artifact at the start of long-running task and get it shown immediately?You can do that. Please see this MRE where your task will still be running whilst your artifact is already in the UI.
from prefect import task, flow
from prefect.artifacts import create_table_artifact
from prefect.logging.loggers import get_run_logger
import time
@task
def my_table_task():
logger = get_run_logger()
table_data = [
{"id": 0, "name": "Dublin", "lat": 53.3498, "lon": -6.2603,},
{"id": 1, "name": "London", "lat": 51.5074, "lon": -0.1278,},
]
<http://logger.info|logger.info>("Creating table artifact")
table_artifact = create_table_artifact(
key="cities-table",
table=table_data,
description="A table of cities and their coordinates",
)
<http://logger.info|logger.info>("Created table artifact")
<http://logger.info|logger.info>("Sleeping for 100 seconds")
time.sleep(100)
<http://logger.info|logger.info>("Done sleeping")
return table_artifact
@flow
def my_flow():
table = my_table_task()
return table
if __name__ == "__main__":
my_flow()
Tim-Oliver
04/03/2023, 1:00 PMkey
argument, which silently failed to create the artifact.Serina
04/03/2023, 2:34 PMSerina
04/03/2023, 2:35 PM