메인 콘텐츠로 건너뛰기
GitHub source

class Api

W&B 서버에 쿼리를 보내는 데 사용됩니다. Examples:
import wandb

wandb.Api()

method Api.__init__

__init__(
    overrides: 'dict[str, Any] | None' = None,
    timeout: 'int | None' = None,
    api_key: 'str | None' = None
) → None
API를 초기화합니다. Args:
  • overrides: https://api.wandb.ai 이외의 W&B 서버를 사용하는 경우 base_url을 설정할 수 있습니다. 또한 entity, project, run에 대한 기본값을 설정할 수 있습니다.
  • timeout: API 요청에 대한 HTTP 타임아웃(초)입니다. 지정하지 않으면 기본 타임아웃이 사용됩니다.
  • api_key: 인증에 사용할 API 키입니다. 제공되지 않으면 현재 환경 또는 설정의 API 키가 사용됩니다. 환경에 구성된 키가 없으면 API 키 입력을 요청하는 프롬프트가 표시됩니다.

property Api.client

클라이언트 오브젝트를 반환합니다. Returns:
  • RetryingClient: 클라이언트 속성 값입니다.

property Api.default_entity

기본 W&B entity를 반환합니다. Returns:
  • str | None: default_entity 속성 값입니다.

property Api.user_agent

W&B 공개 사용자 에이전트를 반환합니다. Returns:
  • str: user_agent 속성 값입니다.

property Api.viewer

viewer 오브젝트를 반환합니다. Raises:
  • ValueError: W&B에서 viewer 데이터를 가져올 수 없는 경우 발생합니다.
  • requests.RequestException: graphql 요청 중 에러가 발생한 경우 발생합니다.
Returns:
  • User: viewer 속성 값입니다.

method Api.artifact

artifact(name: 'str', type: 'str | None' = None)
단일 Artifact를 반환합니다. Args:
  • name: Artifact의 이름입니다. Artifact의 이름은 최소한 Artifact가 로그된 프로젝트 이름, Artifact 이름, 그리고 Artifact의 버전 또는 에일리어스로 구성된 파일 경로와 유사합니다. 선택적으로 Artifact를 로그한 entity를 접두사로 추가하고 슬래시(/)를 붙일 수 있습니다. 이름에 entity가 지정되지 않으면 Run 또는 API 설정의 entity가 사용됩니다.
  • type: 가져올 Artifact의 타입입니다.
Returns: Artifact 오브젝트를 반환합니다. Raises:
  • ValueError: Artifact 이름이 지정되지 않은 경우 발생합니다.
  • ValueError: Artifact 타입이 지정되었으나 가져온 Artifact의 타입과 일치하지 않는 경우 발생합니다.
Examples: 다음 코드 조각에서 “entity”, “project”, “artifact”, “version”, “alias”는 각각 사용자의 W&B entity, Artifact가 속한 프로젝트 이름, Artifact 이름, Artifact 버전 및 에일리어스에 대한 플레이스홀더입니다.
import wandb

# 프로젝트, Artifact 이름, Artifact 에일리어스 지정
wandb.Api().artifact(name="project/artifact:alias")

# 프로젝트, Artifact 이름, 특정 Artifact 버전 지정
wandb.Api().artifact(name="project/artifact:version")

# entity, 프로젝트, Artifact 이름, Artifact 에일리어스 지정
wandb.Api().artifact(name="entity/project/artifact:alias")

# entity, 프로젝트, Artifact 이름, 특정 Artifact 버전 지정
wandb.Api().artifact(name="entity/project/artifact:version")
Note:
이 메소드는 외부 사용 전용입니다. wandb 레포지토리 코드 내에서 api.artifact()를 호출하지 마세요.

method Api.artifact_collection

artifact_collection(type_name: 'str', name: 'str') → ArtifactCollection
타입별로 단일 Artifact 컬렉션을 반환합니다. 반환된 ArtifactCollection 오브젝트를 사용하여 해당 컬렉션 내의 특정 Artifact에 대한 정보 등을 검색할 수 있습니다. Args:
  • type_name: 가져올 Artifact 컬렉션의 타입입니다.
  • name: Artifact 컬렉션 이름입니다. 선택적으로 Artifact를 로그한 entity를 접두사로 추가하고 슬래시(/)를 붙일 수 있습니다.
Returns: ArtifactCollection 오브젝트를 반환합니다. Examples: 다음 코드 조각에서 “type”, “entity”, “project”, “artifact_name”은 각각 컬렉션 타입, W&B entity, Artifact가 속한 프로젝트 이름, Artifact 이름에 대한 플레이스홀더입니다.
import wandb

collections = wandb.Api().artifact_collection(
    type_name="type", name="entity/project/artifact_name"
)

# 컬렉션의 첫 번째 Artifact 가져오기
artifact_example = collections.artifacts()[0]

# 지정된 루트 디렉토리에 Artifact 내용 다운로드
artifact_example.download()

method Api.artifact_collection_exists

artifact_collection_exists(name: 'str', type: 'str') → bool
지정된 프로젝트 및 entity 내에 Artifact 컬렉션이 존재하는지 여부를 확인합니다. Args:
  • name: Artifact 컬렉션 이름입니다. 선택적으로 Artifact를 로그한 entity를 접두사로 추가하고 슬래시(/)를 붙일 수 있습니다. entity나 프로젝트가 지정되지 않은 경우, 오버라이드 파라미터가 있다면 거기서 유추합니다. 그렇지 않으면 entity는 사용자 설정에서 가져오고 프로젝트는 기본값인 “uncategorized”로 설정됩니다.
  • type: Artifact 컬렉션의 타입입니다.
Returns: Artifact 컬렉션이 존재하면 True, 그렇지 않으면 False를 반환합니다. Examples: 다음 코드 조각에서 “type”과 “collection_name”은 각각 Artifact 컬렉션의 타입과 컬렉션 이름을 나타냅니다.
import wandb

wandb.Api.artifact_collection_exists(type="type", name="collection_name")

method Api.artifact_collections

artifact_collections(
    project_name: 'str',
    type_name: 'str',
    per_page: 'int' = 50
) → ArtifactCollections
일치하는 Artifact 컬렉션들의 모음을 반환합니다. Args:
  • project_name: 필터링할 프로젝트 이름입니다.
  • type_name: 필터링할 Artifact 타입 이름입니다.
  • per_page: 쿼리 페이지네이션을 위한 페이지 크기를 설정합니다. 일반적으로 이를 변경할 이유는 없습니다.
Returns: 반복 가능한 ArtifactCollections 오브젝트를 반환합니다.

method Api.artifact_exists

artifact_exists(name: 'str', type: 'str | None' = None) → bool
지정된 프로젝트 및 entity 내에 Artifact 버전이 존재하는지 여부를 확인합니다. Args:
  • name: Artifact 이름입니다. Artifact의 entity와 프로젝트를 접두사로 추가하세요. 콜론(:)과 함께 Artifact의 버전이나 에일리어스를 추가합니다. entity나 프로젝트가 지정되지 않은 경우, W&B는 오버라이드 파라미터가 채워져 있다면 이를 사용합니다. 그렇지 않으면 entity는 사용자 설정에서 가져오고 프로젝트는 “Uncategorized”로 설정됩니다.
  • type: Artifact의 타입입니다.
Returns: Artifact 버전이 존재하면 True, 그렇지 않으면 False를 반환합니다. Examples: 다음 코드 조각에서 “entity”, “project”, “artifact”, “version”, “alias”는 각각 W&B entity, 프로젝트 이름, Artifact 이름, Artifact 버전에 대한 플레이스홀더입니다.
import wandb

wandb.Api().artifact_exists("entity/project/artifact:version")
wandb.Api().artifact_exists("entity/project/artifact:alias")

method Api.artifact_type

artifact_type(type_name: 'str', project: 'str | None' = None) → ArtifactType
일치하는 ArtifactType을 반환합니다. Args:
  • type_name: 가져올 Artifact 타입 이름입니다.
  • project: 주어진 경우, 필터링할 프로젝트 이름 또는 경로입니다.
Returns: ArtifactType 오브젝트를 반환합니다.

method Api.artifact_types

artifact_types(project: 'str | None' = None) → ArtifactTypes
일치하는 Artifact 타입들의 모음을 반환합니다. Args:
  • project: 필터링할 프로젝트 이름 또는 경로입니다.
Returns: 반복 가능한 ArtifactTypes 오브젝트를 반환합니다.

method Api.artifact_versions

artifact_versions(type_name, name, per_page=50)
Deprecated 되었습니다. 대신 Api.artifacts(type_name, name) 메소드를 사용하세요.

method Api.artifacts

artifacts(
    type_name: 'str',
    name: 'str',
    per_page: 'int' = 50,
    tags: 'list[str] | None' = None
) → Artifacts
Artifacts 컬렉션을 반환합니다. Args: type_name: 가져올 Artifact의 타입입니다. name: Artifact 컬렉션 이름입니다. 선택적으로 Artifact를 로그한 entity를 접두사로 추가하고 슬래시(/)를 붙일 수 있습니다. per_page: 쿼리 페이지네이션을 위한 페이지 크기를 설정합니다. 일반적으로 이를 변경할 이유는 없습니다. tags: 이 태그들을 모두 포함하는 Artifact만 반환합니다. Returns: 반복 가능한 Artifacts 오브젝트를 반환합니다. Examples: 다음 코드 조각에서 “type”, “entity”, “project”, “artifact_name”은 각각 Artifact 타입, W&B entity, Artifact가 로그된 프로젝트 이름, Artifact 이름에 대한 플레이스홀더입니다.
import wandb

wandb.Api().artifacts(type_name="type", name="entity/project/artifact_name")

method Api.automation

