X Tutup
Skip to content

Latest commit

 

History

History
2647 lines (1771 loc) · 67.7 KB

File metadata and controls

2647 lines (1771 loc) · 67.7 KB
title
API Documentation

wandb.apis.public

[view_source]

PY3

[view_source]

logger

[view_source]

RETRY_TIMEDELTA

[view_source]

WANDB_INTERNAL_KEYS

[view_source]

PROJECT_FRAGMENT

[view_source]

RUN_FRAGMENT

[view_source]

FILE_FRAGMENT

[view_source]

ARTIFACTS_TYPES_FRAGMENT

[view_source]

ARTIFACT_FRAGMENT

[view_source]

ARTIFACT_FILES_FRAGMENT

[view_source]

RetryingClient Objects

class RetryingClient(object)

[view_source]

__init__

 | __init__(client)

[view_source]

app_url

 | @property
 | app_url()

[view_source]

execute

 | @retriable(
 |         retry_timedelta=RETRY_TIMEDELTA,
 |         check_retry_fn=util.no_retry_auth,
 |         retryable_exceptions=(RetryError, requests.RequestException),
 |     )
 | execute(*args, **kwargs)

[view_source]

Api Objects

class Api(object)

[view_source]

Used for querying the wandb server.

Examples:

Most common way to initialize

wandb.Api()

Arguments:

  • overrides dict - You can set base_url if you are using a wandb server other than https://api.wandb.ai. You can also set defaults for entity, project, and run.

VIEWER_QUERY

[view_source]

__init__

 | __init__(overrides={})

[view_source]

create_run

 | create_run(**kwargs)

[view_source]

client

 | @property
 | client()

[view_source]

user_agent

 | @property
 | user_agent()

[view_source]

api_key

 | @property
 | api_key()

[view_source]

default_entity

 | @property
 | default_entity()

[view_source]

flush

 | flush()

[view_source]

The api object keeps a local cache of runs, so if the state of the run may change while executing your script you must clear the local cache with api.flush() to get the latest values associated with the run.

projects

 | projects(entity=None, per_page=200)

[view_source]

Get projects for a given entity.

Arguments:

  • entity str - Name of the entity requested. If None will fallback to default entity passed to Api. If no default entity, will raise a ValueError.
  • per_page int - Sets the page size for query pagination. None will use the default size. Usually there is no reason to change this.

Returns:

A Projects object which is an iterable collection of Project objects.

reports

 | reports(path="", name=None, per_page=50)

[view_source]

Get reports for a given project path.

WARNING: This api is in beta and will likely change in a future release

Arguments:

  • path str - path to project the report resides in, should be in the form: "entity/project"
  • name str - optional name of the report requested.
  • per_page int - Sets the page size for query pagination. None will use the default size. Usually there is no reason to change this.

Returns:

A Reports object which is an iterable collection of BetaReport objects.

runs

 | runs(path="", filters={}, order="-created_at", per_page=50)

[view_source]

Return a set of runs from a project that match the filters provided. You can filter by config.*, summary.*, state, entity, createdAt, etc.

Examples:

Find runs in my_project config.experiment_name has been set to "foo"

api.runs(path="my_entity/my_project", {"config.experiment_name": "foo"})

Find runs in my_project config.experiment_name has been set to "foo" or "bar"

api.runs(path="my_entity/my_project",
- `{"$or"` - [{"config.experiment_name": "foo"}, {"config.experiment_name": "bar"}]})

Find runs in my_project sorted by ascending loss

api.runs(path="my_entity/my_project", {"order": "+summary_metrics.loss"})

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. For example: {"config.experiment_name": "foo"} would find runs with a config entry of experiment name set to "foo" You can compose operations to make more complicated queries, see Reference for the language is at https://docs.mongodb.com/manual/reference/operator/query
  • order str - Order can be created_at, heartbeat_at, config.*.value, or summary_metrics.*. If you prepend order with a + order is ascending. If you prepend order with a - order is descending (default). The default order is run.created_at from newest to oldest.

Returns:

A Runs object, which is an iterable collection of Run objects.

run

 | @normalize_exceptions
 | run(path="")

[view_source]

Returns a single run by parsing path in the form entity/project/run_id.

Arguments:

  • path str - path to run in the form entity/project/run_id. If api.entity is set, this can be in the form project/run_id and if api.project is set this can just be the run_id.

Returns:

A Run object.

sweep

 | @normalize_exceptions
 | sweep(path="")

[view_source]

Returns a sweep by parsing path in the form entity/project/sweep_id.

Arguments:

  • path str, optional - path to sweep in the form entity/project/sweep_id. If api.entity is set, this can be in the form project/sweep_id and if api.project is set this can just be the sweep_id.

Returns:

A Sweep object.

artifact_types

 | @normalize_exceptions
 | artifact_types(project=None)

[view_source]

artifact_type

 | @normalize_exceptions
 | artifact_type(type_name, project=None)

[view_source]

artifact_versions

 | @normalize_exceptions
 | artifact_versions(type_name, name, per_page=50)

[view_source]

artifact

 | @normalize_exceptions
 | artifact(name, type=None)

[view_source]

Returns a single artifact by parsing path in the form entity/project/run_id.

Arguments:

  • name str - An artifact name. May be prefixed with entity/project. Valid names can be in the following forms: name:version name:alias digest
  • type str, optional - The type of artifact to fetch.

Returns:

A Artifact object.

artifact_from_id

 | artifact_from_id(id)

[view_source]

Attrs Objects

class Attrs(object)

[view_source]

__init__

 | __init__(attrs)

[view_source]

snake_to_camel

 | snake_to_camel(string)

[view_source]

__getattr__

 | __getattr__(name)

[view_source]

Paginator Objects

class Paginator(object)

[view_source]

QUERY

[view_source]

__init__

 | __init__(client, variables, per_page=None)

[view_source]

__iter__

 | __iter__()

[view_source]

__len__

 | __len__()

[view_source]

length

 | @property
 | length()

[view_source]

more

 | @property
 | more()

[view_source]

cursor

 | @property
 | cursor()

[view_source]

convert_objects

 | convert_objects()

[view_source]

update_variables

 | update_variables()

[view_source]

__getitem__

 | __getitem__(index)

[view_source]

__next__

 | __next__()

[view_source]

next

[view_source]

User Objects

class User(Attrs)

[view_source]

init

 | init(attrs)

[view_source]

Projects Objects

class Projects(Paginator)

[view_source]

An iterable collection of Project objects.

QUERY

[view_source]

__init__

 | __init__(client, entity, per_page=50)

[view_source]

length

 | @property
 | length()

[view_source]

more

 | @property
 | more()

[view_source]

cursor

 | @property
 | cursor()

[view_source]

convert_objects

 | convert_objects()

[view_source]

__repr__

 | __repr__()

[view_source]

Project Objects

class Project(Attrs)

[view_source]

A project is a namespace for runs

__init__

 | __init__(client, entity, project, attrs)

[view_source]

path

 | @property
 | path()

[view_source]

__repr__

 | __repr__()

[view_source]

artifacts_types

 | @normalize_exceptions
 | artifacts_types(per_page=50)

[view_source]

Runs Objects

class Runs(Paginator)

[view_source]

An iterable collection of runs associated with a project and optional filter. This is generally used indirectly via the Api.runs method

QUERY

[view_source]

__init__

 | __init__(client, entity, project, filters={}, order=None, per_page=50)

[view_source]

length

 | @property
 | length()

[view_source]

more

 | @property
 | more()

[view_source]

cursor

 | @property
 | cursor()

[view_source]

convert_objects

 | convert_objects()

[view_source]

__repr__

 | __repr__()

[view_source]

Run Objects

class Run(Attrs)

[view_source]

A single run associated with an entity and project.

Attributes:

  • tags [str] - a list of tags associated with the run
  • url str - the url of this run
  • id str - unique identifier for the run (defaults to eight characters)
  • name str - the name of the run
  • state str - one of: running, finished, crashed, aborted
  • config dict - a dict of hyperparameters associated with the run
  • created_at str - ISO timestamp when the run was started
  • system_metrics dict - the latest system metrics recorded for the run
  • summary dict - A mutable dict-like property that holds the current summary. Calling update will persist any changes.
  • project str - the project associated with the run
  • entity str - the name of the entity associated with the run
  • user str - the name of the user who created the run
  • path str - Unique identifier [entity]/[project]/[run_id]
  • notes str - Notes about the run
  • read_only boolean - Whether the run is editable
  • history_keys str - Keys of the history metrics that have been logged with wandb.log({key: value})

__init__

 | __init__(client, entity, project, run_id, attrs={})

[view_source]

Run is always initialized by calling api.runs() where api is an instance of wandb.Api

entity

 | @property
 | entity()

[view_source]

username

 | @property
 | username()

[view_source]

storage_id

 | @property
 | storage_id()

[view_source]

id

 | @property
 | id()

[view_source]

id

 | @id.setter
 | id(new_id)

[view_source]

name

 | @property
 | name()

[view_source]

name

 | @name.setter
 | name(new_name)

[view_source]

create

 | @classmethod
 | create(cls, api, run_id=None, project=None, entity=None)

[view_source]

Create a run for the given project

load

 | load(force=False)

[view_source]

update

 | @normalize_exceptions
 | update()

[view_source]

Persists changes to the run object to the wandb backend.

save

 | save()

[view_source]

json_config

 | @property
 | json_config()

[view_source]

files

 | @normalize_exceptions
 | files(names=[], per_page=50)

[view_source]

Arguments:

  • names list - names of the requested files, if empty returns all files
  • per_page int - number of results per page

Returns:

A Files object, which is an iterator over File obejcts.

file

 | @normalize_exceptions
 | file(name)

[view_source]

Arguments:

  • name str - name of requested file.

Returns:

A File matching the name argument.

upload_file

 | @normalize_exceptions
 | upload_file(path, root=".")

[view_source]

Arguments:

  • path str - name of file to upload.
  • root str - the root path to save the file relative to. i.e. If you want to have the file saved in the run as "my_dir/file.txt" and you're currently in "my_dir" you would set root to "../"

Returns:

A File matching the name argument.

history

 | @normalize_exceptions
 | history(samples=500, keys=None, x_axis="_step", pandas=True, stream="default")

[view_source]

Returns sampled history metrics for a run. This is simpler and faster if you are ok with the history records being sampled.

Arguments:

  • samples int, optional - The number of samples to return
  • pandas bool, optional - Return a pandas dataframe
  • keys list, optional - Only return metrics for specific keys
  • x_axis str, optional - Use this metric as the xAxis defaults to _step
  • stream str, optional - "default" for metrics, "system" for machine metrics

Returns:

If pandas=True returns a pandas.DataFrame of history metrics. If pandas=False returns a list of dicts of history metrics.

scan_history

 | @normalize_exceptions
 | scan_history(keys=None, page_size=1000, min_step=None, max_step=None)

[view_source]

Returns an iterable collection of all history records for a run.

Example:

Export all the loss values for an example run

run = api.run("l2k2/examples-numpy-boston/i0wt6xua")
history = run.scan_history(keys=["Loss"])
losses = [row["Loss"] for row in history]

Arguments:

  • keys [str], optional - only fetch these keys, and only fetch rows that have all of keys defined.
  • page_size int, optional - size of pages to fetch from the api

Returns:

An iterable collection over history records (dict).

logged_artifacts

 | @normalize_exceptions
 | logged_artifacts(per_page=100)

[view_source]

used_artifacts

 | @normalize_exceptions
 | used_artifacts(per_page=100)

[view_source]

use_artifact

 | @normalize_exceptions
 | use_artifact(artifact)

