メインコンテンツへスキップ

Documentation Index

Fetch the complete documentation index at: https://wb-21fd5541-john-wbdocs-2044-rename-serverless-products.mintlify.app/llms.txt

Use this file to discover all available pages before exploring further.

class Api

W&Bサーバーへのクエリに使用します。 例:
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 を初期化します。 引数:
  • overrides: 次の場合は base_url を設定できます
  • https: //api.wandb.ai 以外の W&B Server を使用している場合。entityprojectrun` のデフォルト値も設定できます。
  • timeout: API リクエストの HTTP タイムアウト (秒) 。指定しない場合は、デフォルトのタイムアウトが使用されます。
  • api_key: 認証に使用する APIキー。指定しない場合は、現在の環境または設定の APIキーが使用されます。APIキーが指定されておらず、環境にも設定されていない場合は、APIキーの入力を求められます。

プロパティ Api.client

クライアントオブジェクトを返します。 戻り値:
  • RetryingClient: client プロパティの値。

プロパティ Api.default_entity

デフォルトの W&B entity を返します。 戻り値:
  • str | None: default_entity プロパティの値。

プロパティ Api.user_agent

W&B の公開用ユーザーエージェントを返します。 戻り値:
  • str: user_agent プロパティの値。

プロパティ Api.viewer

viewer オブジェクトを返します。 発生する例外:
  • ValueError: W&B から viewer データを取得できない場合。
  • requests.RequestException: GraphQL リクエストの実行中にエラーが発生した場合。
戻り値:
  • User: viewer プロパティの値。

method Api.artifact

artifact(name: 'str', type: 'str | None' = None)
1 つのartifactを返します。 引数:
  • name: artifactの名。artifactの名はファイルパスのような形式で、少なくともartifactがログされたprojectの名、artifactの名、artifactのバージョンまたはaliasで構成されます。必要に応じて、artifactをログしたentityを接頭辞として追加し、その後にスラッシュ (/) を続けます。名にentityが指定されていない場合は、RunまたはAPI設定のentityが使用されます。
  • type: 取得するartifactのタイプ。
戻り値: Artifact オブジェクト。 発生する例外:
  • ValueError: artifactの名が指定されていない場合。
  • ValueError: artifactのタイプが指定されているものの、取得したartifactのタイプと一致しない場合。
例: 次のコードスニペットでは、“entity”、“project”、“artifact”、“version”、“alias” は、それぞれW&Bのentity、artifactが含まれるprojectの名、artifactの名、artifactのバージョン、artifactのaliasを表すプレースホルダーです。
import wandb

# project、artifactの名、artifactのaliasを指定する
wandb.Api().artifact(name="project/artifact:alias")

# project、artifactの名、特定のartifactバージョンを指定する
wandb.Api().artifact(name="project/artifact:version")

# entity、project、artifactの名、artifactのaliasを指定する
wandb.Api().artifact(name="entity/project/artifact:alias")

# entity、project、artifactの名、特定のartifactバージョンを指定する
wandb.Api().artifact(name="entity/project/artifact:version")
注記:
この method は外部からの使用のみを想定しています。wandb repository のコード内で api.artifact() を呼び出さないでください。

method Api.artifact_collection

artifact_collection(type_name: 'str', name: 'str') → ArtifactCollection
タイプを指定して、単一の artifact collection を返します。 返された ArtifactCollection オブジェクトを使用すると、その collection 内の特定の artifact に関する情報などを取得できます。 引数:
  • type_name: 取得する artifact collection のタイプ。
  • name: artifact collection の名前。必要に応じて、artifact をログした entity をプレフィックスとして先頭に付け、その後にスラッシュを続けます。
戻り値: ArtifactCollection オブジェクト。 例: 次のコードスニペットでは、“type”、“entity”、“project”、および “artifact_name” は、それぞれ collection のタイプ、あなたの W&B entity、artifact が含まれている project 名、および artifact の名前を表すプレースホルダーです。
import wandb

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

