Update artifacts
Pass desired values to update the description
, metadata
, and alias
of an artifact. Call the save()
method to update the artifact on the Weights & Biases servers. You can update an artifact during a W&B Run or outside of a Run.
Use the W&B Public API (wandb.Api
) to update an artifact outside of a run. Use the Artifact API (wandb.Artifact
) to update an artifact during a run.
You can not update the alias of artifact that is linked to a model in Model Registry.
- During a Run
- Outside of a Run
The proceeding code example demonstrates how to update the description of an artifact using the wandb.Artifact
API:
import wandb
run = wandb.init(project="<example>", job_type="<job-type>")
artifact = run.use_artifact('<artifact-name>:<alias>')
artifact = wandb.Artifact('')
run.use_artifact(artifact)
artifact.description = '<description>'
artifact.save()
The proceeding code example demonstrates how to update the description of an artifact using the wandb.Api
API:
import wandb
api = wandb.Api()
artifact = api.artifact('entity/project/artifact:alias')
# Update the description
artifact.description = "My new description"
# Selectively update metadata keys
artifact.metadata["oldKey"] = "new value"
# Replace the metadata entirely
artifact.metadata = {"newKey": "new value"}
# Add an alias
artifact.aliases.append('best')
# Remove an alias
artifact.aliases.remove('latest')
# Completely replace the aliases
artifact.aliases = ['replaced']
# Persist all artifact modifications
artifact.save()
For more information, see the Weights and Biases Public Artifact API.