automation(name: 'str', entity: 'str | None' = None) → Automation
파라미터와 일치하는 유일한 Automation을 반환합니다. Args:
  • name: 가져올 Automation의 이름입니다.
  • entity: Automation을 가져올 entity입니다.
Raises:
  • ValueError: 검색 기준과 일치하는 Automation이 없거나 여러 개인 경우 발생합니다.
Examples: 이름이 “my-automation”인 기존 Automation 가져오기:
import wandb

api = wandb.Api()
automation = api.automation(name="my-automation")
“my-team” entity에서 “other-automation”이라는 이름의 기존 Automation 가져오기:
automation = api.automation(name="other-automation", entity="my-team")

method Api.automations

automations(
    entity: 'str | None' = None,
    name: 'str | None' = None,
    per_page: 'int' = 50
) → Iterator[Automation]
주어진 파라미터와 일치하는 모든 Automation에 대한 iterator를 반환합니다. 파라미터가 제공되지 않으면 반환된 iterator에는 사용자가 엑세스할 수 있는 모든 Automation이 포함됩니다. Args:
  • entity: Automation을 가져올 entity입니다.
  • name: 가져올 Automation의 이름입니다.
  • per_page: 페이지당 가져올 Automation 수입니다. 기본값은 50입니다. 일반적으로 이를 변경할 이유는 없습니다.
Returns: Automation 리스트를 반환합니다. Examples: “my-team” entity에 대한 모든 기존 Automation 가져오기:
import wandb

api = wandb.Api()
automations = api.automations(entity="my-team")

method Api.create_automation

create_automation(
    obj: 'NewAutomation',
    fetch_existing: 'bool' = False,
    **kwargs: 'Unpack[WriteAutomationsKwargs]'
) → Automation
새로운 Automation을 생성합니다. Args: obj: 생성할 Automation입니다. fetch_existing: True인 경우, 충돌하는 Automation이 이미 존재하면 에러를 발생시키는 대신 기존 Automation을 가져오려고 시도합니다. **kwargs: 생성하기 전에 Automation에 할당할 추가 값들입니다. 제공된 경우 Automation에 이미 설정되어 있을 수 있는 값을 덮어씁니다:
  • name: Automation 이름.
  • description: Automation 설명.
  • enabled: Automation 활성화 여부.
  • scope: Automation 범위.
  • event: Automation을 트리거하는 이벤트.
  • action: Automation에 의해 트리거되는 액션.
Returns: 저장된 Automation을 반환합니다. Examples: 특정 프로젝트 내의 Run이 커스텀 임계값을 초과하는 메트릭을 로그할 때 Slack 알림을 보내는 “my-automation”이라는 새 Automation을 생성합니다:
import wandb
from wandb.automations import OnRunMetric, RunEvent, SendNotification

api = wandb.Api()

project = api.project("my-project", entity="my-team")

# 팀의 첫 번째 Slack 인테그레이션 사용
slack_hook = next(api.slack_integrations(entity="my-team"))

event = OnRunMetric(
     scope=project,
     filter=RunEvent.metric("custom-metric") > 10,
)
action = SendNotification.from_integration(slack_hook)

automation = api.create_automation(
     event >> action,
     name="my-automation",
     description="Send a Slack message whenever 'custom-metric' exceeds 10.",
)

method Api.create_custom_chart

create_custom_chart(
    entity: 'str',
    name: 'str',
    display_name: 'str',
    spec_type: "Literal['vega2']",
    access: "Literal['private', 'public']",
    spec: 'str | dict'
) → str
커스텀 차트 프리셋을 생성하고 해당 ID를 반환합니다. Args:
  • entity: 차트를 소유한 entity(사용자 또는 팀)
  • name: 차트 프리셋의 유니크한 식별자
  • display_name: UI에 표시되는 읽기 쉬운 이름
  • spec_type: 사양 타입. Vega-Lite v2 사양의 경우 “vega2”여야 합니다.
  • access: 차트 엑세스 레벨:
    • “private”: 생성한 entity만 차트에 엑세스 가능
    • “public”: 공개적으로 엑세스 가능
  • spec: 사전 또는 JSON 문자열 형태의 Vega/Vega-Lite 사양
Returns: 생성된 차트 프리셋의 ID를 “entity/name” 형식으로 반환합니다. Raises:
  • wandb.Error: 차트 생성 실패 시 발생합니다.
  • UnsupportedError: 서버가 커스텀 차트를 지원하지 않을 때 발생합니다.
Example:
   import wandb

   api = wandb.Api()

   # 간단한 바 차트 사양 정의
   vega_spec = {
        "$schema": "https://vega.github.io/schema/vega-lite/v6.json",
        "mark": "bar",
        "data": {"name": "wandb"},
        "encoding": {
            "x": {"field": "${field:x}", "type": "ordinal"},
            "y": {"field": "${field:y}", "type": "quantitative"},
        },
   }

   # 커스텀 차트 생성
   chart_id = api.create_custom_chart(
        entity="my-team",
        name="my-bar-chart",
        display_name="My Custom Bar Chart",
        spec_type="vega2",
        access="private",
        spec=vega_spec,
   )

   # wandb.plot_table()과 함께 사용
   chart = wandb.plot_table(
        vega_spec_name=chart_id,
        data_table=my_table,
        fields={"x": "category", "y": "value"},
   )