# collection 内の最初の 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 collectionが存在するかどうか。 引数:
  • name: artifact collectionの名。必要に応じて、artifactをログしたentityを接頭辞として付け、その後にスラッシュを続けます。entityまたはプロジェクトが指定されていない場合は、overrideパラメータがあればそこからcollectionを推定します。そうでない場合、entityはユーザー設定から取得され、プロジェクトのデフォルトは”uncategorized”になります。
  • type: artifact collectionのタイプ。
戻り値: artifact collectionが存在する場合はTrue、存在しない場合はFalse。 例: 次のコードスニペットでは、“type”と”collection_name”はそれぞれartifact collectionのタイプとcollectionの名を指します。
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,
    start: 'str | None' = None
) → ArtifactCollections
条件に一致する artifact collection のコレクションを返します。 引数:
  • project_name: フィルター対象の project 名。
  • type_name: フィルター対象の artifact type 名。
  • per_page: クエリのページネーションにおけるページサイズを設定します。通常は変更する必要はありません。
  • start: 過去のクエリを再開するためのページネーション カーソル。前の paginator の .cursor 属性から取得します。
戻り値: 反復可能な ArtifactCollections オブジェクト。

method Api.artifact_exists

artifact_exists(name: 'str', type: 'str | None' = None) → bool
指定したプロジェクトおよびentity内に、artifactのバージョンが存在するかどうかを返します。 引数:
  • name: artifactの名。先頭にartifactのentityとプロジェクトを付けます。末尾には、artifactのバージョンまたはaliasをコロン区切りで追加します。entityまたはプロジェクトが指定されていない場合、値が設定されていれば W&B は override パラメーターを使用します。そうでない場合、entity はユーザー設定から取得され、プロジェクトは”Uncategorized”に設定されます。
  • type: artifactのタイプ。
戻り値: artifactのバージョンが存在する場合は True、存在しない場合は False。 例: 以下のコードスニペットでは、“entity”、“project”、“artifact”、“version”、および”alias”は、それぞれあなたの W&B entity、artifact が含まれるプロジェクトの名、artifact の名、artifact のバージョン、artifact の alias を表すプレースホルダーです。
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 を返します。 引数:
  • type_name: 取得する artifact タイプの名前。
  • project: 指定した場合、絞り込み対象のプロジェクト名またはパス。
戻り値: ArtifactType オブジェクト。

method Api.artifact_types

artifact_types(
    project: 'str | None' = None,
    start: 'str | None' = None
) → ArtifactTypes
一致する artifact type のコレクションを返します。 引数:
  • project: フィルター対象の project 名またはパス。
  • start: 前回のクエリを再開するためのページネーション カーソル。以前の paginator の .cursor 属性から取得します。
戻り値: 反復可能な ArtifactTypes オブジェクト。

method Api.artifact_versions

artifact_versions(type_name, name, per_page=50)
非推奨です。代わりに Api.artifacts(type_name, name) method を使用してください。

method Api.artifacts

artifacts(
    type_name: 'str',
    name: 'str',
    per_page: 'int' = 50,
    tags: 'list[str] | None' = None,
    start: 'str | None' = None
) → Artifacts
Artifacts コレクションを返します。 引数:
  • type_name: 取得する artifact のタイプ。
  • name: artifact のコレクション名。必要に応じて、artifact をログした entity をプレフィックスとして付け、その後にスラッシュを追加します。
  • per_page: クエリのページネーションにおけるページサイズを設定します。通常は、これを変更する必要はありません。
  • tags: これらのタグをすべて持つ artifact のみを返します。
  • start: 過去のクエリを再開するためのページネーションカーソル。以前の paginator の .cursor 属性から取得します。
戻り値: 反復可能な Artifacts オブジェクト。 例: 以下のコードスニペットでは、“type”、“entity”、“project”、および “artifact_name” は、それぞれ artifact のタイプ、W&B entity、artifact がログされた project の名、および artifact の名を表すプレースホルダーです。
import wandb

wandb.Api().artifacts(type_name="type", name="entity/project/artifact_name")
paginator.cursor を保存し、それを start= に渡すと、イテレーションを一時停止し、後で同じ位置から再開できます:
from itertools import islice

