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}".

Replace values enclosed in <> with your own:

import wandb

ARTIFACT_NAME = "<ARTIFACT-TO-LINK>"
ARTIFACT_TYPE = "ARTIFACT-TYPE"
ENTITY_NAME = "<TEAM-ARTIFACT-BELONGS-IN>"
PROJECT_NAME = "<PROJECT-ARTIFACT-TO-LINK-BELONGS-IN>"

ORG_ENTITY_NAME = "<YOUR ORG NAME>"
REGISTRY_NAME = "<REGISTRY-TO-LINK-TO>"
COLLECTION_NAME = "<REGISTRY-COLLECTION-TO-LINK-TO>"

run = wandb.init(entity=ENTITY_NAME, project=PROJECT_NAME)
artifact = wandb.Artifact(name=ARTIFACT_NAME, type=ARTIFACT_TYPE)
run.link_artifact(
artifact=artifact,
target_path=f"{ORG_ENTITY_NAME}/wandb-registry-{REGISTRY_NAME}/{COLLECTION_NAME}"
)
run.finish()

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?๐Ÿ‘๐Ÿ‘Ž