Link an artifact version to a registry
Programmatically or interactively link artifact versions to a registry.
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.
- Python SDK
- Registry App
- Artifact browser
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.
- 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.
- 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.