method Api.create_project

create_project(name: 'str', entity: 'str') → None
새로운 Projects를 생성합니다. Args:
  • name: 새 프로젝트 이름.
  • entity: 새 프로젝트의 entity.

method Api.create_registry

create_registry(
    name: 'str',
    visibility: "Literal['organization', 'restricted']",
    organization: 'str | None' = None,
    description: 'str | None' = None,
    artifact_types: 'list[str] | None' = None
) → Registry
새로운 레지스트리를 생성합니다. Args:
  • name: 레지스트리 이름. 이름은 조직 내에서 유일해야 합니다.
  • visibility: 레지스트리의 가시성.
  • organization: 조직의 모든 사용자가 이 레지스트리를 볼 수 있습니다. 나중에 UI 설정에서 역할을 편집할 수 있습니다.
  • restricted: UI를 통해 초대된 멤버만 이 레지스트리에 엑세스할 수 있습니다. 공개 공유는 비활성화됩니다.
  • organization: 레지스트리의 조직. 설정에 조직이 지정되지 않은 경우, 해당 entity가 하나의 조직에만 속해 있다면 entity에서 조직 정보를 가져옵니다.
  • description: 레지스트리에 대한 설명.
  • artifact_types: 레지스트리에서 허용하는 Artifact 타입들입니다. 타입은 128자를 초과할 수 없으며 / 또는 : 문자를 포함할 수 없습니다. 지정하지 않으면 모든 타입이 허용됩니다. 레지스트리에 추가된 허용 타입은 나중에 삭제할 수 없습니다.
Returns: 레지스트리 오브젝트를 반환합니다. Examples:
import wandb

api = wandb.Api()
registry = api.create_registry(
   name="my-registry",
   visibility="restricted",
   organization="my-org",
   description="This is a test registry",
   artifact_types=["model"],
)

method Api.create_run

create_run(
    run_id: 'str | None' = None,
    project: 'str | None' = None,
    entity: 'str | None' = None
) → public.Run
새로운 Runs를 생성합니다. Args:
  • run_id: Run에 할당할 ID입니다. 지정하지 않으면 W&B가 랜덤 ID를 생성합니다.
  • project: Run을 로그할 프로젝트입니다. 지정하지 않으면 “Uncategorized”라는 프로젝트에 로그됩니다.
  • entity: 프로젝트를 소유한 entity입니다. 지정하지 않으면 기본 entity에 로그됩니다.
Returns: 새로 생성된 Run을 반환합니다.

method Api.create_run_queue

create_run_queue(
    name: 'str',
    type: 'public.RunQueueResourceType',
    entity: 'str | None' = None,
    prioritization_mode: 'public.RunQueuePrioritizationMode | None' = None,
    config: 'dict | None' = None,
    template_variables: 'dict | None' = None
) → public.RunQueue
W&B Launch에 새로운 Run 대기열을 생성합니다. Args:
  • name: 생성할 대기열 이름
  • type: 대기열에 사용할 리소스 타입. “local-container”, “local-process”, “kubernetes”, “sagemaker”, 또는 “gcp-vertex” 중 하나입니다.
  • entity: 대기열을 생성할 entity 이름. None인 경우 구성된 또는 기본 entity를 사용합니다.
  • prioritization_mode: 사용할 우선순위 지정 버전. “V0” 또는 None.
  • config: 대기열에 사용할 기본 리소스 설정입니다. 템플릿 변수를 지정하려면 핸들바(예: {{var}})를 사용하세요.
  • template_variables: 설정과 함께 사용할 템플릿 변수 스키마의 사전입니다.
Returns: 새로 생성된 RunQueue를 반환합니다. Raises: 파라미터가 유효하지 않으면 ValueError가 발생하고, wandb API 에러 시 wandb.Error가 발생합니다.

method Api.create_team

create_team(team: 'str', admin_username: 'str | None' = None) → Team
새로운 Teams를 생성합니다. Args:
  • team: 팀 이름
  • admin_username: 팀 관리자의 사용자 이름입니다. 기본값은 현재 사용자입니다.
Returns: Team 오브젝트를 반환합니다.

method Api.create_user

create_user(email: 'str', admin: 'bool | None' = False) → User
새로운 Users를 생성합니다. Args:
  • email: 사용자의 이메일 주소.
  • admin: 사용자를 글로벌 인스턴스 관리자로 설정합니다.
Returns: User 오브젝트를 반환합니다.

method Api.delete_automation

delete_automation(obj: 'Automation | str') → Literal[True]
Automation을 삭제합니다. Args:
  • obj: 삭제할 Automation 또는 그 ID.
Returns: Automation이 성공적으로 삭제되면 True를 반환합니다.

