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

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 を初期化します。 Args:
  • overrides: base_url を設定できます。
  • using a W&B server other than https: //api.wandb.ai. また、entityprojectrun のデフォルト値も設定できます。
  • timeout: API リクエストの HTTP タイムアウト (秒) 。指定しない場合はデフォルトのタイムアウトが使用されます。
  • api_key: 認証に使用する API キー。指定しない場合は、現在の環境または設定にある API キーが使用されます。環境にも設定にも API キーがない場合は、API キーの入力を求めます。

property Api.client

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

property Api.default_entity

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

property Api.user_agent

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

property Api.viewer

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

method Api.artifact

artifact(name: 'str', type: 'str | None' = None)
単一のアーティファクトを返します。 Args:
  • name: アーティファクトの名前。アーティファクトの名前はファイルパスに似た形式で、少なくとも、そのアーティファクトがログされたプロジェクト名、アーティファクト名、アーティファクトのバージョンまたはエイリアスで構成されます。任意で、そのアーティファクトをログした entity 名を先頭に付け、その後にスラッシュを続けることもできます。name に entity が指定されていない場合は、Run または API 設定の entity が使用されます。
  • type: 取得するアーティファクトの種類。
Returns: Artifact オブジェクト。 Raises:
  • ValueError: アーティファクト名が指定されていない場合。
  • ValueError: アーティファクトの種類が指定されているが、取得したアーティファクトの種類と一致しない場合。
Examples: 次のコードスニペットにおける “entity”、“project”、“artifact”、“version”、および “alias” は、それぞれ、あなたの W&B entity、アーティファクトが含まれているプロジェクトの名前、アーティファクトの名前、およびアーティファクトのバージョンまたはエイリアスを表すプレースホルダーです。
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")
注意:
このメソッドは外部からの利用のみを想定しています。wandb リポジトリのコード内で api.artifact() を呼び出さないでください。

method Api.artifact_collection

artifact_collection(type_name: 'str', name: 'str') → ArtifactCollection
指定した type のアーティファクトコレクションを 1 つ返します。 返された ArtifactCollection オブジェクトを使って、そのコレクション内の特定のアーティファクトに関する情報を取得したり、その他の操作を行ったりできます。 Args:
  • type_name: 取得するアーティファクトコレクションの type。
  • name: アーティファクトコレクション名。任意で、アーティファクトをログした entity を、スラッシュ区切りのプレフィックスとして付与できます。
Returns: ArtifactCollection オブジェクト。 Examples: 以下のコードスニペット中の “type”、“entity”、“project”、および “artifact_name” は、それぞれコレクションの type、あなたの W&B entity、アーティファクトが属するプロジェクト名、アーティファクト名を表すプレースホルダーです。
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
指定された プロジェクト と entity 内にアーティファクトコレクションが存在するかどうか。 Args:
  • name: アーティファクトコレクション名。任意で、そのアーティファクトをログした entity をプレフィックスとして付け、その後にスラッシュを続けて指定できます。entity または project が指定されていない場合、存在すれば override パラメーターからコレクションを推論します。それ以外の場合、entity はユーザー設定から取得され、project はデフォルトで「uncategorized」になります。
  • type: アーティファクトコレクションの種類。
Returns: アーティファクトコレクションが存在する場合は True、存在しない場合は False。 Examples: 以下のコードスニペットでは、「type」と「collection_name」は、それぞれアーティファクトコレクションの種類とコレクション名を表します。
import wandb

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

メソッド Api.artifact_collections

artifact_collections(
    project_name: 'str',
    type_name: 'str',
    per_page: 'int' = 50
) → ArtifactCollections
条件に一致する artifact collection の一覧を返します。 Args:
  • project_name: フィルター対象のプロジェクト名。
  • type_name: フィルター対象のアーティファクトタイプ名。
  • per_page: クエリのページネーションにおけるページサイズを設定します。通常、これを変更する必要はありません。
Returns: イテラブルな ArtifactCollections オブジェクトを返します。

method Api.artifact_exists

artifact_exists(name: 'str', type: 'str | None' = None) → bool
指定したプロジェクトと entity 内に、アーティファクト バージョンが存在するかどうか。 Args:
  • name: アーティファクトの名前。先頭にそのアーティファクトの entity とプロジェクトをプレフィックスとして付ける。末尾に、コロン区切りでバージョンまたはアーティファクトのエイリアスを付ける。entity またはプロジェクトが指定されていない場合、設定されていれば override パラメーターが使用される。そうでない場合、entity はユーザー設定から取得され、プロジェクトは “Uncategorized” に設定される。
  • type: アーティファクトの種類。
Returns: アーティファクト バージョンが存在する場合は True、そうでない場合は False。 Examples: 以下のコードスニペットでは、「entity」「project」「artifact」「version」「alias」は、それぞれあなたの W&B entity、アーティファクトが属するプロジェクト名、アーティファクト名、およびアーティファクトのバージョンを表すプレースホルダーである。
import wandb

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

