> ## Documentation Index
> Fetch the complete documentation index at: https://wb-21fd5541-style-guide-models-artifacts-20260603-165211.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

> View and traverse artifact lineage graphs to track the inputs and outputs of W&B runs as a directed acyclic graph.

# Explore artifact lineage graphs

W\&B tracks the inputs and outputs of runs using directed acyclic graphs (DAGs) called *lineage graphs*. Lineage graphs are visual representations of the relationships between artifacts and runs in an ML experiment. They show how data and models
flow through different stages of the ML lifecycle, from raw data ingestion to model training and evaluation.

Tracking artifact lineage provides several key advantages:

* **Reproducibility**: Teams can reproduce experiments, models, and results for debugging, experimentation, and validation.
* **Version control**: Track changes to artifacts over time so that teams can revert to previous data or model versions when needed.
* **Auditing**: Maintain a detailed record of artifacts and transformations to support compliance and governance.
* **Collaboration**: Improve teamwork by making experiment history transparent, reducing duplicated effort, and accelerating development.

## View an artifact's lineage graph

To view an artifact's lineage graph:

1. Navigate to your project's workspace in the W\&B App.
2. Click the **Artifacts** tab in the project sidebar.
3. Select an artifact, then click the **Lineage** tab.

## Navigate lineage graphs

The lineage graph is a visual representation of the relationships between artifacts and runs in an ML experiment. Use the W\&B App UI or the Python SDK to explore and traverse an artifact's lineage graph.

