Registry 内のコレクションに説明を追加する
"""
Add an description to a collection in a registry.
"""
import wandb
# レジストリとコレクションの詳細を定義します
collection_type = "<collection_type>"
registry_name = "<registry_name>"
collection_name = "<collection_name>"
# 完全な Registry パスを作成します
registry_path = f"wandb-registry-{registry_name}/{collection_name}"
# W&B API を初期化します
api = wandb.Api()
# アーティファクト コレクションを取得します
collection = api.artifact_collection(
type_name = collection_type,
name = registry_path
)
# コレクション オブジェクトに説明のアノテーションを追加します
collection.description = "<description>"
# 更新したコレクションを保存します
collection.save()
新しい Registry を作成する
"""
Create a new registry in W&B. If the registry does not exist, W&B creates it.
"""
import wandb
# W&B API を初期化します
api = wandb.Api()
# 新しいレジストリを作成します
registry = api.create_registry(
name="<registry_name>",
visibility="<visibility>", # 例: "public" または "private"
)
Registry を削除する
"""
Delete a registry from W&B.
"""
import wandb
# レジストリとコレクションの詳細を定義します
registry_name = "<registry_name>"
collection_name = "<collection_name>"
# 完全な Registry パスを構築します
registry_path = f"wandb-registry-{registry_name}/{collection_name}"
# W&B API を初期化します
api = wandb.Api()
# 削除するレジストリを取得します
fetched_registry = api.registry("<registry_name>")
# レジストリを削除します
fetched_registry.delete()
アーティファクトを作成してRegistry内のコレクションにリンクする
"""
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
# アーティファクト オブジェクトを作成します
artifact = wandb.Artifact(name = "<artifact_name>", type = "<artifact_type>")
# レジストリ名とコレクション名を定義します
registry_name = "<registry_name>"
collection_name = "<collection_name>"
target_path = f"wandb-registry-{registry_name}/{collection_name}"
# run を初期化します
with wandb.init(entity = "<entity>", project = "<project>") as run:
# アーティファクトをコレクションにリンクします。コレクションが存在しない場合は、W&B が作成します。
run.link_artifact(artifact = artifact, target_path = target_path)
Registry コレクションからアーティファクトの特定のバージョンを取得する
"""
Retrieve a specific version of an artifact from a registry collection.
"""
import wandb
# レジストリ、コレクション、アーティファクトのバージョンを指定します
registry = "<registry_name>"
collection = "<collection_name>"
version = "<version>"
# バージョンを含む完全なアーティファクト名を作成します
artifact_name = f"wandb-registry-{registry}/{collection}:{version}"
# W&B API を初期化します
api = wandb.Api()
# 指定したレジストリのコレクションとバージョンからアーティファクトを取得します
artifact = api.artifact(name = artifact_name)
Registry のコレクションを作成してアーティファクトをリンクする
"""
Ceates a registry collection and links an artifact to it.
"""
import wandb
# アーティファクトオブジェクトを作成します
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}"
# run を初期化します
with wandb.init(entity = "<entity>", project = "<project>") as run:
# アーティファクトをコレクションにリンクします。コレクションが存在しない場合は、W&B が自動的に作成します。
run.link_artifact(artifact = artifact, target_path = registry_path)
Registry 内のコレクションにタグを追加する
"""
Add tags to a collection in a registry.
"""
import wandb
# Registry とコレクションの情報を定義
collection_name = "<collection_name>"
collection_type = "<collection_type>"
registry_name = "<registry_name>"
# 完全な Registry パスを組み立てる
registry_path = f"wandb-registry-{registry_name}/{collection_name}"
# アーティファクト コレクションを取得
collection = wandb.Api().artifact_collection(
type_name = collection_type,
name = registry_path
)
collection.tags = ["<tag>"]
collection.save()
Registry内のコレクションからタグを削除する
"""
Remove a tag from a collection in a registry.
"""
import wandb
# レジストリとコレクションの詳細を定義します
collection_name = "<collection_name>"
collection_type = "<collection_type>"
registry_name = "<registry_name>"
# 完全な Registry パスを作成します
registry_path = f"wandb-registry-{registry_name}/{collection_name}"
# アーティファクト コレクションを取得します
collection = wandb.Api().artifact_collection(
type_name = collection_type,
name = registry_path
)
collection.tags.remove("<tag>")
collection.save()