Hi :prefect:team, love the new artifacts! Is there...
# ask-community
t
Hi Pteam, love the new artifacts! Is there a way to link artifacts from the flow-run view? Such that I can go from a task-run to the artifact?
At what point in time are artifacts generated? My observation so far tells me they are generated once the task-run is completed. Could I create an artifact at the start of long-running task and get it shown immediately? I am thinking about linking to a weights&biases dashboard at the start of the training-task.
s
Hi Tim, we’re glad you like artifacts so far!
Is 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 🙂
🔥 1
Could 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.
Copy code
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()
🙏 1
t
Okay, this works now for me as well. I forgot to pass the
key
argument, which silently failed to create the artifact.
s
Once we add the ability to see artifacts from a flow run or task run, you should be able to view key-less artifacts.
Otherwise there isn’t a great way to identify them on the Artifacts page.
👍 1