Link an artifact to a collection
Based on your use case, follow the instructions described in the tabs below to link an artifact version.Before you start, check the following:
- The types of artifacts that collection permits. For more information about collection types, see “Collection types” within Create a collection.
- The registry that the collection belongs to already exists. To check that the registry exists, navigate to the Registry App and search for the name of the registry.
- Python SDK
- W&B Registry
- Artifact browser
Programmatically link an artifact version to a collection with For both approaches, specify the name of the artifact (
wandb.Run.link_artifact() or
wandb.Artifact.link().Use
wandb.Run.link_artifact() to link an artifact version within the context of a run. Use wandb.Artifact.link() to link an existing artifact version outside the context of a run.wandb.Artifact(name="<name>"), the type of artifact (wandb.Artifact(type="<type>"), and the target_path (wandb.Artifact(target_path="<target_path>")) of the collection and registry you want to link the artifact version to.The target path consists of the prefix "wandb-registry", the name of the registry, and the name of the collection separated by a forward slashes:Link an artifact version within the context of a run
Usewandb.Run.link_artifact() to link an artifact version within the context of a run. To do so,
first initialize a run with wandb.init(). Next, create an artifact object and add files to it. Finally, use the wandb.Run.link_artifact() method to link the artifact version to the collection.When you use this approach, a run is created in your W&B project. The artifact version is linked to the collection and is associated with that run.Copy and paste the code snippet below. Replace values enclosed in <> with your own:Link an artifact version outside the context of a run
Usewandb.Artifact.link() to link an existing artifact version outside the context of a run. With this approach,
you do not need to initialize a run with wandb.init(). This means that a run is not created in your W&B project. In other
words, the artifact version is linked to the collection without being associated with a run.First, create an artifact object and add files to it. Next, use the wandb.Artifact.link() method to link the artifact version to the collection.Copy and paste the code snippet below. Replace values enclosed in <> with your own:View linked artifacts in a registry
View information about linked artifacts such as metadata, lineage, and usage information in the W&B Registry.- Navigate to the W&B Registry.
- Select the name of the registry that you linked the artifact to.
- Select the name of the collection.
- If the collection’s artifacts log metrics, compare metrics across versions by clicking Show metrics.
- From the list of artifact versions, select the version you want to access. Version numbers are incrementally assigned to each linked artifact version starting with
v0. - To view details about an artifact version, click the version. From the tabs in this page, you can view that version’s metadata (including logged metrics), lineage, and usage information.
Full name of a linked artifact
Troubleshooting
Below are some common things to double check if you are not able to link an artifact.Logging artifacts from a personal account
Artifacts logged to W&B with a personal entity can not be linked to the registry. Make sure that you log artifacts using a team entity within your organization. Only artifacts logged within an organization’s team can be linked to the organization’s registry.Ensure that you log an artifact with a team entity if you want to link that artifact to a registry.
Find your team entity
W&B uses the name of your team as the team’s entity. For example, if your team is called team-awesome, your team entity isteam-awesome.
You can confirm the name of your team by:
- Navigate to your team’s W&B profile page.
- Copy the site’s URL. It has the form of
https://wandb.ai/<team>. Where<team>is the both the name of your team and the team’s entity.
Log from a team entity
- Specify the team as the entity when you initialize a run with
wandb.init(). If you do not specify theentitywhen you initialize a run, the run uses your default entity which may or may not be your team entity.
-
Log the artifact to the run either with run.log_artifact or by creating an Artifact object and then adding files to it with:
To log artifacts, see Construct artifacts.
- If an artifact is logged to your personal entity, you will need to re-log it to an entity within your organization.
Confirm the path of a registry in the W&B App UI
There are two ways to confirm the path of a registry with the UI: create an empty collection and view the collection details or copy and paste the autogenerated code on the collection’s homepage.Copy and paste autogenerated code
- Navigate to the W&B Registry at https://wandb.ai/registry/.
- Click the registry you want to link an artifact to.
- At the top of the page, you will see an autogenerated code block.
- Copy and paste this into your code, ensure to replace the last part of the path with the name of your collection.

Create an empty collection
- Navigate to the W&B Registry at https://wandb.ai/registry/.
- Click the registry you want to link an artifact to.
- Click on the empty collection. If an empty collection does not exist, create a new collection.
- Within the code snippet that appears, identify the
target_pathfield within.link_artifact(). - (Optional) Delete the collection.

target_path parameter:
Ensure that you replace the name of the collection from the temporary collection with the name of the collection that you want to link your artifact to.