[view_source]

Declare an artifact as an input to a run.

Arguments:

  • artifact Artifact - An artifact returned from wandb.Api().artifact(name)

Returns:

A Artifact object.

log_artifact

 | @normalize_exceptions
 | log_artifact(artifact, aliases=None)

[view_source]

Declare an artifact as output of a run.

Arguments:

  • artifact Artifact - An artifact returned from wandb.Api().artifact(name)
  • aliases list, optional - Aliases to apply to this artifact

Returns:

A Artifact object.

summary

 | @property
 | summary()

[view_source]

path

 | @property
 | path()

[view_source]

url

 | @property
 | url()

[view_source]

lastHistoryStep

 | @property
 | lastHistoryStep()

[view_source]

__repr__

 | __repr__()

[view_source]

Sweep Objects

class Sweep(Attrs)

[view_source]

A set of runs associated with a sweep Instantiate with: api.sweep(sweep_path)

Attributes:

  • runs Runs - list of runs
  • id str - sweep id
  • project str - name of project
  • config str - dictionary of sweep configuration

QUERY

[view_source]

__init__

 | __init__(client, entity, project, sweep_id, attrs={})

[view_source]

entity

 | @property
 | entity()

[view_source]

username

 | @property
 | username()

[view_source]

config

 | @property
 | config()

[view_source]

load

 | load(force=False)

[view_source]

order

 | @property
 | order()

[view_source]

best_run

 | best_run(order=None)

[view_source]

Returns the best run sorted by the metric defined in config or the order passed in

path

 | @property
 | path()

[view_source]

url

 | @property
 | url()

[view_source]

get

 | @classmethod
 | get(cls, client, entity=None, project=None, sid=None, withRuns=True, order=None, query=None, **kwargs)

[view_source]

Execute a query against the cloud backend

__repr__

 | __repr__()

[view_source]

Files Objects

class Files(Paginator)

[view_source]

Files is an iterable collection of File objects.

QUERY

[view_source]

__init__

 | __init__(client, run, names=[], per_page=50, upload=False)

[view_source]

length

 | @property
 | length()

[view_source]

more

 | @property
 | more()

[view_source]

cursor

 | @property
 | cursor()

[view_source]

update_variables

 | update_variables()

[view_source]

convert_objects

 | convert_objects()

[view_source]

__repr__

 | __repr__()

[view_source]

File Objects

class File(object)

[view_source]

File is a class associated with a file saved by wandb.

Attributes:

  • name string - filename
  • url string - path to file
  • md5 string - md5 of file
  • mimetype string - mimetype of file
  • updated_at string - timestamp of last update
  • size int - size of file in bytes

__init__

 | __init__(client, attrs)

[view_source]

name

 | @property
 | name()

[view_source]

url

 | @property
 | url()

[view_source]

md5

 | @property
 | md5()

[view_source]

digest

 | @property
 | digest()

[view_source]

mimetype

 | @property
 | mimetype()

[view_source]

updated_at

 | @property
 | updated_at()

[view_source]

size

 | @property
 | size()

[view_source]

download

 | @normalize_exceptions
 | @retriable(
 |         retry_timedelta=RETRY_TIMEDELTA,
 |         check_retry_fn=util.no_retry_auth,
 |         retryable_exceptions=(RetryError, requests.RequestException),
 |     )
 | download(root=".", replace=False)

[view_source]

Downloads a file previously saved by a run from the wandb server.

Arguments:

  • replace boolean - If True, download will overwrite a local file if it exists. Defaults to False.
  • root str - Local directory to save the file. Defaults to ".".

Raises:

ValueError if file already exists and replace=False

__repr__

 | __repr__()

[view_source]

Reports Objects

class Reports(Paginator)

[view_source]

Reports is an iterable collection of BetaReport objects.

QUERY

[view_source]

__init__

 | __init__(client, project, name=None, entity=None, per_page=50)

[view_source]

length

 | @property
 | length()

[view_source]