method Api.flush

flush()
로컬 캐시를 비웁니다. api 오브젝트는 Run의 로컬 캐시를 유지하므로, 스크립트 실행 중에 Run의 상태가 변경될 수 있는 경우 api.flush()를 호출하여 로컬 캐시를 지우고 Run과 관련된 최신 값을 가져와야 합니다.

method Api.from_path

from_path(path: 'str')
경로로부터 Run, Sweep, Project 또는 Report를 반환합니다. Args:
  • path: Project, Run, Sweep 또는 Report에 대한 경로
Returns: Project, Run, Sweep, 또는 BetaReport 인스턴스를 반환합니다. Raises: 경로가 유효하지 않거나 오브젝트가 존재하지 않으면 wandb.Error를 발생시킵니다. Examples: 다음 코드 조각에서 “project”, “team”, “run_id”, “sweep_id”, “report_name”은 각각 프로젝트, 팀, Run ID, Sweep ID, 특정 리포트 이름에 대한 플레이스홀더입니다.
import wandb

api = wandb.Api()

project = api.from_path("project")
team_project = api.from_path("team/project")
run = api.from_path("team/project/runs/run_id")
sweep = api.from_path("team/project/sweeps/sweep_id")
report = api.from_path("team/project/reports/report_name")

method Api.integrations

integrations(
    entity: 'str | None' = None,
    per_page: 'int' = 50
) → Iterator[Integration]
entity에 대한 모든 인테그레이션의 iterator를 반환합니다. Args:
  • entity: 인테그레이션을 가져올 entity(예: 팀 이름). 제공되지 않으면 사용자의 기본 entity가 사용됩니다.
  • per_page: 페이지당 가져올 인테그레이션 수입니다. 기본값은 50입니다. 일반적으로 이를 변경할 이유는 없습니다.
Yields:
  • Iterator[SlackIntegration | WebhookIntegration]: 지원되는 모든 인테그레이션의 iterator입니다.

method Api.job

job(name: 'str | None', path: 'str | None' = None) → public.Job
Job 오브젝트를 반환합니다. Args:
  • name: Job의 이름.
  • path: Job Artifact를 다운로드할 루트 경로.
Returns: Job 오브젝트를 반환합니다.

method Api.list_jobs

list_jobs(entity: 'str', project: 'str') → list[dict[str, Any]]
주어진 entity와 프로젝트에 대한 Job 리스트(있는 경우)를 반환합니다. Args:
  • entity: Job이 나열될 entity.
  • project: Job이 나열될 프로젝트.
Returns: 일치하는 Job 리스트를 반환합니다.

method Api.project

project(name: 'str', entity: 'str | None' = None) → public.Project
주어진 이름(및 지정된 경우 entity)을 가진 Project를 반환합니다. Args:
  • name: 프로젝트 이름.
  • entity: 요청된 entity 이름. None인 경우 Api에 전달된 기본 entity를 사용합니다. 기본 entity가 없으면 ValueError를 발생시킵니다.
Returns: Project 오브젝트를 반환합니다.

method Api.projects

projects(entity: 'str | None' = None, per_page: 'int' = 200) → public.Projects
주어진 entity에 대한 프로젝트들을 가져옵니다. Args:
  • entity: 요청된 entity 이름. None인 경우 Api에 전달된 기본 entity를 사용합니다. 기본 entity가 없으면 ValueError를 발생시킵니다.
  • per_page: 쿼리 페이지네이션을 위한 페이지 크기를 설정합니다. 일반적으로 이를 변경할 이유는 없습니다.
Returns: Project 오브젝트들의 반복 가능한 컬렉션인 Projects 오브젝트를 반환합니다.

method Api.queued_run

queued_run(
    entity: 'str',
    project: 'str',
    queue_name: 'str',
    run_queue_item_id: 'str',
    project_queue=None,
    priority=None
)
경로를 기반으로 단일 대기 중인 Run을 반환합니다. entity/project/queue_id/run_queue_item_id 형식의 경로를 파싱합니다.

method Api.registries

registries(
    organization: 'str | None' = None,
    filter: 'dict[str, Any] | None' = None,
    per_page: 'int' = 100
) → Registries
Registry 오브젝트의 lazy iterator를 반환합니다. iterator를 사용하여 조직의 레지스트리 전체에서 레지스트리, 컬렉션 또는 Artifact 버전을 검색하고 필터링합니다. Args:
  • organization: (str, 선택사항) 가져올 레지스트리의 조직. 지정하지 않으면 사용자 설정에 지정된 조직을 사용합니다.
  • filter: (dict, 선택사항) lazy 레지스트리 iterator의 각 오브젝트에 적용할 MongoDB 스타일 필터입니다. 레지스트리 필터링에 사용 가능한 필드는 name, description, created_at, updated_at입니다. 컬렉션 필터링에 사용 가능한 필드는 name, tag, description, created_at, updated_at입니다. 버전 필터링에 사용 가능한 필드는 tag, alias, created_at, updated_at, metadata입니다.
  • per_page: 쿼리 페이지네이션을 위한 페이지 크기를 설정합니다.
