メインコンテンツへスキップ
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 を設定できます。また、 entityprojectrun のデフォルト値を設定することも可能です。
  • 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 がログ記録された Projects の名前、Artifact の名前、および Artifact のバージョンまたはエイリアスが含まれます。オプションとして、Artifact をログ記録した entity をプレフィックスとして追加し、その後にスラッシュを続けることができます。名前に entity が指定されていない場合は、 Runs または API 設定の entity が使用されます。
  • type: 取得する Artifact のタイプ。
Returns: Artifact オブジェクト。 Raises:
  • ValueError: Artifact 名が指定されていない場合。
  • ValueError: Artifact タイプが指定されているが、取得された Artifact のタイプと一致しない場合。
Examples: 以下のコードスニペットにおいて、“entity”、“project”、“artifact”、“version”、および “alias” は、それぞれあなたの W&B entity、Artifact が属する Projects の名前、Artifact の名前、および Artifact のバージョンを表すプレースホルダーです。
import wandb

# プロジェクト、アーティファクト名、アーティファクトのエイリアスを指定
wandb.Api().artifact(name="project/artifact:alias")

# プロジェクト、アーティファクト名、特定のアーティファクトバージョンを指定
wandb.Api().artifact(name="project/artifact:version")

# entity、プロジェクト、アーティファクト名、アーティファクトのエイリアスを指定
wandb.Api().artifact(name="entity/project/artifact:alias")

# entity、プロジェクト、アーティファクト名、特定のアーティファクトバージョンを指定
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 が属する Projects の名前、および Artifact の名前を表すプレースホルダーです。
import wandb

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

# コレクション内の最初のアーティファクトを取得
artifact_example = collections.artifacts()[0]

# アーティファクトの内容を指定したルートディレクトリにダウンロード
artifact_example.download()

method Api.artifact_collection_exists

artifact_collection_exists(name: 'str', type: 'str') → bool
指定された Projects および entity 内に Artifact コレクションが存在するかどうかを確認します。 Args:
  • name: Artifact コレクションの名前。オプションとして、Artifact をログ記録した entity をプレフィックスとして追加し、その後にスラッシュを続けることができます。entity または project が指定されていない場合、オーバーライドパラメータが存在すればそれらからコレクションを推測します。それ以外の場合、entity はユーザー設定から取得され、project はデフォルトで “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: フィルタリングする Projects の名前。
  • type_name: フィルタリングする Artifact タイプの名前。
  • per_page: クエリのページネーションにおけるページサイズを設定します。通常、これを変更する理由はありません。
Returns: イテラブルな ArtifactCollections オブジェクト。

method Api.artifact_exists

artifact_exists(name: 'str', type: 'str | None' = None) → bool
指定された Projects および entity 内に Artifact バージョンが存在するかどうかを確認します。 Args:
  • name: Artifact の名前。Artifact の entity と project をプレフィックスとして追加します。Artifact のバージョンまたはエイリアスをコロンで末尾に付けます。entity または project が指定されていない場合、設定されているオーバーライドパラメータを使用します。それ以外の場合、entity はユーザー設定から取得され、project は “Uncategorized” に設定されます。
  • type: Artifact のタイプ。
Returns: Artifact バージョンが存在する場合は True、そうでない場合は False。 Examples: 以下のコードスニペットにおいて、“entity”、“project”、“artifact”、“version”、および “alias” は、それぞれあなたの W&B entity、Artifact が属する Projects の名前、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: 指定された場合、フィルタリングする Projects 名またはパス。
Returns: ArtifactType オブジェクト。

method Api.artifact_types

artifact_types(project: 'str | None' = None) → ArtifactTypes
一致する Artifact タイプの集合を返します。 Args:
  • project: フィルタリングする Projects 名またはパス。
Returns: イテラブルな ArtifactTypes オブジェクト。

method Api.artifact_versions

artifact_versions(type_name, name, per_page=50)
非推奨。代わりに 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 がログ記録された Projects の名前、および 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: 取得するオートメーションの名前。
  • entity: オートメーションを取得する対象の entity。
