Skip to main content

Link an artifact version to a registry

Programmatically or interactively link artifact versions to a registry.

info

When you link an artifact to a registry, this "publishes" that artifact to that registry. Any user that has access to that registry can access linked artifact versions when you link an artifact to a collection.

In other words, linking an artifact to a registry collection brings that artifact version from a private, project-level scope, to the shared organization level scope.

Based on your use case, follow the instructions described in the tabs below to link an artifact version.

Use the link_artifact method to programmatically link an artifact to a registry. When you link an artifact, specify the path where you want artifact version to link to for the target_path parameter. The target path takes the form of {ORG_ENTITY_NAME}/wandb-registry-{REGISTRY_NAME}/{COLLECTION_NAME}. Note that this path informs the registry and collection the artifact will be linked to.

Replace values enclosed in <> with your own:

import wandb

ORG_NAME = "<insert-org-name>"
REGISTRY_NAME = "<insert-registry-name>" # Set to "model" to link to the model registry
COLLECTION_TYPE = "model"

with wandb.init(project="link-quickstart") as run:
with open("my_model.txt", "w") as f:
f.write("simulated model file")

logged_artifact = run.log_artifact("./my_model.txt", "artifact-name", type=COLLECTION_TYPE)
run.link_artifact(
artifact=logged_artifact,
target_path=f"{ORG_NAME}/wandb-registry-{REGISTRY_NAME}/Example ML Task"
)

If you want to link an artifact version to the Models registry or the Dataset registry, set the artifact type to "model" or "dataset", respectively.

Linked vs source artifact versions
  • Source version: the artifact version inside a team's project that is logged to a run.
  • Linked version: the artifact version that is published to the registry. This is a pointer to the source artifact, and is the exact same artifact version, just made available in the scope of the registry.
Was this page helpful?๐Ÿ‘๐Ÿ‘Ž