Returns: Registry 오브젝트의 lazy iterator를 반환합니다. Examples: 이름에 “model”이 포함된 모든 레지스트리 찾기
import wandb

api = wandb.Api()  # entity가 여러 조직에 속해 있다면 조직을 지정하세요
api.registries(filter={"name": {"$regex": "model"}})
이름이 “my_collection”이고 태그가 “my_tag”인 레지스트리 내의 모든 컬렉션 찾기
api.registries().collections(filter={"name": "my_collection", "tag": "my_tag"})
컬렉션 이름에 “my_collection”이 포함되어 있고 에일리어스가 “best”인 버전이 있는 모든 Artifact 버전 찾기
api.registries().collections(
    filter={"name": {"$regex": "my_collection"}}
).versions(filter={"alias": "best"})
“model”을 포함하고 “prod” 태그 또는 “best” 에일리어스를 가진 모든 Artifact 버전 찾기
api.registries(filter={"name": {"$regex": "model"}}).versions(
    filter={"$or": [{"tag": "prod"}, {"alias": "best"}]}
)

method Api.registry

registry(name: 'str', organization: 'str | None' = None) → Registry
레지스트리 이름이 주어지면 레지스트리를 반환합니다. Args:
  • name: 레지스트리 이름. wandb-registry- 접두사는 제외합니다.
  • organization: 레지스트리의 조직. 설정에 조직이 지정되지 않은 경우, 해당 entity가 하나의 조직에만 속해 있다면 entity에서 조직 정보를 가져옵니다.
Returns: 레지스트리 오브젝트를 반환합니다. Examples: 레지스트리 가져오기 및 업데이트
import wandb

api = wandb.Api()
registry = api.registry(name="my-registry", organization="my-org")
registry.description = "This is an updated description"
registry.save()

method Api.reports

reports(
    path: 'str' = '',
    name: 'str | None' = None,
    per_page: 'int' = 50
) → public.Reports
주어진 프로젝트 경로에 대한 Reports를 가져옵니다. 참고: wandb.Api.reports() API는 베타 버전이며 향후 릴리스에서 변경될 수 있습니다. Args:
  • path: 리포트가 있는 프로젝트의 경로. 프로젝트를 생성한 entity를 접두사로 추가하고 슬래시(/)를 붙여 지정합니다.
  • name: 요청된 리포트의 이름.
  • per_page: 쿼리 페이지네이션을 위한 페이지 크기를 설정합니다. 일반적으로 이를 변경할 이유는 없습니다.
Returns: BetaReport 오브젝트들의 반복 가능한 컬렉션인 Reports 오브젝트를 반환합니다. Examples:
import wandb

wandb.Api.reports("entity/project")

method Api.run

run(path='')
entity/project/run_id 형식의 경로를 파싱하여 단일 Run을 반환합니다. Args:
  • path: entity/project/run_id 형식의 Run 경로. api.entity가 설정되어 있으면 project/run_id 형식일 수 있고, api.project가 설정되어 있으면 그냥 run_id일 수 있습니다.
Returns: Run 오브젝트를 반환합니다.

method Api.run_queue

run_queue(entity: 'str', name: 'str')
entity에 대해 이름이 지정된 RunQueue를 반환합니다. Run 대기열 생성 방법에 대한 자세한 내용은 Api.create_run_queue를 참조하세요.

method Api.runs

runs(
    path: 'str | None' = None,
    filters: 'dict[str, Any] | None' = None,
    order: 'str' = '+created_at',
    per_page: 'int' = 50,
    include_sweeps: 'bool' = True,
    lazy: 'bool' = True
)
Run 오브젝트를 지연 반복(lazily iterate)하는 Runs 오브젝트를 반환합니다. 필터링 가능한 필드는 다음과 같습니다:
  • createdAt: Run이 생성된 타임스탬프 (ISO 8601 형식, 예: “2023-01-01T12:00:00Z”).
  • displayName: Run의 사람이 읽을 수 있는 표시 이름 (예: “eager-fox-1”).
  • duration: Run의 총 실행 시간(초).
  • group: 관련 Run을 함께 구성하는 데 사용되는 그룹 이름.
  • host: Run이 실행된 호스트 이름.
  • jobType: 작업 타입 또는 Run의 목적.
  • name: Run의 유니크한 식별자 (예: “a1b2cdef”).
  • state: Run의 현재 상태.
  • tags: Run과 관련된 태그.
  • username: Run을 시작한 사용자의 이름.
또한 Run config의 항목이나 summary metrics를 기준으로 필터링할 수 있습니다. 예를 들어 config.experiment_name, summary_metrics.loss 등입니다. 더 복잡한 필터링을 위해서는 MongoDB 쿼리 연산자를 사용할 수 있습니다. 자세한 내용은 https://docs.mongodb.com/manual/reference/operator/query 를 참조하세요. 다음 연산자들이 지원됩니다:
  • $and
  • $or
  • $nor
  • $eq
  • $ne
  • $gt
  • $gte
  • $lt
  • $lte
  • $in
  • $nin
  • $exists
  • $regex