import wandb

api = wandb.Api()

# 最初のページの結果を取得し、カーソルを保存します。
page_size = 10
artifacts = api.artifacts(
    type_name="type",
    name="entity/project/artifact_name",
    per_page=page_size,
)
first_page = list(islice(artifacts, page_size))

saved_cursor = artifacts.cursor

# 後で(例:新しいプロセスで)、保存したカーソルからイテレーションを再開します。
remaining_artifacts = api.artifacts(
    type_name="type",
    name="entity/project/artifact_name",
    per_page=page_size,
    start=saved_cursor,
)

method Api.automation

automation(name: 'str', entity: 'str | None' = None) → Automation
パラメーターに一致する オートメーション を 1 件だけ返します。 引数:
  • name: 取得する オートメーション の名前。
  • entity: オートメーション の取得対象の entity。
例外:
  • ValueError: 検索条件に一致する オートメーション が 0 件、または複数件ある場合。
例: "my-automation" という名前の既存の オートメーション を取得します:
import wandb

api = wandb.Api()
automation = api.automation(name="my-automation")
entity “my-team” から、名前が “other-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,
    start: 'str | None' = None
) → Iterator[Automation]
指定したパラメーターに一致するすべての オートメーション を走査するイテレーターを返します。 パラメーターを指定しない場合、返されるイテレーターには、ユーザーがアクセスできるすべての オートメーション が含まれます。 引数:
  • entity: オートメーション を取得する対象の entity。
  • name: 取得する オートメーション の名。
  • per_page: 1 ページあたりに取得する オートメーション の数。デフォルトは 50 です。通常、これを変更する必要はありません。
  • start: 過去のクエリを再開するためのページネーションカーソル。以前の paginator の .cursor 属性から取得します。
戻り値: オートメーション のリスト。 Examples: entity “my-team” の既存の オートメーション をすべて取得します:
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
新しい オートメーション を作成します。 引数: obj: 作成するオートメーション。 fetch_existing: True の場合、競合するオートメーションがすでに存在するときは、エラーを発生させる代わりに既存のオートメーションの取得を試みます。 **kwargs: 作成前にオートメーションに追加で割り当てる値。 指定した場合、これらの値はオートメーションにすでに設定されている値を上書きします。
  • name: オートメーションの名前。
    • description: オートメーションの説明。
    • enabled: オートメーションが有効かどうか。
    • scope: オートメーションのスコープ。
    • event: オートメーションをトリガーするイベント。
    • action: オートメーションによってトリガーされるアクション。
戻り値: 保存された オートメーション。 Examples: 特定の project 内の run がカスタムしきい値を超えるメトリクスをログしたときに Slack 通知を送信する、my-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 を返します。 引数:
  • entity: チャートを所有する entity (ユーザーまたはチーム)
  • name: チャートプリセットの一意の識別子
  • display_name: UI に表示される、人が理解しやすい名前
  • spec_type: 仕様のタイプ。Vega-Lite v2 の仕様では “vega2” である必要があります。
  • access: チャートのアクセスレベル:
    • “private”: チャートを作成した entity のみがアクセス可能
    • “public”: チャートは公開アクセス可能
  • spec: dict または JSON 文字列として表した Vega/Vega-Lite 仕様
戻り値: 作成されたチャートプリセットの 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
新しいプロジェクトを作成します。 引数:
  • 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
新しいレジストリを作成します。 引数:
  • name: レジストリの名です。名は組織内で一意である必要があります。
  • visibility: レジストリの公開範囲です。
  • organization: 組織内の誰でもこのレジストリを表示できます。ロールは後で UI の設定から編集できます。
  • restricted: UI で招待されたメンバーのみがこのレジストリにアクセスできます。公開共有は無効になります。
  • organization: レジストリの組織です。設定で組織が指定されていない場合、entity が 1 つの組織にのみ属していれば、その組織が entity から取得されます。
  • description: レジストリの説明です。
  • artifact_types: レジストリで受け入れ可能な artifact タイプです。タイプは次の条件を満たす必要があります
  • more than 128 characters and do not include characters /or ``:. 指定しない場合は、すべてのタイプが受け入れられます。レジストリに追加した許可タイプは後から削除できません。
