Within a collection in the W&B Registry, you can view a history of the artifacts that an ML experiment uses. This history is called a lineage graph.
You can also view lineage graphs for artifacts you log to W&B that are not part of a collection.
- Multiple runs log the split_zoo_dataset:v4artifact.
- The “rural-feather-20” run uses the split_zoo_dataset:v4artifact for training.
- The output of the “rural-feather-20” run is a model artifact called zoo-ylbchv20:v0.
- A run called “northern-lake-21” uses the model artifact zoo-ylbchv20:v0to evaluate the model.
Mark an artifact as an input or dependency of a run with thewandb.init.use_artifact API.
The proceeding code snippet shows how to use the use_artifact. Replace values enclosed in angle brackets (< >) with your values:
import wandb
# Initialize a run
run = wandb.init(project="<project>", entity="<entity>")
# 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.init.log_artifact) to declare an artifact as an output of a run.
The proceeding code snippet shows how to use the wandb.init.log_artifact API. Ensure to replace values enclosed in angle brackets (< >) with your values:
import wandb
# Initialize a run
run = wandb.init(entity  "<entity>", project = "<project>",)
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)
View lineage graphs in a collection
View the lineage of an artifact linked to a collection in the W&B Registry.
- Navigate to the W&B Registry.
- Select the collection that contains the artifact.
- From the dropdown, click the artifact version you want to view its lineage graph.
- Select the “Lineage” tab.
Once you are in an artifact’s lineage graph page, you can view additional information about any node in that lineage graph.
Select a run node to view that run’s details, such as the run’s ID, the run’s name, the run’s state, and more. As an example, the proceeding image shows information about therural-feather-20 run:
Select an artifact node to view that artifact’s details, such as its full name, type, creation time, and associated aliases.