Args:
  • path: (str) 프로젝트 경로, “entity/project” 형식이어야 합니다.
  • filters: (dict) MongoDB 쿼리 언어를 사용한 특정 Run에 대한 쿼리입니다. config.key, summary_metrics.key, state, entity, createdAt 등과 같은 Run 속성으로 필터링할 수 있습니다.
  • 예를 들어: {"config.experiment_name": "foo"}는 experiment name이 “foo”로 설정된 config 항목을 가진 Run을 찾습니다.
  • order: (str) 정렬 기준은 created_at, heartbeat_at, config.*.value, 또는 summary_metrics.*가 될 수 있습니다. 앞에 +를 붙이면 오름차순(기본값), -를 붙이면 내림차순입니다. 기본 정렬은 run.created_at 기준 오래된 순서입니다.
  • per_page: (int) 쿼리 페이지네이션을 위한 페이지 크기를 설정합니다.
  • include_sweeps: (bool) 결과에 Sweep Run을 포함할지 여부입니다.
  • lazy: (bool) 더 빠른 성능을 위해 지연 로딩을 사용할지 여부입니다. True(기본값)인 경우 처음에 필수적인 Run 메타데이터만 로드됩니다. config, summaryMetrics, systemMetrics와 같은 무거운 필드는 엑세스할 때 온디맨드로 로드됩니다. 모든 데이터를 미리 가져오려면 False로 설정하세요.
Returns: Run 오브젝트들의 반복 가능한 컬렉션인 Runs 오브젝트를 반환합니다. Examples:
import wandb
from wandb.apis.public import Api

# 프로젝트에서 config.experiment_name이 "foo"로 설정된 Run 찾기
Api.runs(path="my_entity/project", filters={"config.experiment_name": "foo"})
# 프로젝트에서 config.experiment_name이 "foo" 또는 "bar"로 설정된 Run 찾기
Api.runs(
    path="my_entity/project",
    filters={
         "$or": [
             {"config.experiment_name": "foo"},
             {"config.experiment_name": "bar"},
         ]
    },
)
# 프로젝트에서 config.experiment_name이 정규식과 일치하는 Run 찾기
# (앵커는 지원되지 않습니다)
Api.runs(
    path="my_entity/project",
    filters={"config.experiment_name": {"$regex": "b.*"}},
)
# 프로젝트에서 Run 이름이 정규식과 일치하는 Run 찾기
# (앵커는 지원되지 않습니다)
Api.runs(
    path="my_entity/project", filters={"display_name": {"$regex": "^foo.*"}}
)
# 프로젝트에서 loss 오름차순으로 정렬된 Run 찾기
Api.runs(path="my_entity/project", order="+summary_metrics.loss")

method Api.slack_integrations

slack_integrations(
    entity: 'str | None' = None,
    per_page: 'int' = 50
) → Iterator[SlackIntegration]
entity에 대한 Slack 인테그레이션의 iterator를 반환합니다. Args:
  • entity: 인테그레이션을 가져올 entity(예: 팀 이름). 제공되지 않으면 사용자의 기본 entity가 사용됩니다.
  • per_page: 페이지당 가져올 인테그레이션 수입니다. 기본값은 50입니다. 일반적으로 이를 변경할 이유는 없습니다.
Yields:
  • Iterator[SlackIntegration]: Slack 인테그레이션의 iterator입니다.
Examples: “my-team” 팀에 등록된 모든 Slack 인테그레이션 가져오기:
import wandb

api = wandb.Api()
slack_integrations = api.slack_integrations(entity="my-team")
채널 이름이 “team-alerts-”로 시작하는 Slack 인테그레이션만 찾기:
slack_integrations = api.slack_integrations(entity="my-team")
team_alert_integrations = [
    ig
    for ig in slack_integrations
    if ig.channel_name.startswith("team-alerts-")
]

method Api.sweep

sweep(path='')
entity/project/sweep_id 형식의 경로를 파싱하여 Sweep을 반환합니다. Args:
  • path: entity/project/sweep_id 형식의 Sweep 경로. api.entity가 설정되어 있으면 project/sweep_id 형식일 수 있고, api.project가 설정되어 있으면 그냥 sweep_id일 수 있습니다.
Returns: Sweep 오브젝트를 반환합니다.

method Api.sync_tensorboard

sync_tensorboard(root_dir, run_id=None, project=None, entity=None)
tfevent 파일을 포함하는 로컬 디렉토리를 wandb에 동기화합니다.

method Api.team

team(team: 'str') → Team
주어진 이름을 가진 일치하는 Team을 반환합니다. Args:
  • team: 팀 이름.
Returns: Team 오브젝트를 반환합니다.

method Api.update_automation

