Skip to main content

Create a collection

Create a collection within a registry to organize your artifacts. A collection is a set of linked artifact versions in a registry. Each collection represents a distinct task or use case and serves as a container for a curated selection of artifact versions related to that task.

tip

If you are familiar with W&B Model Registry, you might aware of "registered models". In W&B Registry, registered models are renamed to "collections". The way you create a registered model in the Model Registry is nearly the same for creating a collection in the W&B Registry. The main difference being that a collection does not belong to an entity like registered models.

Collection typesโ€‹

When you create a collection, you must select the type of artifacts that you can link to that collection. Each collection accepts one, and only one, type of artifact. The type of artifact that a collection can have is determined by the accepted types defined for that registry. You can configure the accepted types a registry allows in the registry settings.

Limiting the types of artifacts that can be linked to a collection is to help ensure that artifacts types are not mixed. For example, that model artifacts are not linked to the dataset registry.

tip

You specify the type of an artifact when you create that artifact. Note the type field in wandb.Artifact():

import wandb

# Initialize a run
run = wandb.init(entity="<team_entity>", project="<project>")

# Create an artifact object
artifact = wandb.Artifact(
name="<artifact_name>",
type="<artifact_type>"
)

For example, suppose you create a collection that accepts "dataset" artifacts types. This means that only of artifacts of type "dataset" can be linked to this collection.

Check the types of artifact that a collection acceptsโ€‹

Before you link to a collection, check the artifact type that the collection accepts:

Check the artifact types that a collection accepts on the registry cards on the homepage or within a registry's settings page. For both methods, you must first navigate to your W&B Registry App at https://wandb.ai/registry/.

Within the homepage of the Registry App, you can view the accepted artifact types by scrolling to the registry card you are interested in. The gray horizontal ovals within the registry card lists the artifact types that that registry accepts.

For example, the proceeding image shows multiple registry cards on the Registry App homepage. Within the Model registry card, you can see two artifact types: model and model-new.

To view accepted artifact types within a registry's settings page:

  1. Click on the registry card you want to view the settings for.
  2. Click on the gear icon in the upper right corner.
  3. Scroll to the Accepted artifact types field.

Programmatically create a collectionโ€‹

Programmatically create a collection with the W&B Python SDK. W&B automatically creates a collection with the name you specify in the target path if you try to link an artifact to a collection that does not exist. The target path consists of the entity of the organization, the prefix "wandb-registry-", the name of the registry, and the name of the collection:

f"{org_entity}/wandb-registry-{registry_name}/{collection_name}"

The proceeding code snippet shows how to programmatically create a collection. Ensure to replace other the values enclosed in <> with your own:

import wandb

# Initialize a run
run = wandb.init(entity="<team_entity>", project="<project>")

# Create an artifact object
artifact = wandb.Artifact(name="<artifact_name>", type="<artifact_type>")

org_entity = "<organization_entity>"
registry_name = "<registry_name>"
collection_name = "<collection_name>"
target_path = f"{org_entity}/wandb-registry-{registry_name}/{collection_name}"

# Link the artifact to a collection
run.link_artifact(artifact = artifact, target_path = target_path)

run.finish()

Interactively create a collectionโ€‹

The following steps describe how to create a collection within a registry using the W&B Registry App UI:

  1. Navigate to the Registry App in the W&B App UI.
  2. Select a registry.
  3. Click on the Create collection button in the upper right hand corner.
  4. Provide a name for your collection in the Name field.
  5. Select a type from the Type dropdown. Or, if the registry enables custom artifact types, provide one or more artifact types that this collection accepts.
info

An artifact type can not be removed from a registry once it is added and saved in the registry's settings.

  1. Optionally provide a description of your collection in the Description field.
  2. Optionally add one or more tags in the Tags field.
  3. Click Link version.
  4. From the Project dropdown, select the project where your artifact is stored.
  5. From the Artifact collection dropdown, select your artifact.
  6. From the Version dropdown, select the artifact version you want to link to your collection.
  7. Click on the Create collection button.

Was this page helpful?๐Ÿ‘๐Ÿ‘Ž