メソッド Api.artifact_type

artifact_type(type_name: 'str', project: 'str | None' = None) → ArtifactType
一致する ArtifactType を返します。 Args:
  • type_name: 取得するアーティファクトタイプの名前。
  • project: 指定された場合、フィルタリングに使用するプロジェクト名またはパス。
Returns: ArtifactType オブジェクトを返します。

method Api.artifact_types

artifact_types(project: 'str | None' = None) → ArtifactTypes
一致するアーティファクトタイプのコレクションを返します。 引数:
  • project: フィルタリング対象のプロジェクト名またはパス。
返り値: イテラブルな 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: 取得するアーティファクトの種類。
  • name: アーティファクトのコレクション名。オプションで、アーティファクトをログした entity を先頭に付け、その後にスラッシュを続けて指定できます。
  • per_page: クエリのページネーションにおけるページサイズを設定します。通常、これを変更する必要はありません。
  • tags: これらすべてのタグを持つアーティファクトのみを返します。
Returns: 反復可能な Artifacts オブジェクト。 Examples: 次のコードスニペットでは、“type”、“entity”、“project”、および “artifact_name” は、それぞれアーティファクトの種類、W&B entity、アーティファクトがログされたプロジェクト名、およびアーティファクト名を表すプレースホルダーです。
import wandb

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

method Api.automation

automation(name: 'str', entity: 'str | None' = None) → Automation
指定したパラメーターに一致するただ 1 つの Automation を返します。 Args:
  • name: 取得する Automation の名前。
  • entity: Automation を取得する対象のエンティティ。
Raises:
  • ValueError: 検索条件に一致する Automation が 0 件、または複数件ある場合。
Examples: 名前が “my-automation” の既存の Automation を取得します:
import wandb

api = wandb.Api()
automation = api.automation(name="my-automation")
エンティティ “my-team” にある、名前が “other-automation” の既存の automation を取得します。
automation = api.automation(name="other-automation", entity="my-team")

メソッド Api.automations

automations(
    entity: 'str | None' = None,
    name: 'str | None' = None,
    per_page: 'int' = 50
) → Iterator[Automation]
指定されたパラメーターに一致するすべての Automation を走査するイテレーターを返します。 パラメーターが指定されていない場合、返されるイテレーターには、そのユーザーがアクセス権を持つすべての Automation が含まれます。 Args:
  • entity: Automation を取得する対象の entity。
  • name: 取得する Automation の名前。
  • per_page: 1 ページあたりに取得する Automation の数。デフォルトは 50。通常、これを変更する必要はありません。
Returns: Automation のリスト。 Examples: Entity “my-team” に対する既存のすべての Automation を取得する:
import wandb

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

メソッド 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.",
)

メソッド 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: チャートを所有するエンティティ (ユーザーまたはチーム)
  • name: チャートプリセットの一意の識別子
  • display_name: UI に表示されるわかりやすい名前
  • spec_type: 仕様の種類。Vega-Lite v2 の仕様では “vega2” でなければなりません。
  • access: チャートのアクセスレベル:
    • “private”: そのチャートを作成したエンティティのみがアクセス可能
    • “public”: 誰でもアクセス可能
  • spec: 辞書または JSON 文字列として指定された Vega/Vega-Lite 仕様
戻り値: 作成されたチャートプリセットの ID (形式は “entity/name”) 送出:
  • wandb.Error: チャートの作成に失敗した場合
  • UnsupportedError: サーバーがカスタムチャートをサポートしていない場合
例:
    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。

メソッド 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: レジストリの所属組織。設定で組織が指定されていない場合、エンティティが 1 つの組織にのみ属しているときは、そのエンティティから組織が取得されます。
  • description: レジストリの説明。
  • artifact_types: レジストリで受け付けるアーティファクトの型。型名は 128 文字以内で、/ および : 文字を含めてはいけません。指定しない場合、すべての型が許可されます。レジストリに追加された許可済みの型は、後から削除できません。
  • more: 上記の説明が 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
新しい run を作成します。 Args:
  • run_id: run に割り当てる ID。指定しない場合、W&B がランダムな ID を作成します。
  • project: run を記録するプロジェクト。プロジェクトを指定しない場合は、“Uncategorized” という名前のプロジェクトに run を記録します。
  • 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 キューを作成します。 引数:
  • 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 例外: パラメーターが不正な場合は ValueError を、wandb API エラー時には wandb.Error を送出します。

method Api.create_team

create_team(team: 'str', admin_username: 'str | None' = None) → Team
新しいチームを作成します。 引数:
  • team: チーム名
  • admin_username: チームの管理者ユーザーのユーザー名。指定しない場合は現在のユーザーが管理者になります。