more

 | @property
 | more()

[view_source]

cursor

 | @property
 | cursor()

[view_source]

update_variables

 | update_variables()

[view_source]

convert_objects

 | convert_objects()

[view_source]

__repr__

 | __repr__()

[view_source]

QueryGenerator Objects

class QueryGenerator(object)

[view_source]

QueryGenerator is a helper object to write filters for runs

INDIVIDUAL_OP_TO_MONGO

[view_source]

GROUP_OP_TO_MONGO

[view_source]

__init__

 | __init__()

[view_source]

format_order_key

 | @classmethod
 | format_order_key(cls, key)

[view_source]

key_to_server_path

 | key_to_server_path(key)

[view_source]

filter_to_mongo

 | filter_to_mongo(filter)

[view_source]

BetaReport Objects

class BetaReport(Attrs)

[view_source]

BetaReport is a class associated with reports created in wandb.

WARNING: this API will likely change in a future release

Attributes:

  • name string - report name
  • description string - report descirpiton;
  • user User - the user that created the report
  • spec dict - the spec off the report;
  • updated_at string - timestamp of last update

__init__

 | __init__(client, attrs, entity=None, project=None)

[view_source]

sections

 | @property
 | sections()

[view_source]

runs

 | runs(section, per_page=50, only_selected=True)

[view_source]

updated_at

 | @property
 | updated_at()

[view_source]

HistoryScan Objects

class HistoryScan(object)

[view_source]

QUERY

[view_source]

__init__

 | __init__(client, run, min_step, max_step, page_size=1000)

[view_source]

__iter__

 | __iter__()

[view_source]

__next__

 | __next__()

[view_source]

next

[view_source]

SampledHistoryScan Objects

class SampledHistoryScan(object)

[view_source]

QUERY

[view_source]

__init__

 | __init__(client, run, keys, min_step, max_step, page_size=1000)

[view_source]

__iter__

 | __iter__()

[view_source]

__next__

 | __next__()

[view_source]

next

[view_source]

ProjectArtifactTypes Objects

class ProjectArtifactTypes(Paginator)

[view_source]

QUERY

[view_source]

__init__

 | __init__(client, entity, project, name=None, per_page=50)

[view_source]

length

 | @property
 | length()

[view_source]

more

 | @property
 | more()

[view_source]

cursor

 | @property
 | cursor()

[view_source]

update_variables

 | update_variables()

[view_source]

convert_objects

 | convert_objects()

[view_source]

ProjectArtifactCollections Objects

class ProjectArtifactCollections(Paginator)

[view_source]

QUERY

[view_source]

__init__

 | __init__(client, entity, project, type_name, per_page=50)

[view_source]

length

 | @property
 | length()

[view_source]

more

 | @property
 | more()

[view_source]

cursor

 | @property
 | cursor()

[view_source]

update_variables

 | update_variables()

[view_source]

convert_objects

 | convert_objects()

[view_source]

RunArtifacts Objects

class RunArtifacts(Paginator)

[view_source]

OUTPUT_QUERY

[view_source]

INPUT_QUERY

[view_source]

__init__

 | __init__(client, run, mode="logged", per_page=50)

[view_source]

length

 | @property
 | length()

[view_source]

more

 | @property
 | more()

[view_source]

cursor

 | @property
 | cursor()

[view_source]

update_variables

 | update_variables()

[view_source]

convert_objects

 | convert_objects()

[view_source]

ArtifactType Objects

class ArtifactType(object)

[view_source]

__init__

 | __init__(client, entity, project, type_name, attrs=None)

[view_source]

load

 | load()

[view_source]

id

 | @property
 | id()

[view_source]

name

 | @property
 | name()

[view_source]

collections

 | @normalize_exceptions
 | collections(per_page=50)

[view_source]

Artifact collections

collection

 | collection(name)

[view_source]

__repr__

 | __repr__()

[view_source]

ArtifactCollection Objects

class ArtifactCollection(object)

[view_source]

