class Api
Description
Used for querying the W&B server.Args
overrides: You can setbase_urlif you aretimeout: HTTP timeout in seconds for API requests. If not specified, the default timeout will be used.api_key: API key to use for authentication. If not provided, the API key from the current environment or configuration will be used. Prompts for an API key if none is provided or configured in the environment.
Examples
Properties
property user_agent
Returns W&B public user agent.property default_entity
Returns the default W&B entity.property viewer
Returns the viewer object.Methods
method artifact
Arguments
name: The artifact’s name. The name of an artifact resembles a filepath that consists, at a minimum, the name of the project the artifact was logged to, the name of the artifact, and the artifact’s version or alias. Optionally append the entity that logged the artifact as a prefix followed by a forward slash. If no entity is specified in the name, the Run or API setting’s entity is used.type: The type of artifact to fetch.
Raises
ValueError: If the artifact name is not specified.ValueError: If the artifact type is specified but does not match the type of the fetched artifact.
Examples
In the following code snippets “entity”, “project”, “artifact”, “version”, and “alias” are placeholders for your W&B entity, name of the project the artifact is in, the name of the artifact, and artifact’s version, respectively.api.artifact() within the wandb repository code.
method artifact_collection
ArtifactCollection object to retrieve
information about specific artifacts in that collection, and more.
Arguments
type_name: The type of artifact collection to fetch.name: An artifact collection name. Optionally append the entity that logged the artifact as a prefix followed by a forward slash.
Examples
In the proceeding code snippet “type”, “entity”, “project”, and “artifact_name” are placeholders for the collection type, your W&B entity, name of the project the artifact is in, and the name of the artifact, respectively.method artifact_collection_exists
Arguments
name: An artifact collection name. Optionally append the entity that logged the artifact as a prefix followed by a forward slash. If entity or project is not specified, infer the collection from the override params if they exist. Otherwise, entity is pulled from the user settings and project will default to “uncategorized”.type: The type of artifact collection.
Examples
In the proceeding code snippet “type”, and “collection_name” refer to the type of the artifact collection and the name of the collection, respectively.method artifact_collections
Arguments
project_name: The name of the project to filter on.type_name: The name of the artifact type to filter on.order: Optional string to specify the order of the results. If prefixed with ’+’, sorts ascending (default). If prefixed with ’-’, sorts descending.per_page: Sets the page size for query pagination. Usually there is no reason to change this.start: Pagination cursor for resuming a past query, captured from a previous paginator’s.cursorattribute.
method artifact_exists
Arguments
name: The name of artifact. Add the artifact’s entity and project as a prefix. Append the version or the alias of the artifact with a colon. If the entity or project is not specified, W&B uses override parameters if populated. Otherwise, the entity is pulled from the user settings and the project is set to “Uncategorized”.type: The type of artifact.
Examples
In the proceeding code snippets “entity”, “project”, “artifact”, “version”, and “alias” are placeholders for your W&B entity, name of the project the artifact is in, the name of the artifact, and artifact’s version, respectively.method artifact_type
ArtifactType.
Arguments
type_name: The name of the artifact type to retrieve.project: If given, a project name or path to filter on.
method artifact_types
Arguments
project: The project name or path to filter on.start: Pagination cursor for resuming a past query, captured from a previous paginator’s.cursorattribute.
method artifact_versions
Api.artifacts(type_name, name) method instead.
Arguments
type_name:name:per_page:
method artifacts
Artifacts collection.
Arguments
type_name: The type of artifacts to fetch.name: The artifact’s collection name. Optionally append the entity that logged the artifact as a prefix followed by a forward slash.order: Optional string to specify the order of the results. If prefixed with ’+’, sorts ascending (default). If prefixed with ’-’, sorts descending.per_page: Sets the page size for query pagination. Usually there is no reason to change this.tags: Only return artifacts with all of these tags.start: Pagination cursor for resuming a past query, captured from a previous paginator’s.cursorattribute.
Examples
In the proceeding code snippet, “type”, “entity”, “project”, and “artifact_name” are placeholders for the artifact type, W&B entity, name of the project the artifact was logged to, and the name of the artifact, respectively..cursor and passing it as start=:
method automation
Arguments
name: The name of the automation to fetch.entity: The entity to fetch the automation for.
Raises
ValueError: If zero or multiple Automations match the search criteria.
Examples
Get an existing automation named “my-automation”:method automations
Arguments
entity: The entity to fetch the automations for.name: The name of the automation to fetch.per_page: The number of automations to fetch per page. Defaults to 50. Usually there is no reason to change this.start: Pagination cursor for resuming a past query, captured from a previous paginator’s.cursorattribute.
Examples
Fetch all existing automations for the entity “my-team”:method create_automation
Arguments
obj: The automation to create.fetch_existing: If True, and a conflicting automation already exists, attempt to fetch the existing automation instead of raising an error.kwargs:
Examples
Create a new automation named “my-automation” that sends a Slack notification when a run within a specific project logs a metric exceeding a custom threshold:method create_custom_chart
Arguments
entity: The entity (user or team) that owns the chartname: Unique identifier for the chart presetdisplay_name: Human-readable name shown in the UIspec_type: Type of specification. Must be “vega2” for Vega-Lite v2 specifications.access: Access level for the chart:spec: The Vega/Vega-Lite specification as a dictionary or JSON string
Raises
wandb.Error: If chart creation failsUnsupportedError: If the server doesn’t support custom charts
Examples
method create_project
Arguments
name: The name of the new project.entity: The entity of the new project.
method create_registry
Arguments
name: The name of the registry. Name must be unique within the organization.visibility: The visibility of the registry.organization: The organization of the registry. If no organization is set in the settings, the organization will be fetched from the entity if the entity only belongs to one organization.description: The description of the registry.artifact_types: The accepted artifact types of the registry. A type is no
Examples
method create_run
Arguments
run_id: The ID to assign to the run. If not specified, W&B creates a random ID.project: The project where to log the run to. If no project is specified, log the run to a project called “Uncategorized”.entity: The entity that owns the project. If no entity is specified, log the run to the default entity.
method create_run_queue
Arguments
name: Name of the queue to createtype: Type of resource to be used for the queue. One of “local-container”, “local-process”, “kubernetes”,“sagemaker”, or “gcp-vertex”.entity: Name of the entity to create the queue. IfNone, use the configured or default entity.prioritization_mode: Version of prioritization to use. Either “V0” orNone.config: Default resource configuration to be used for the queue. Use handlebars (eg.{{var}}) to specify template variables.template_variables: A dictionary of template variable schemas to use with the config.
method create_team
Arguments
team: The name of the teamadmin_username: Username of the admin user of the team. Defaults to the current user.
method create_user
Arguments
email: The email address of the user.admin: Set user as a global instance administrator.
method delete_automation
Arguments
obj: The automation to delete, or its ID.
method flush
api.flush() to get the latest values associated with the run.
method from_path
Arguments
path: The path to the project, run, sweep or report
Examples
In the proceeding code snippets “project”, “team”, “run_id”, “sweep_id”, and “report_name” are placeholders for the project, team, run ID, sweep ID, and the name of a specific report, respectively.method integrations
Arguments
entity: The entity (e.g. team name) for which to fetch integrations. If not provided, the user’s default entity will be used.per_page: Number of integrations to fetch per page. Defaults to 50. Usually there is no reason to change this.start:
method job
Job object.
Arguments
name: The name of the job.path: The root path to download the job artifact.
method list_jobs
Arguments
entity: The entity for the listed jobs.project: The project for the listed jobs.
method project
Project with the given name (and entity, if given).
Arguments
name: The project name.entity: Name of the entity requested. If None, will fall back to the default entity passed toApi. If no default entity, will raise aValueError.
method projects
Arguments
entity: Name of the entity requested. If None, will fall back to the default entity passed toApi. If no default entity, will raise aValueError.per_page: Sets the page size for query pagination. Usually there is no reason to change this.
method queued_run
entity/project/queue_id/run_queue_item_id.
Arguments
entity:project:queue_name:run_queue_item_id:project_queue:priority:
method registries
Registry objects.
Use the iterator to search and filter registries, collections,
or artifact versions across your organization’s registry.
Arguments
organization: The organization of the registry to fetch. If not specified, use the organization specified in the user’s settings.filter: Optional MongoDB-style filter to apply to each object in the lazy registry iterator. Fields available to filter for registries arename,description,created_at,updated_at. Fields available to filter for collections arename,tag,description,created_at,updated_atFields available to filter for versions aretag,alias,created_at,updated_at,metadataorder: Optional string to specify the order of the results. If prefixed with ’+’, sorts ascending (default). If prefixed with ’-’, sorts descending.per_page: Sets the page size for query pagination.start: Pagination cursor for resuming a past query, captured from a previous paginator’s.cursorattribute.
Examples
Find all registries with the names that contain “model”.cursor and passing it as start=:
method registry
Arguments
name: The name of the registry. This is without thewandb-registry-prefix.organization: The organization of the registry. If no organization is set in the settings, the organization will be fetched from the entity if the entity only belongs to one organization.
Examples
Fetch and update a registrymethod reports
wandb.Api.reports() API is in beta and will likely change in
future releases.
Arguments
path: The path to the project the report resides in. Specify the entity that created the project as a prefix followed by a forward slash.name: Name of the report requested.per_page: Sets the page size for query pagination. Usually there is no reason to change this.
Examples
method run
entity/project/run_id.
Arguments
path: Path to run in the formentity/project/run_id. Ifapi.entityis set, this can be in the formproject/run_idand ifapi.projectis set this can just be the run_id.
method run_queue
RunQueue for entity.
See Api.create_run_queue for more information on how to create a run queue.
Arguments
entity:name:
method runs
Runs object, which lazily iterates over Run objects.
Fields you can filter by include:
createdAt: The timestamp when the run was created. (in ISO 8601 format, e.g. “2023-01-01T12:00:00Z”)displayName: The human-readable display name of the run. (e.g. “eager-fox-1”)duration: The total runtime of the run in seconds.group: The group name used to organize related runs together.host: The hostname where the run was executed.jobType: The type of job or purpose of the run.name: The unique identifier of the run. (e.g. “a1b2cdef”)state: The current state of the run.tags: The tags associated with the run.username: The username of the user who initiated the run
config.experiment_name, summary_metrics.loss, etc.
For more complex filtering, you can use MongoDB query operators.
For details, see: https://docs.mongodb.com/manual/reference/operator/query
The following operations are supported:
$and$or$nor$eq$ne$gt$gte$lt$lte$in$nin$exists$regex
Arguments
path: (str) path to project, should be in the form: “entity/project”filters: (dict) queries for specific runs using the MongoDB query language. You can filter by run properties such as config.key, summary_metrics.key, state, entity, createdAt, etc.order: (str) Order can becreated_at,heartbeat_at,config.*.value, orsummary_metrics.*. If you prepend order with a + order is ascending (default). If you prepend order with a - order is descending. The default order is run.created_at from oldest to newest.per_page: (int) Sets the page size for query pagination.include_sweeps: (bool) Whether to eagerly fetch the sweep object in each run result.lazy: (bool) Whether to use lazy loading for faster performance. When True (default), only essential run metadata is loaded initially. Heavy fields like config, summaryMetrics, and systemMetrics are loaded on-demand when accessed. Set to False for full data upfront.
Examples
method slack_integrations
Arguments
entity: The entity (e.g. team name) for which to fetch integrations. If not provided, the user’s default entity will be used.per_page: Number of integrations to fetch per page. Defaults to 50. Usually there is no reason to change this.start:
Examples
Get all registered Slack integrations for the team “my-team”:method sweep
entity/project/sweep_id.
Arguments
path: Path to sweep in the form entity/project/sweep_id. Ifapi.entityis set, this can be in the form project/sweep_id and ifapi.projectis set this can just be the sweep_id.
method sync_tensorboard
Arguments
root_dir:run_id:project:entity:
method team
Team with the given name.
Arguments
team: The name of the team.
method update_automation
Arguments
obj: The automation to update. Must be an existing automation.create_missing: If True, and the automation does not exist, create it.kwargs:
Examples
Disable and edit the description of an existing automation (“my-automation”):method upsert_run_queue
Arguments
name: Name of the queue to createresource_config: Optional default resource configuration to be used for the queue. Use handlebars (eg.{{var}}) to specify template variables.resource_type: Type of resource to be used for the queue. One of “local-container”, “local-process”, “kubernetes”, “sagemaker”, or “gcp-vertex”.entity: Optional name of the entity to create the queue. IfNone, use the configured or default entity.template_variables: A dictionary of template variable schemas to be used with the config.external_links: Optional dictionary of external links to be used with the queue.prioritization_mode: Optional version of prioritization to use. Either “V0” or None
method user
api.viewer
to get your own user object.
Arguments
username_or_email: The username or email address of the user.
method users
api.viewer
to get your own user object.
Arguments
username_or_email: The prefix or suffix of the user you want to find.
method webhook_integrations
Arguments
entity: The entity (e.g. team name) for which to fetch integrations. If not provided, the user’s default entity will be used.per_page: Number of integrations to fetch per page. Defaults to 50. Usually there is no reason to change this.start: