Ajouter une description à une collection dans un registre
"""
Ajouter une description à une collection dans un registre.
"""
import wandb
# Définir les détails 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 annotation de description à l'objet collection
collection.description = "<description>"
# Enregistrer la collection mise à jour
collection.save()
Créer un nouveau registre
"""
Créer un nouveau registre dans W&B. Si le registre n'existe pas, W&B le crée.
"""
import wandb
# Initialiser l'API W&B
api = wandb.Api()
# Créer un nouveau registre
registry = api.create_registry(
name="<registry_name>",
visibility="<visibility>", # ex. : "public" ou "private"
)
Supprimer un registre
"""
Supprimer un registre de W&B.
"""
import wandb
# Définir les détails 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>")
# Suppression d'un registre
fetched_registry.delete()
Créer un artifact et l’attacher à une collection dans un registre
"""
Créer un artifact W&B et le lier à une collection dans un registre. Si la
collection n'existe pas, W&B la crée.
"""
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)
Récupérer une version spécifique d’un artifact dans une collection de registre
"""
Récupérer une version spécifique d'un artifact depuis une collection de registre.
"""
import wandb
# Définir les détails du registre, de la collection et de la version de l'artifact
registry = "<registry_name>"
collection = "<collection_name>"
version = "<version>"
# Construire le nom complet de l'artifact avec la version
artifact_name = f"wandb-registry-{registry}/{collection}:{version}"
# Initialiser l'API W&B
api = wandb.Api()
# Récupérer l'artifact depuis la collection de registre et la version spécifiées
artifact = api.artifact(name = artifact_name)
Créer une collection de registre et y lier un artifact
"""
Crée une collection de registre W&B et lie un artifact à celle-ci.
"""
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)
Ajouter des tags à une collection dans un registre
"""
Ajouter des tags à une collection dans un registre.
"""
import wandb
# Définir les détails 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 = ["<tag>"]
collection.save()
Supprimer un tag d’une collection d’un registre
"""
Supprimer un tag d'une collection dans un registre.
"""
import wandb
# Définir les détails 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()