레지스트리의 컬렉션에 설명 추가
"""
Add an description to a collection in a registry.
"""
import wandb
# 레지스트리와 컬렉션 세부 정보를 정의합니다
collection_type = "<collection_type>"
registry_name = "<registry_name>"
collection_name = "<collection_name>"
# 전체 레지스트리 경로를 구성합니다
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()
새 레지스트리 만들기
"""
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"
)
레지스트리 삭제
"""
Delete a registry from W&B.
"""
import wandb
# 레지스트리 및 컬렉션 세부 정보 정의
registry_name = "<registry_name>"
collection_name = "<collection_name>"
# 전체 레지스트리 경로 구성
registry_path = f"wandb-registry-{registry_name}/{collection_name}"
# W&B API 초기화
api = wandb.Api()
# 삭제할 레지스트리 가져오기
fetched_registry = api.registry("<registry_name>")
# 레지스트리 삭제
fetched_registry.delete()
아티팩트를 생성하고 레지스트리의 컬렉션에 연결하기
"""
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)
레지스트리 컬렉션에서 아티팩트의 특정 버전 가져오기
"""
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)
레지스트리 컬렉션을 만들고 아티팩트 연결하기
"""
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)
레지스트리의 컬렉션에 태그 추가
"""
Add tags to a collection in a registry.
"""
import wandb
# 레지스트리와 컬렉션 세부 정보를 정의합니다
collection_name = "<collection_name>"
collection_type = "<collection_type>"
registry_name = "<registry_name>"
# 전체 레지스트리 경로를 구성합니다
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()
레지스트리의 컬렉션에서 태그 제거
"""
Remove a tag from a collection in a registry.
"""
import wandb
# 레지스트리 및 컬렉션 세부 정보 정의
collection_name = "<collection_name>"
collection_type = "<collection_type>"
registry_name = "<registry_name>"
# 전체 레지스트리 경로 구성
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()