<Tabs>
  <Tab title="W&B App UI">
    Nodes with green icons represent runs. Nodes with blue icons represent artifacts. Arrows between nodes indicate the input and output of a run or artifact.

    Artifact nodes display the artifact's name along with the version of the artifact in the form `[ARTIFACT_NAME]:[VERSION]`. The artifact's type appears above the name of the artifact.

    <Note>
      You can view the type and the name of an artifact in both the left sidebar and in the lineage graph node.
    </Note>

    Run nodes display the run's name.

    <Frame>
      <img src="https://mintcdn.com/wb-21fd5541-style-guide-models-artifacts-20260603-165211/xrgAaxIcOWSlGEO8/images/artifacts/lineage2.png?fit=max&auto=format&n=xrgAaxIcOWSlGEO8&q=85&s=bc955ffb1766ff243ec3b630f1d780b0" alt="Run and artifact nodes" width="4774" height="1932" data-path="images/artifacts/lineage2.png" />
    </Frame>

    Click any individual run to get more information about that run, such as the run's start time, time duration, author, and job type. Click any individual artifact to get more information about the artifact, such as its aliases, creation time, type, version, description, the run that logged the artifact, and file size.

    <Frame>
      <img src="https://mintcdn.com/wb-21fd5541-style-guide-models-artifacts-20260603-165211/xrgAaxIcOWSlGEO8/images/artifacts/lineage3a.gif?s=5c02825a60f845c5395aee5461014866" alt="Previewing a run" width="4754" height="1930" data-path="images/artifacts/lineage3a.gif" />
    </Frame>

    W\&B groups runs that create multiple versions of the same artifact into a cluster. Click a specific artifact version listed within the cluster to view specific information about that artifact version.

    <Frame>
      <img src="https://mintcdn.com/wb-21fd5541-style-guide-models-artifacts-20260603-165211/xrgAaxIcOWSlGEO8/images/artifacts/lineage_multiple_artifact_versions.png?fit=max&auto=format&n=xrgAaxIcOWSlGEO8&q=85&s=810a987a376747adf7d55aa81669568a" alt="Cluster of artifact versions in a lineage graph" width="4756" height="2044" data-path="images/artifacts/lineage_multiple_artifact_versions.png" />
    </Frame>

    Click and drag a node to rearrange the graph to customize the layout. You can also zoom in and out of the graph to get a better view of the nodes and their relationships.

    <Frame>
      <img src="https://mintcdn.com/wb-21fd5541-style-guide-models-artifacts-20260603-165211/xrgAaxIcOWSlGEO8/images/artifacts/lineage_rearrange_nodes.gif?s=f02a7d7b338be519338aef40957cfc7b" alt="Rearranging nodes in a lineage graph" width="4754" height="2466" data-path="images/artifacts/lineage_rearrange_nodes.gif" />
    </Frame>

    Point to a node and click the eye icon to hide or show a node in the graph. Use this to declutter the graph and focus on specific nodes and their relationships.
  </Tab>

  <Tab title="W&B Python SDK">
    Programmatically navigate a graph using the W\&B Python SDK. Use an artifact object's
    [`logged_by()`](/models/ref/python/experiments/artifact#method-artifact-logged-by) and [`used_by()`](/models/ref/python/experiments/artifact#method-artifact-used-by) methods to walk the graph:

    ```python theme={null}
    with wandb.init() as run:
        artifact = run.use_artifact("artifact_name:latest")

        # Walk up and down the graph from an artifact:
        producer_run = artifact.logged_by()
        consumer_runs = artifact.used_by()
    ```
  </Tab>
</Tabs>

## Enable lineage graph tracking

To enable lineage graph tracking, you must mark artifacts as [inputs](/models/artifacts/explore-and-traverse-an-artifact-graph#track-the-input-of-a-run) or
[outputs](/models/artifacts/explore-and-traverse-an-artifact-graph#track-the-output-of-a-run) of a run using the W\&B Python SDK. The following sections describe how to mark each.

### Track the input of a run

Mark an artifact as the input (or dependency) of a run with the [`wandb.Run.use_artifact()`](/models/ref/python/experiments/run#method-runuse_artifact)
method. Specify the name of the artifact and an optional alias to reference a specific version of that artifact. The name of the
artifact is in the format `[ARTIFACT_NAME]:[VERSION]` or `[ARTIFACT_NAME]:[ALIAS]`.

Replace the bracketed placeholders with your values:

```python theme={null}
import wandb

# Initialize a run
with wandb.init(entity="[ENTITY]", project="[PROJECT]") as run:
  # Get artifact, mark it as a dependency
  artifact = run.use_artifact(artifact_or_name="[NAME]", aliases="[ALIAS]")
```

### Track the output of a run

Use [`wandb.Run.log_artifact()`](/models/ref/python/experiments/run#log_artifact) to declare an artifact as an output of a run. First,
create an artifact with the [`wandb.Artifact()`](/models/ref/python/experiments/artifact#wandb.Artifact) constructor. Then, log the
artifact as an output of the run with `wandb.Run.log_artifact()`.

Replace the bracketed placeholders with your values:

```python theme={null}
import wandb

# Initialize a run
with wandb.init(entity="[ENTITY]", project="[PROJECT]") as run:
  
  # Create an artifact
  artifact = wandb.Artifact(name = "[ARTIFACT_NAME]", type = "[ARTIFACT_TYPE]")
  artifact.add_file(local_path = "[LOCAL_FILEPATH]", name="[OPTIONAL_NAME]")

  # Log the artifact as an output of the run
  run.log_artifact(artifact_or_path = artifact)
```

## Artifact clusters

To keep large lineage graphs readable, W\&B groups dense levels of the graph into clusters that you can search and expand.

When a level of the graph has five or more runs or artifacts, W\&B creates a cluster. A cluster has a search bar to find specific versions of runs or artifacts and lets you pull an individual node from a cluster to continue investigating the lineage of a node inside a cluster.

Click a node to open a preview with an overview of the node. Click the arrow to extract the individual run or artifact so you can examine the lineage of the extracted node.

<Frame>
  <img src="https://mintcdn.com/wb-21fd5541-style-guide-models-artifacts-20260603-165211/xrgAaxIcOWSlGEO8/images/artifacts/lineage3b.gif?s=9c919c3d4c813975aeaa2a96b22ee88a" alt="Searching a run cluster" width="3016" height="1600" data-path="images/artifacts/lineage3b.gif" />
</Frame>