Raises:
  • ValueError: 検索条件に一致する Automation が 0 個または複数存在する場合。
Examples: “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
) → Iterator[Automation]
指定されたパラメータに一致するすべての Automations に対するイテレータを返します。 パラメータが指定されない場合、返されるイテレータにはユーザーがアクセス権を持つすべての Automations が含まれます。 Args:
  • entity: オートメーションを取得する対象の entity。
  • name: 取得するオートメーションの名前。
  • per_page: 1ページあたりに取得するオートメーションの数。デフォルトは 50 です。通常、これを変更する理由はありません。
Returns: オートメーションのリスト。 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
新しい Automation を作成します。 Args: obj: 作成するオートメーション。 fetch_existing: True の場合、競合するオートメーションが既に存在すると、エラーを発生させる代わりに既存のオートメーションの取得を試みます。 **kwargs: 作成前にオートメーションに割り当てる追加の値。指定された場合、これらはオートメーションに既に設定されている値を上書きします:
  • name: オートメーションの名前。
  • description: オートメーションの説明。
  • enabled: オートメーションが有効かどうか。
  • scope: オートメーションのスコープ。
  • event: オートメーションをトリガーするイベント。
  • action: オートメーションによってトリガーされるアクション。
Returns: 保存された Automation。 Examples: 特定のプロジェクト内の 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="'custom-metric' が 10 を超えるたびに Slack メッセージを送信します。",
)

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
新しいプロジェクトを作成します。 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 が1つの組織にのみ属しているなら、その 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="これはテストレジストリです",
   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 を作成します。 Args:
  • run_id: Run に割り当てる ID。指定しない場合、W&B はランダムな ID を作成します。
  • project: Run をログに記録する Projects。プロジェクトが指定されていない場合、“Uncategorized” という名前のプロジェクトにログを記録します。
  • entity: プロジェクトを所有する entity。entity が指定されていない場合、デフォルトの entity に Run をログ記録します。
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 またはデフォルトの entity を使用します。
  • prioritization_mode: 使用する優先順位付けのバージョン。“V0” または None
  • config: キューに使用されるデフォルトのリソース設定。テンプレート変数を指定するにはハンドルバー(例: {{var}})を使用します。
  • template_variables: 設定で使用するテンプレート変数スキーマの辞書。
Returns: 新しく作成された RunQueue Raises: パラメータのいずれかが無効な場合は ValueError 、W&B API エラーの場合は wandb.Error

method Api.create_team

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

method Api.create_user

create_user(email: 'str', admin: 'bool | None' = False) → User
新しいユーザーを作成します。 Args:
  • email: ユーザーのメールアドレス。
  • admin: ユーザーをグローバルインスタンス管理者として設定します。
Returns: User オブジェクト。

method Api.delete_automation

delete_automation(obj: 'Automation | str') → Literal[True]
オートメーションを削除します。 Args:
  • obj: 削除するオートメーション、またはその ID。
Returns: オートメーションが正常に削除された場合は True。

method Api.flush

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

method Api.from_path

from_path(path: 'str')
パスから Run、Sweep、Projects、または Report を返します。 Args:
  • path: プロジェクト、Run、Sweep、または Report へのパス。
Returns: ProjectRunSweep、または BetaReport のインスタンス。 Raises: パスが無効であるか、オブジェクトが存在しない場合は wandb.Error Examples: 以下のコードスニペットにおいて、“project”、“team”、“run_id”、“sweep_id”、および “report_name” は、それぞれプロジェクト、チーム、Run ID、Sweep ID、および特定の Report の名前を表すプレースホルダーです。
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 のすべてのインテグレーションのイテレータを返します。 Args:
  • entity: インテグレーションを取得する entity (チーム名など)。提供されない場合、ユーザーのデフォルト entity が使用されます。
  • per_page: 1ページあたりに取得するインテグレーションの数。デフォルトは 50 です。通常、これを変更する理由はありません。