戻り値: レジストリ object です。 例:
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
新しいrunを作成します。 引数:
  • run_id: runに割り当てるID。指定しない場合、W&BがランダムなIDを生成します。
  • project: runをログする先のプロジェクト。指定しない場合、“Uncategorized” という名前のプロジェクトにrunをログします。
  • entity: プロジェクトの所有者であるentity。指定しない場合、デフォルトのentityにrunをログします。
戻り値: 新しく作成された 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 キューを作成します。 引数:
  • name: 作成するキューの名
  • type: キューで使用するリソースのタイプ。"local-container""local-process""kubernetes""sagemaker"、または "gcp-vertex" のいずれかです。
  • entity: キューを作成する entity の名。None の場合は、設定済みまたはデフォルトの entity を使用します。
  • prioritization_mode: 使用する優先順位付けのバージョン。"V0" または None のいずれかです。
  • config: キューで使用するデフォルトのリソース設定。テンプレート変数を指定するには、Handlebars (例: {{var}}) を使用します。
  • template_variables: config と一緒に使用するテンプレート変数スキーマの辞書。
戻り値: 新しく作成された RunQueue Raises: いずれかのパラメーターが無効な場合は ValueError、wandb API エラーが発生した場合は wandb.Error

method Api.create_team

create_team(team: 'str', admin_username: 'str | None' = None) → Team
新しいチームを作成します。 引数:
  • team: チームの名前
  • admin_username: チームの管理者ユーザーのユーザー名。デフォルトでは現在のユーザーです。
戻り値: Team オブジェクト。

method Api.create_user

create_user(email: 'str', admin: 'bool | None' = False) → User
新しいユーザーを作成します。 引数:
  • email: ユーザーのメールアドレス。
  • admin: ユーザーをインスタンス全体の管理者に設定します。
戻り値: User オブジェクト。

method Api.delete_automation

delete_automation(obj: 'Automation | str') → Literal[True]
自動化 を削除します。 引数:
  • obj: 削除対象の 自動化、またはその ID。
戻り値: 自動化 が正常に削除された場合は True。

method Api.flush

flush()
ローカルキャッシュをフラッシュします。 api オブジェクトは runs のローカルキャッシュを保持しています。そのため、スクリプトの実行中に run の状態が変わる可能性がある場合は、api.flush() でローカルキャッシュをクリアし、run に関連付けられた最新の値を取得する必要があります。

method Api.from_path

from_path(path: 'str')
パスから run、sweep、プロジェクト、または レポート を返します。 引数:
  • path: プロジェクト、run、sweep、または レポート へのパス
戻り値: ProjectRunSweep、または BetaReport のインスタンス。 Raises: パスが無効であるか、オブジェクトが存在しない場合は wandb.Error Examples: 以下のコードスニペットでは、“project”、“チーム”、“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,
    start: 'str | None' = None
) → Iterator[Integration]
entity のすべてのインテグレーションを反復するイテレーターを返します。 引数:
  • entity: インテグレーションを取得する対象の entity (例: チーム名) 。指定しない場合は、ユーザーのデフォルト entity が使用されます。
  • per_page: 1 ページあたりに取得するインテグレーション数。デフォルトは 50 です。通常、これを変更する必要はありません。
生成される値:
  • Iterator[SlackIntegration | WebhookIntegration]: サポートされる任意のインテグレーションのイテレーター。

method Api.job

job(name: 'str | None', path: 'str | None' = None) → public.Job
Job オブジェクトを返します。 引数:
  • name: ジョブ名。
  • path: ジョブ artifact をダウンロードするルートパス。
戻り値: Job オブジェクト。

method Api.list_jobs

list_jobs(entity: 'str', project: 'str') → list[dict[str, Any]]
指定されたentityとプロジェクトに対応するジョブが存在する場合は、その一覧を返します。 引数:
  • entity: 一覧表示するジョブのentity。
  • project: 一覧表示するジョブのプロジェクト。