__init__

 | __init__(client, entity, project, name, type, attrs=None)

[view_source]

id

 | @property
 | id()

[view_source]

versions

 | @normalize_exceptions
 | versions(per_page=50)

[view_source]

Artifact versions

__repr__

 | __repr__()

[view_source]

Artifact Objects

class Artifact(object)

[view_source]

QUERY

[view_source]

from_id

 | @classmethod
 | from_id(cls, client, id)

[view_source]

__init__

 | __init__(client, entity, project, name, attrs=None)

[view_source]

id

 | @property
 | id()

[view_source]

metadata

 | @property
 | metadata()

[view_source]

metadata

 | @metadata.setter
 | metadata(metadata)

[view_source]

manifest

 | @property
 | manifest()

[view_source]

digest

 | @property
 | digest()

[view_source]

state

 | @property
 | state()

[view_source]

size

 | @property
 | size()

[view_source]

created_at

 | @property
 | created_at()

[view_source]

updated_at

 | @property
 | updated_at()

[view_source]

description

 | @property
 | description()

[view_source]

description

 | @description.setter
 | description(desc)

[view_source]

type

 | @property
 | type()

[view_source]

name

 | @property
 | name()

[view_source]

aliases

 | @property
 | aliases()

[view_source]

aliases

 | @aliases.setter
 | aliases(aliases)

[view_source]

delete

 | delete()

[view_source]

Delete artifact and it's files.

new_file

 | new_file(name, mode=None)

[view_source]

add_file

 | add_file(path, name=None)

[view_source]

add_dir

 | add_dir(path, name=None)

[view_source]

add_reference

 | add_reference(path, name=None)

[view_source]

get_path

 | get_path(name)

[view_source]

get

 | get(name)

[view_source]

Returns the wandb.Media resource stored in the artifact. Media can be stored in the artifact via Artifact#add(obj: wandbMedia, name: str)`

Arguments:

  • name str - name of resource.

Returns:

A wandb.Media which has been stored at name

download

 | download(root=None)

[view_source]

Download the artifact to dir specified by the

Arguments:

  • root str, optional - directory to download artifact to. If None artifact will be downloaded to './artifacts/<self.name>/'

Returns:

The path to the downloaded contents.

file

 | file(root=None)

[view_source]

Download a single file artifact to dir specified by the

Arguments:

  • root str, optional - directory to download artifact to. If None artifact will be downloaded to './artifacts/<self.name>/'

Returns:

The full path of the downloaded file

save

 | @normalize_exceptions
 | save()

[view_source]

Persists artifact changes to the wandb backend.

verify

 | verify(root=None)

[view_source]

Verify an artifact by checksumming its downloaded contents.

Raises a ValueError if the verification fails. Does not verify downloaded reference files.

Arguments:

  • root str, optional - directory to download artifact to. If None artifact will be downloaded to './artifacts/<self.name>/'

__repr__

 | __repr__()

[view_source]

ArtifactVersions Objects

class ArtifactVersions(Paginator)

[view_source]

An iterable collection of artifact versions associated with a project and optional filter. This is generally used indirectly via the Api.artifact_versions method

QUERY

[view_source]

__init__

 | __init__(client, entity, project, collection_name, type, filters={}, order=None, per_page=50)

[view_source]

length

 | @property
 | length()

[view_source]

more

 | @property
 | more()

[view_source]

cursor

 | @property
 | cursor()

[view_source]

convert_objects

 | convert_objects()

[view_source]

ArtifactFiles Objects

class ArtifactFiles(Paginator)

[view_source]

QUERY

[view_source]

__init__

 | __init__(client, artifact, names=None, per_page=50)

[view_source]

length

 | @property
 | length()

[view_source]

more

 | @property
 | more()

[view_source]

cursor

 | @property
 | cursor()

[view_source]

update_variables

 | update_variables()

[view_source]

convert_objects

 | convert_objects()

[view_source]

__repr__

 | __repr__()

[view_source]

X Tutup