戻り値: Team オブジェクト。

メソッド Api.create_user

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

メソッド Api.delete_automation

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

メソッド Api.flush

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

method Api.from_path

from_path(path: 'str')
パスから run、sweep、プロジェクト、またはレポートを返します。 引数:
  • path: プロジェクト、run、sweep、またはレポートへのパス
戻り値: ProjectRunSweep、または BetaReport のインスタンス。 送出される例外: パスが無効な場合、またはオブジェクトが存在しない場合に wandb.Error が送出されます。 使用例: 以下のコードスニペットに登場する “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")

メソッド Api.integrations

integrations(
    entity: 'str | None' = None,
    per_page: 'int' = 50
) → Iterator[Integration]
エンティティに対するすべてのインテグレーションのイテレータを返します。 引数:
  • entity: インテグレーションを取得する対象のエンティティ (例: チーム名)。指定しない場合は、そのユーザーのデフォルトエンティティが使用されます。
  • per_page: 1 ページあたりに取得するインテグレーション数。デフォルトは 50 です。通常、これを変更する必要はありません。
Yields:
  • Iterator[SlackIntegration | WebhookIntegration]: サポートされているインテグレーションのイテレータ。

method Api.job

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

メソッド Api.list_jobs

list_jobs(entity: 'str', project: 'str') → list[dict[str, Any]]
指定された entity とプロジェクトに対して、該当する job があれば、その一覧を返します。 引数:
  • entity: 一覧に含める job の対象となる entity。
  • project: 一覧に含める job の対象となるプロジェクト。
戻り値: 条件に一致する job のリスト。

method Api.project

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

メソッド 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 オブジェクトの遅延イテレーターを返します。 このイテレーターを使って、組織内の registry 全体にわたって registry、collection、または アーティファクト バージョンを検索およびフィルタリングします。 Args:
  • organization: (str, optional) 取得する registry の所属組織。指定されていない場合は、ユーザーの設定で指定されている組織を使用します。
  • filter: (dict, optional) 遅延 registry イテレーター内の各オブジェクトに適用される MongoDB 形式のフィルター。registry でフィルターに使用できるフィールドは namedescriptioncreated_atupdated_at です。collection でフィルターに使用できるフィールドは nametagdescriptioncreated_atupdated_at です。version でフィルターに使用できるフィールドは tagaliascreated_atupdated_atmetadata です。
  • per_page: クエリのページネーションにおけるページサイズを設定します。
Returns: Registry オブジェクトの遅延イテレーター。 Examples: 名前に “model” を含むすべての registry を検索します。
import wandb

api = wandb.Api()  # エンティティが複数の組織に属している場合は org を指定してください
api.registries(filter={"name": {"$regex": "model"}})
名前が “my_collection” で、タグが “my_tag” のすべてのコレクションをレジストリ内で検索します
api.registries().collections(filter={"name": "my_collection", "tag": "my_tag"})
レジストリ内で、コレクション名に “my_collection” を含み、バージョンにエイリアス “best” が付いているすべてのアーティファクト バージョンを検索します
api.registries().collections(
    filter={"name": {"$regex": "my_collection"}}
).versions(filter={"alias": "best"})
レジストリ内で名前に “model” を含み、タグ “prod” またはエイリアス “best” を持つすべてのアーティファクト バージョンを検索します
api.registries(filter={"name": {"$regex": "model"}}).versions(
    filter={"$or": [{"tag": "prod"}, {"alias": "best"}]}
)

method Api.registry

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

メソッド Api.run_queue

run_queue(entity: 'str', name: 'str')
指定した entity の、指定された名前の RunQueue を返します。 run queue の作成方法の詳細については、Api.create_run_queue を参照してください。

メソッド 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 の config や 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
Args:
  • 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 の config エントリが “foo” に設定されている run を検索します。
  • order: (str) 並び順は created_atheartbeat_atconfig.*.value、または summary_metrics.* を指定できます。order の前に + を付けると昇順 (デフォルト)、- を付けると降順になります。デフォルトの並び順は、最も古いものから新しいものへの 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" に設定されているプロジェクト内の runs を検索する
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.*"}}
)
# プロジェクト内の runs を loss の昇順で検索する
Api.runs(path="my_entity/project", order="+summary_metrics.loss")

メソッド Api.slack_integrations

slack_integrations(
    entity: 'str | None' = None,
    per_page: 'int' = 50
) → Iterator[SlackIntegration]
エンティティに対する Slack インテグレーションのイテレータを返します。 Args:
  • 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 を返します。 引数:
  • 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 と同期します。

method Api.team

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

method Api.user

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

メソッド 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
) → Iterator[WebhookIntegration]
エンティティの webhook インテグレーションのイテレータを返します。 引数:
  • 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")
]