戻り値: 一致するジョブの一覧。

method Api.project

project(name: 'str', entity: 'str | None' = None) → public.Project
指定された名前の Project を返します (entity が指定されている場合は、その entityProject) 。 引数:
  • name: プロジェクト名。
  • entity: 取得する entity の名前。None の場合は、Api に渡されたデフォルトの entity が使用されます。デフォルトの entity がない場合は、ValueError を送出します。
戻り値: Project オブジェクト。

method Api.projects

projects(entity: 'str | None' = None, per_page: 'int' = 200) → public.Projects
指定したentityのプロジェクトを取得します。 引数:
  • entity: 要求されたentityの名です。None の場合は、Api に渡されたデフォルトのentityが使用されます。デフォルトのentityがない場合は、ValueError が発生します。
  • per_page: クエリのページネーションにおけるページサイズを設定します。通常、これを変更する必要はありません。
戻り値: 反復可能なコレクションである Projects object。各要素は Project object です。

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,
    start: 'str | None' = None
) → Registries
Registry オブジェクトの遅延イテレーターを返します。 このイテレーターを使用して、組織のレジストリ全体にあるレジストリ、collection、または artifact バージョンを検索したり、フィルターしたりできます。 引数:
  • organization: (str, optional) 取得するレジストリの組織。指定しない場合は、ユーザーの Settings で指定された組織を使用します。
  • filter: (dict, optional) 遅延レジストリイテレーター内の各オブジェクトに適用する MongoDB スタイルのフィルター。レジストリに対してフィルターできるフィールドは namedescriptioncreated_atupdated_at です。collection に対してフィルターできるフィールドは nametagdescriptioncreated_atupdated_at です。バージョンに対してフィルターできるフィールドは tagaliascreated_atupdated_atmetadata です。
  • per_page: クエリのページネーションにおけるページサイズを設定します。
  • start: 過去のクエリを再開するためのページネーションカーソル。以前の paginator の .cursor 属性から取得します。
戻り値: Registry オブジェクトの遅延イテレーター。 例: 名前に “model” を含むすべてのレジストリを検索する
import wandb

api = wandb.Api()  # entity が複数の org に属している場合は、org を指定します
api.registries(filter={"name": {"$regex": "model"}})
レジストリ内で、名が “my_collection”、タグが “my_tag” のすべてのコレクションを検索します
api.registries().collections(filter={"name": "my_collection", "tag": "my_tag"})
「my_collection」を含む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"}]}
)
paginator の .cursor を保存して start= に渡すと、イテレーションを一時停止し、後で同じ位置から再開できます:
from itertools import islice

import wandb

api = wandb.Api()

# 最初のページの結果を取得し、カーソルを保存します。
page_size = 10
registries = api.registries(per_page=page_size)
first_page = list(islice(registries, page_size))

saved_cursor = registries.cursor

# 後で(例:新しいプロセスで)、保存したカーソルからイテレーションを再開します。
remaining_registries = api.registries(per_page=page_size, start=saved_cursor)

method Api.registry

registry(name: 'str', organization: 'str | None' = None) → Registry
指定したレジストリ名に対応するレジストリを返します。 引数:
  • name: レジストリの名前。wandb-registry- プレフィックスは含みません。
  • organization: レジストリの組織。Settings で組織が設定されていない場合、entity が 1 つの組織にのみ所属していれば、その entity から組織を取得します。
戻り値: レジストリオブジェクト。 例: レジストリを取得して更新する
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
指定したプロジェクトパスのレポートを取得します。 注: wandb.Api.reports() API はベータ版のため、今後の version で変更される可能性があります。 引数:
  • path: レポートが存在するプロジェクトのパスです。プロジェクトを作成した entity をプレフィックスとして指定し、その後にスラッシュを付けます。
  • name: 取得するレポートの名です。
  • per_page: クエリのページネーションにおけるページサイズを設定します。通常、これを変更する必要はありません。
戻り値: 反復可能な BetaReport オブジェクトのコレクションである Reports オブジェクト。 例:
import wandb

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

