> ## Documentation Index
> Fetch the complete documentation index at: https://docs.coreweave.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Registre

> Utilisez W&B Model Registry pour organiser et gérer les versions de vos modèles.

Utilisez W\&B Model Registry pour organiser et gérer les versions de vos modèles.

<h2 id="add-a-description-to-a-collection-in-a-registry">
  Ajouter une description à une collection dans un registre
</h2>

```python theme={"system"}
"""
Add an description to a collection in a registry.
"""
import wandb

# Définir les informations du registre et de la collection
collection_type = "<collection_type>"
registry_name = "<registry_name>"
collection_name = "<collection_name>"

# Construire le chemin complet du registre
registry_path = f"wandb-registry-{registry_name}/{collection_name}"

# Initialiser l’API W&B
api = wandb.Api()

# Récupérer la collection d’artifacts
collection = api.artifact_collection(
  type_name = collection_type, 
  name = registry_path
  )

# Ajouter une description à l’objet collection
collection.description = "<description>"

# Enregistrer la collection mise à jour
collection.save()
```

<h2 id="create-a-new-registry">
  Créer un registre
</h2>

```python theme={"system"}
"""
Create a new registry in W&B. If the registry does not exist, W&B creates it.
"""
import wandb

# Initialiser l’API W&B
api = wandb.Api()

# Créer un nouveau registre
registry = api.create_registry(
    name="<registry_name>",
    visibility="<visibility>",  # par exemple "public" ou "private"
)
```

<h2 id="delete-a-registry">
  Supprimer un registre
</h2>

```python theme={"system"}
"""
Delete a registry from W&B.
"""
import wandb

# Définir les informations du registre et de la collection
registry_name = "<registry_name>"
collection_name = "<collection_name>"

# Construire le chemin complet du registre
registry_path = f"wandb-registry-{registry_name}/{collection_name}"

# Initialiser l’API W&B
api = wandb.Api()

# Récupérer le registre à supprimer
fetched_registry = api.registry("<registry_name>")

# Supprimer le registre
fetched_registry.delete()
```

<h2 id="create-an-artifact-and-link-it-to-a-collection-in-a-registry">
  Créer un artifact et le lier à une collection dans un registre
</h2>

```python theme={"system"}
"""
Create a W&B artifact and link it to a collection in a registry. If the
collection does not exist, W&B creates it.
"""
import wandb

# Créer un objet artifact
artifact = wandb.Artifact(name = "<artifact_name>", type = "<artifact_type>")

# Définir les noms du registre et de la collection
registry_name = "<registry_name>"
collection_name = "<collection_name>"
target_path = f"wandb-registry-{registry_name}/{collection_name}"

# Initialiser un run
with wandb.init(entity = "<entity>", project = "<project>") as run:
  # Lier l’artifact à une collection. Si la collection n’existe pas, W&B la crée.
  run.link_artifact(artifact = artifact, target_path = target_path)
```

<h2 id="retrieve-a-specific-version-of-an-artifact-from-a-registry-collection">
  Récupérer une version spécifique d’un artifact depuis une collection de registre
</h2>

```python theme={"system"}
"""
Retrieve a specific version of an artifact from a registry collection.
"""

import wandb

# Définir le registre, la collection et la version de l’artifact
registry = "<registry_name>"
collection = "<collection_name>"
version = "<version>"

# Construire le nom complet de l’artifact, version incluse
artifact_name = f"wandb-registry-{registry}/{collection}:{version}"

# Initialiser l’API W&B
api = wandb.Api()

# Récupérer l’artifact à partir de la collection du registre et de la version spécifiées
artifact = api.artifact(name = artifact_name)
```

<h2 id="create-a-registry-collection-and-link-an-artifact-to-it">
  Créer une collection de registre et y lier un artifact
</h2>

```python theme={"system"}
"""
Ceates a registry collection and links an artifact to it.
"""
import wandb

# Créer un objet artifact
artifact = wandb.Artifact(name = "<artifact_name>", type = "<artifact_type>")

registry_name = "<registry_name>"
collection_name = "<collection_name>"
registry_path = f"wandb-registry-{registry_name}/{collection_name}"

# Initialiser un run
with wandb.init(entity = "<entity>", project = "<project>") as run:

  # Lier l’artifact à une collection. Si la collection n’existe pas, W&B la crée.
  run.link_artifact(artifact = artifact, target_path = registry_path)
```

<h2 id="add-tags-to-a-collection-in-a-registry">
  Ajouter des tags à une collection dans un registre
</h2>

```python theme={"system"}
"""
Add tags to a collection in a registry.
"""
import wandb

# Définir les informations du registre et de la collection
collection_name = "<collection_name>"
collection_type = "<collection_type>"
registry_name = "<registry_name>"

# Construire le chemin complet dans le registre
registry_path = f"wandb-registry-{registry_name}/{collection_name}"

# Récupérer la collection d’artifacts
collection = wandb.Api().artifact_collection(
  type_name = collection_type, 
  name = registry_path
  )

collection.tags = ["<tag>"]
collection.save()
```

<h2 id="remove-a-tag-from-a-collection-in-a-registry">
  Supprimer un tag d’une collection dans un registre
</h2>

```python theme={"system"}
"""
Remove a tag from a collection in a registry.
"""
import wandb

# Définir les informations du registre et de la collection
collection_name = "<collection_name>"
collection_type = "<collection_type>"
registry_name = "<registry_name>"

# Construire le chemin complet du registre
registry_path = f"wandb-registry-{registry_name}/{collection_name}"

# Récupérer la collection d’artifacts
collection = wandb.Api().artifact_collection(
  type_name = collection_type, 
  name = registry_path
  )

collection.tags.remove("<tag>")
collection.save()
```