Yields:
  • Iterator[SlackIntegration | WebhookIntegration]: サポートされているインテグレーションのイテレータ。

method Api.job

job(name: 'str | None', path: 'str | None' = None) → public.Job
Job オブジェクトを返します。 Args:
  • name: ジョブの名前。
  • path: ジョブ Artifact をダウンロードするためのルートパス。
Returns: Job オブジェクト。

method Api.list_jobs

list_jobs(entity: 'str', project: 'str') → list[dict[str, Any]]
指定された entity と Projects に対してジョブがある場合、そのリストを返します。 Args:
  • entity: リストされるジョブの entity。
  • project: リストされるジョブの Projects。
Returns: 一致するジョブのリスト。

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 の Projects を取得します。 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 オブジェクトのレイジーイテレータを返します。 イテレータを使用して、組織のレジストリ全体でレジストリ、コレクション、または Artifact バージョンを検索およびフィルタリングします。 Args:
  • organization: (str, オプション) 取得するレジストリの組織。指定しない場合、ユーザー設定で指定された組織が使用されます。
  • filter: (dict, オプション) レイジーレジストリイテレータの各オブジェクトに適用する MongoDB スタイルのフィルター。レジストリのフィルタリングに使用できるフィールドは namedescriptioncreated_atupdated_at です。コレクションのフィルタリングに使用できるフィールドは nametagdescriptioncreated_atupdated_at です。バージョンのフィルタリングに使用できるフィールドは tagaliascreated_atupdated_atmetadata です。
  • per_page: クエリのページネーションにおけるページサイズを設定します。
Returns: Registry オブジェクトのレイジーイテレータ。 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 が1つの組織にのみ属しているなら、その entity から組織が取得されます。
Returns: レジストリオブジェクト。 Examples: レジストリを取得して更新する
import wandb

api = wandb.Api()
registry = api.registry(name="my-registry", organization="my-org")
registry.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: Report が存在する Projects へのパス。プロジェクトを作成した entity をプレフィックスとして追加し、その後にスラッシュを続けます。
  • name: 要求された Report の名前。
  • 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 オブジェクトをレイジーに反復する Runs オブジェクトを返します。 フィルタリングに使用できるフィールドには、以下が含まれます:
  • createdAt: Run が作成されたタイムスタンプ(ISO 8601 形式、例: “2023-01-01T12:00:00Z”)。
  • displayName: Run の人間が読める表示名(例: “eager-fox-1”)。
  • duration: Run の総実行時間(秒)。
  • group: 関連する Runs をまとめて整理するために使用されるグループ名。
  • host: Run が実行されたホスト名。
  • jobType: ジョブのタイプまたは Run の目的。
  • name: Run の一意識別子(例: “a1b2cdef”)。
  • state: Run の現在の状態。
  • tags: Run に関連付けられたタグ。
  • username: Run を開始したユーザーのユーザー名。