method Api.run

run(path='')
entity/project/run_id 形式のパスを解析して、1 つの run を返します。 引数:
  • path: entity/project/run_id 形式の run へのパス。api.entity が設定されている場合は project/run_id 形式でも指定でき、api.project が設定されている場合は run_id のみでも指定できます。
戻り値: 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 オブジェクトを遅延的に反復処理する 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 の設定や summary メトリクス内の項目でもフィルターできます。たとえば config.experiment_namesummary_metrics.loss などです。 より複雑なフィルタリングには、MongoDB のクエリ演算子を使用できます。詳細は https://docs.mongodb.com/manual/reference/operator/query を参照してください。サポートされる操作は次のとおりです。
  • $and
  • $or
  • $nor
  • $eq
  • $ne
  • $gt
  • $gte
  • $lt
  • $lte
  • $in
  • $nin
  • $exists
  • $regex
引数:
  • path: (str) プロジェクトへのパス。形式は “entity/project” である必要があります
  • filters: (dict) MongoDB クエリ言語を使用して特定の run をクエリするための条件。config.key、summary_metrics.key、state、entity、createdAt などの run のプロパティでフィルターできます。
  • For example: {"config.experiment_name": "foo"} は、experiment name の設定エントリが “foo” に設定されている run を検索します
  • order: (str) 順序には created_atheartbeat_atconfig.*.value、または summary_metrics.* を指定できます。先頭に + を付けると昇順 (デフォルト) 、- を付けると降順になります。デフォルトの順序は、古いものから新しいものへの run.created_at です。
  • per_page: (int) クエリのページネーションのページサイズを設定します。
  • include_sweeps: (bool) 結果に sweep の run を含めるかどうか。
  • lazy: (bool) より高速なパフォーマンスのために遅延読み込みを使用するかどうか。True (デフォルト) の場合、最初は必要最小限の run メタデータのみが読み込まれます。config、summaryMetrics、systemMetrics などの重いフィールドは、アクセス時にオンデマンドで読み込まれます。最初から完全なデータを取得するには False に設定してください。
戻り値: Run オブジェクトの反復可能なコレクションである Runs オブジェクト。 例:
import wandb
from wandb.apis.public import Api

# project 内で config.experiment_name が "foo" に設定されている run を検索する
Api.runs(path="my_entity/project", filters={"config.experiment_name": "foo"})
# config.experiment_name が "foo" または "bar" に設定されている project の run を検索する
Api.runs(
    path="my_entity/project",
    filters={
         "$or": [
             {"config.experiment_name": "foo"},
             {"config.experiment_name": "bar"},
         ]
    },
)
# config.experiment_name が正規表現に一致する project 内の run を検索する
# (アンカーはサポートされていません)
Api.runs(
    path="my_entity/project",
    filters={"config.experiment_name": {"$regex": "b.*"}},
)
# run 名が正規表現に一致する project 内の run を検索する
# (アンカーはサポートされていません)
Api.runs(
    path="my_entity/project", filters={"display_name": {"$regex": "^foo.*"}}
)
# 損失の昇順で並べ替えたプロジェクト内の 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,
    start: 'str | None' = None
) → Iterator[SlackIntegration]
entity の Slack インテグレーションのイテレーターを返します。 引数:
  • entity: インテグレーションを取得する対象の entity (例: チーム名) 。指定しない場合は、ユーザーのデフォルトの entity が使用されます。
  • per_page: 1 ページあたりに取得するインテグレーション数。デフォルトは 50 です。通常、これを変更する必要はありません。
生成される値:
  • Iterator[SlackIntegration]: Slack インテグレーションのイテレーター。
例: チーム “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 を返します。 引数:
  • path: entity/project/sweep_id 形式の sweep へのパス。api.entity が設定されている場合は project/sweep_id 形式でも指定でき、api.project が設定されている場合は sweep_id のみでも指定できます。
戻り値: Sweep オブジェクト。

method Api.sync_tensorboard

sync_tensorboard(root_dir, run_id=None, project=None, entity=None)
tfevent ファイルを含むローカルディレクトリを wandb に Sync します。

