Link an artifact version to a collection
8 minute read
Link an artifact version to a collection to make it available to other members in your organization. Linking an artifact to a collection brings that artifact version from a private, project-level scope, to a shared organization level scope.
You can link an artifact version to a collection programmatically with the W&B Python SDK or interactively with the W&B App.
When you link an artifact version to a collection, W&B creates a linked version of that artifact in the collection. The linked version points to the source artifact version that is logged to a run within a project. You can view the linked version in the collection and the source version in the project where it was logged.
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.
Programmatically link an artifact version to a collection with wandb.init.Run.link_artifact()
or wandb.Artifact.link()
. Use wandb.init.Run.link_artifact()
if you are linking an artifact version within the context of a run. Use wandb.Artifact.link()
if you are linking an artifact version outside the context of a run.
wandb.Artifact.link()
does not require you to initialize a run with wandb.init()
. wandb.init.Run.link_artifact()
requires you to initialize a run with wandb.init()
.For both approaches, specify the name of the artifact (wandb.Artifact(type="<name>"
), the type of artifact (wandb.Artifact(type="<type>"
), and the 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:
wandb-registry-{REGISTRY_NAME}/{COLLECTION_NAME}
Link an artifact version within the context of a run
When you use wandb.init.Run.link_artifact()
, you need to initialize a run with wandb.init()
. This means that a run is created in your W&B project.
Copy and paste the code snippet below. Replace values enclosed in <>
with your own:
import wandb
entity = "<team_entity>" # Your team entity
project = "<project_name>" # The name of the project that contains your artifact
# Initialize a run
with wandb.init(entity = entity, project = project) as run:
# Create an artifact object
# The type parameter specifies both the type of the
# artifact object and the collection type
artifact = wandb.Artifact(name = "<name>", type = "<type>")
# Add the file to the artifact object.
# Specify the path to the file on your local machine.
artifact.add_file(local_path = "<local_path_to_artifact>")
# Specify the collection and registry to link the artifact to
REGISTRY_NAME = "<registry_name>"
COLLECTION_NAME = "<collection_name>"
target_path=f"wandb-registry-{REGISTRY_NAME}/{COLLECTION_NAME}"
# Link the artifact to the collection
run.link_artifact(artifact = artifact, target_path = target_path)
Link an artifact version outside the context of a run
When you use wandb.Artifact.link()
, you do not need to initialize a run with wandb.init()
. This means that a run is not created in your W&B project. The artifact version is linked to the collection without being associated with a run.
Copy and paste the code snippet below. Replace values enclosed in <>
with your own:
import wandb
# Create an artifact object
# The type parameter specifies both the type of the
# artifact object and the collection type
artifact = wandb.Artifact(name = "<name>", type = "<type>")
# Add the file to the artifact object.
# Specify the path to the file on your local machine.
artifact.add_file(local_path = "<local_path_to_artifact>")
# Save the artifact
artifact.save()
# Specify the collection and registry to link the artifact to
REGISTRY_NAME = "<registry_name>"
COLLECTION_NAME = "<collection_name>"
target_path=f"wandb-registry-{REGISTRY_NAME}/{COLLECTION_NAME}"
# Link the artifact to the collection
artifact.link(target_path = target_path)
- Navigate to the Registry App.
- Hover your mouse next to the name of the collection you want to link an artifact version to.
- Select the meatball menu icon (three horizontal dots) next to View details.
- From the dropdown, select Link new version.
- From the sidebar that appears, select the name of a team from the Team dropdown.
- From the Project dropdown, select the name of the project that contains your artifact.
- From the Artifact dropdown, select the name of the artifact.
- From the Version dropdown, select the artifact version you want to link to the collection.
- Navigate to your project’s artifact browser on the W&B App at:
https://wandb.ai/<entity>/<project>/artifacts
- Select the Artifacts icon on the left sidebar.
- Click on the artifact version you want to link to your registry.
- Within the Version overview section, click the Link to registry button.
- From the modal that appears on the right of the screen, select an artifact from the Select a register model menu dropdown.
- Click Next step.
- (Optional) Select an alias from the Aliases dropdown.
- Click Link to registry.
Once an artifact is linked, you can view a linked artifact’s metadata, version data, usage, lineage information and more in the Registry App.
View linked artifacts in a registry
View information about linked artifacts such as metadata, lineage, and usage information in the Registry App.
- Navigate to the Registry App.
- 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.
Make note of the Full Name field within the Version tab. The full name of a linked artifact consists of the registry, collection name, and the alias or index of the artifact version.
wandb-registry-{REGISTRY_NAME}/{COLLECTION_NAME}:v{INTEGER}
You need the full name of a linked artifact to access the artifact version programmatically.
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.
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 is team-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 theentity
when you initialize a run, the run uses your default entity which may or may not be your team entity.
import wandb
run = wandb.init(
entity='<team_entity>',
project='<project_name>'
)
-
Log the artifact to the run either with run.log_artifact or by creating an Artifact object and then adding files to it with:
artifact = wandb.Artifact(name="<artifact_name>", type="<type>")
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 Registry app 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 Registry app 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_path
field within.link_artifact()
. - (Optional) Delete the collection.

For example, after completing the steps outlined, you find the code block with the target_path
parameter:
target_path =
"smle-registries-bug-bash/wandb-registry-Golden Datasets/raw_images"
Breaking this down into its components, you can see what you will need to use to create the path to link your artifact programmatically:
ORG_ENTITY_NAME = "smle-registries-bug-bash"
REGISTRY_NAME = "Golden Datasets"
COLLECTION_NAME = "raw_images"
Feedback
Was this page helpful?
Glad to hear it! If you have more to say, please let us know.
Sorry to hear that. Please tell us how we can improve.