update_automation(
    obj: 'Automation',
    create_missing: 'bool' = False,
    **kwargs: 'Unpack[WriteAutomationsKwargs]'
) → Automation
기존 Automation을 업데이트합니다. Args:
  • obj: 업데이트할 Automation. 반드시 존재하는 Automation이어야 합니다. create_missing (bool): True인 경우, Automation이 존재하지 않으면 새로 생성합니다. **kwargs: 업데이트 전에 Automation에 할당할 추가 값들입니다. 제공된 경우 Automation에 이미 설정되어 있을 수 있는 값을 덮어씁니다:
    • name: Automation 이름.
    • description: Automation 설명.
    • enabled: Automation 활성화 여부.
    • scope: Automation 범위.
    • event: Automation을 트리거하는 이벤트.
    • action: Automation에 의해 트리거되는 액션.
Returns: 업데이트된 Automation을 반환합니다. Examples: 기존 Automation(“my-automation”)을 비활성화하고 설명을 편집합니다:
import wandb

api = wandb.Api()

automation = api.automation(name="my-automation")
automation.enabled = False
automation.description = "Kept for reference, but no longer used."

updated_automation = api.update_automation(automation)
또는
import wandb

api = wandb.Api()

automation = api.automation(name="my-automation")

updated_automation = api.update_automation(
    automation,
    enabled=False,
    description="Kept for reference, but no longer used.",
)

method Api.upsert_run_queue

upsert_run_queue(
    name: 'str',
    resource_config: 'dict',
    resource_type: 'public.RunQueueResourceType',
    entity: 'str | None' = None,
    template_variables: 'dict | None' = None,
    external_links: 'dict | None' = None,
    prioritization_mode: 'public.RunQueuePrioritizationMode | None' = None
)
W&B Launch에서 Run 대기열을 upsert(업데이트 또는 삽입)합니다. Args:
  • name: 생성할 대기열 이름
  • entity: 대기열을 생성할 선택적 entity 이름. None인 경우 구성된 또는 기본 entity를 사용합니다.
  • resource_config: 대기열에 사용할 선택적 기본 리소스 설정입니다. 템플릿 변수를 지정하려면 핸들바(예: {{var}})를 사용하세요.
  • resource_type: 대기열에 사용할 리소스 타입. “local-container”, “local-process”, “kubernetes”, “sagemaker”, 또는 “gcp-vertex” 중 하나입니다.
  • template_variables: 설정과 함께 사용될 템플릿 변수 스키마의 사전입니다.
  • external_links: 대기열과 함께 사용될 외부 링크의 선택적 사전입니다.
  • prioritization_mode: 사용할 선택적 우선순위 지정 버전. “V0” 또는 None.
Returns: upsert된 RunQueue를 반환합니다. Raises: 파라미터가 유효하지 않으면 ValueError가 발생하고, wandb API 에러 시 wandb.Error가 발생합니다.

method Api.user

user(username_or_email: 'str') → User | None
사용자 이름 또는 이메일 주소로부터 사용자를 반환합니다. 이 함수는 로컬 관리자에게만 작동합니다. 자신의 사용자 오브젝트를 가져오려면 api.viewer를 사용하세요. Args:
  • username_or_email: 사용자의 사용자 이름 또는 이메일 주소.
Returns: User 오브젝트를 반환하거나 사용자를 찾지 못하면 None을 반환합니다.

method Api.users

users(username_or_email: 'str') → list[User]
부분적인 사용자 이름 또는 이메일 주소 쿼리로부터 모든 사용자를 반환합니다. 이 함수는 로컬 관리자에게만 작동합니다. 자신의 사용자 오브젝트를 가져오려면 api.viewer를 사용하세요. Args:
  • username_or_email: 찾고자 하는 사용자의 접두사 또는 접미사.
Returns: User 오브젝트 배열을 반환합니다.

method Api.webhook_integrations

webhook_integrations(
    entity: 'str | None' = None,
    per_page: 'int' = 50
) → Iterator[WebhookIntegration]
entity에 대한 웹훅 인테그레이션의 iterator를 반환합니다. Args:
  • entity: 인테그레이션을 가져올 entity(예: 팀 이름). 제공되지 않으면 사용자의 기본 entity가 사용됩니다.
  • per_page: 페이지당 가져올 인테그레이션 수입니다. 기본값은 50입니다. 일반적으로 이를 변경할 이유는 없습니다.
Yields:
  • Iterator[WebhookIntegration]: 웹훅 인테그레이션의 iterator입니다.
Examples: “my-team” 팀에 등록된 모든 웹훅 인테그레이션 가져오기:
import wandb

api = wandb.Api()
webhook_integrations = api.webhook_integrations(entity="my-team")
https://my-fake-url.com”으로 요청을 보내는 웹훅 인테그레이션만 찾기:
webhook_integrations = api.webhook_integrations(entity="my-team")
my_webhooks = [
    ig
    for ig in webhook_integrations
    if ig.url_endpoint.startswith("https://my-fake-url.com")
]