method Api.team

team(team: 'str') → Team
指定された名前に一致する Team を返します。 引数:
  • team: チームの名前。
戻り値: Team オブジェクト。

method Api.update_automation

update_automation(
    obj: 'Automation',
    create_missing: 'bool' = False,
    **kwargs: 'Unpack[WriteAutomationsKwargs]'
) → Automation
既存の自動化を更新します。 引数:
  • obj: 更新する自動化。既存の自動化である必要があります。 create_missing (bool): True の場合、自動化が存在しなければ作成します。 **kwargs: 更新前に自動化に設定する追加の値。指定した場合、これらの値は自動化にすでに設定されている値を上書きします:
    • name: 自動化の名。
    • description: 自動化の説明。
    • enabled: 自動化が有効かどうか。
    • scope: 自動化のスコープ。
    • event: 自動化をトリガーするイベント。
    • action: 自動化によってトリガーされるアクション。
戻り値: 更新された自動化。 Examples: 既存の自動化 (“my-automation”) を無効にし、説明を編集します:
import wandb

api = wandb.Api()

automation = api.automation(name="my-automation")
automation.enabled = False
automation.description = "参照用として保持していますが、現在は使用していません。"

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="参照用に保持していますが、現在は使用していません。",
)

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 キューをアップサートします。 引数:
  • name: 作成するキューの名
  • entity: キューを作成する entity の任意の名。None の場合は、設定済みまたはデフォルトの entity を使用します。
  • resource_config: キューに使用する任意のデフォルトのリソース設定。テンプレート変数を指定するには、handlebars (例: {{var}}) を使用します。
  • resource_type: キューに使用するリソースのタイプ。“local-container”、“local-process”、“kubernetes”、“sagemaker”、または “gcp-vertex” のいずれかです。
  • template_variables: 設定で使用するテンプレート変数スキーマの辞書。
  • external_links: キューで使用する外部リンクの任意の辞書。
  • prioritization_mode: 使用する優先順位付けの任意のバージョン。“V0” または None のいずれかです
戻り値: アップサートされた RunQueue Raises: いずれかのパラメーターが無効な場合は ValueError、wandb API エラーが発生した場合は wandb.Error

method Api.user

user(username_or_email: 'str') → User | None
ユーザー名またはメールアドレスからユーザーを返します。 この関数はローカル管理者でのみ使用できます。自分自身のユーザーオブジェクトを取得するには、api.viewer を使用します。 引数:
  • username_or_email: 対象ユーザーのユーザー名またはメールアドレス。
戻り値: ユーザーが見つかった場合は User オブジェクト、見つからない場合は None を返します。

method Api.users

users(username_or_email: 'str') → list[User]
ユーザー名またはメールアドレスの一部をクエリして、該当するすべてのユーザーを返します。 この関数はローカル管理者のみが使用できます。自分自身のユーザーオブジェクトを取得するには、api.viewer を使用します。 引数:
  • username_or_email: 検索したいユーザー名またはメールアドレスの接頭辞または接尾辞。
戻り値: User オブジェクトの配列。

method Api.webhook_integrations

webhook_integrations(
    entity: 'str | None' = None,
    per_page: 'int' = 50,
    start: 'str | None' = None
) → Iterator[WebhookIntegration]
entity の webhook インテグレーションのイテレーターを返します。 引数:
  • entity: インテグレーションを取得する対象の entity (例: チーム名) 。指定しない場合は、ユーザーのデフォルト entity が使用されます。
  • per_page: 1 ページあたりに取得するインテグレーション数。デフォルトは 50 です。通常、これを変更する必要はありません。
生成される値:
  • Iterator[WebhookIntegration]: webhook インテグレーションのイテレーター。
例: チーム “my-team” に登録されている webhook インテグレーションをすべて取得します:
import wandb

api = wandb.Api()
webhook_integrations = api.webhook_integrations(entity="my-team")
https://my-fake-url.com” にPOSTリクエストを送信する webhook インテグレーションのみを検索します:
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")
]