さらに、Run 設定(config)やサマリーメトリクス内の項目でフィルタリングすることもできます( 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
Args:
  • path: (str) プロジェクトへのパス。“entity/project” の形式である必要があります。
  • filters: (dict) MongoDB クエリ言語を使用した特定の Runs のクエリ。config.key、summary_metrics.key、state、entity、createdAt などの Run プロパティでフィルタリングできます。
  • : {"config.experiment_name": "foo"} は、設定項目の experiment name が “foo” に設定されている Runs を検索します。
  • order: (str) 並び順は created_atheartbeat_atconfig.*.value、または summary_metrics.* を指定できます。 + を先頭に付けると昇順(デフォルト)、 - を先頭に付けると降順になります。デフォルトの順序は run.created_at の古い順です。
  • per_page: (int) クエリのページネーションにおけるページサイズを設定します。
  • include_sweeps: (bool) 結果に Sweep の Runs を含めるかどうか。
  • lazy: (bool) 高速化のためにレイジーローディングを使用するかどうか。True(デフォルト)の場合、最初は必須の Run メタデータのみが読み込まれます。config、summaryMetrics、systemMetrics などの重いフィールドは、アクセスされたときにオンデマンドで読み込まれます。最初からすべてのデータを取得するには False に設定します。
Returns: Run オブジェクトのイテラブルなコレクションである Runs オブジェクト。 Examples:
import wandb
from wandb.apis.public import Api

# config.experiment_name が "foo" に設定されているプロジェクト内の Runs を検索
Api.runs(path="my_entity/project", filters={"config.experiment_name": "foo"})
# config.experiment_name が "foo" または "bar" に設定されているプロジェクト内の Runs を検索
Api.runs(
    path="my_entity/project",
    filters={
         "$or": [
             {"config.experiment_name": "foo"},
             {"config.experiment_name": "bar"},
         ]
    },
)
# config.experiment_name が正規表現に一致するプロジェクト内の Runs を検索
# (アンカーはサポートされていません)
Api.runs(
    path="my_entity/project",
    filters={"config.experiment_name": {"$regex": "b.*"}},
)
# Run の表示名が正規表現に一致するプロジェクト内の Runs を検索
# (アンカーはサポートされていません)
Api.runs(
    path="my_entity/project", filters={"display_name": {"$regex": "^foo.*"}}
)
# loss の昇順でソートされたプロジェクト内の Runs を検索
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 インテグレーションのイテレータを返します。 Args:
  • entity: インテグレーションを取得する entity (チーム名など)。提供されない場合、ユーザーのデフォルト entity が使用されます。
  • per_page: 1ページあたりに取得するインテグレーションの数。デフォルトは 50 です。通常、これを変更する理由はありません。
Yields:
  • Iterator[SlackIntegration]: Slack インテグレーションのイテレータ。
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
既存のオートメーションを更新します。 Args:
  • obj: 更新するオートメーション。既存のオートメーションである必要があります。 create_missing (bool): True の場合、オートメーションが存在しないときは作成します。 **kwargs: 更新前にオートメーションに割り当てる追加の値。指定された場合、これらはオートメーションに既に設定されている値を上書きします:
    • name: オートメーションの名前。
    • description: オートメーションの説明。
    • enabled: オートメーションが有効かどうか。
    • scope: オートメーションのスコープ。
    • event: オートメーションをトリガーするイベント。
    • action: オートメーションによってトリガーされるアクション。
Returns: 更新されたオートメーション。 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 キューをアップサート(更新または挿入)します。 Args:
  • name: 作成するキューの名前
  • entity: オプション。キューを作成する entity の名前。 None の場合、設定された entity またはデフォルトの entity を使用します。
  • resource_config: オプション。キューに使用されるデフォルトのリソース設定。テンプレート変数を指定するにはハンドルバー(例: {{var}})を使用します。
  • resource_type: キューに使用されるリソースのタイプ。“local-container”、“local-process”、“kubernetes”、“sagemaker”、または “gcp-vertex” のいずれか。
  • template_variables: 設定で使用するテンプレート変数スキーマの辞書。
  • external_links: オプション。キューで使用する外部リンクの辞書。
  • prioritization_mode: オプション。使用する優先順位付けのバージョン。“V0” または None。
Returns: アップサートされた RunQueue Raises: パラメータのいずれかが無効な場合は ValueError、W&B 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 の Webhook インテグレーションのイテレータを返します。 Args:
  • entity: インテグレーションを取得する entity (チーム名など)。提供されない場合、ユーザーのデフォルト entity が使用されます。
  • per_page: 1ページあたりに取得するインテグレーションの数。デフォルトは 50 です。通常、これを変更する理由はありません。
Yields:
  • Iterator[WebhookIntegration]: Webhook インテグレーションのイテレータ。
Examples: チーム “my-team” に登録されているすべての Webhook インテグレーションを取得します:
import wandb

api = wandb.Api()
webhook_integrations = api.webhook_integrations(entity="my-team")
https://my-fake-url.com” にリクエストを送信する 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")
]