API Reference

wandb.apis.public

source

Api

source

Api(self, overrides={})

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.

Api.flush

source

Api.flush(self)

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.

Api.projects

source

Api.projects(self, entity=None, per_page=None)

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.

Api.reports

source

Api.reports(self, path='', name=None, per_page=None)

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.

Api.runs

source

Api.runs(self, path='', filters={}, order='-created_at', per_page=None)

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.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.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.*. 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.

Api.run

source

Api.run(self, path='')

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.

Api.sweep

source

Api.sweep(self, path='')

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.

Projects

source

Projects(self, client, entity, per_page=50)

An iterable collection of Project objects.

Project

source

Project(self, entity, project, attrs)

A project is a namespace for runs

Runs

source

Runs(self, client, entity, project, filters={}, order=None, per_page=50)

An iterable collection of runs associated with a project and optional filter.

Run

source

Run(self, client, entity, project, run_id, attrs={})

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})

Run.create

source

Run.create(api, run_id=None, project=None, entity=None)

Create a run for the given project

Run.update

source

Run.update(self)

Persists changes to the run object to the wandb backend.

Run.files

source

Run.files(self, names=[], per_page=50)

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.

Run.file

source

Run.file(self, name)

Arguments:

  • name str - name of requested file.

Returns:

A File matching the name argument.

Run.history

source

Run.history(self,
samples=500,
keys=None,
x_axis='_step',
pandas=True,
stream='default')

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.

Run.scan_history

source

Run.scan_history(self, keys=None, page_size=1000)

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

Examples:

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).

Sweep

source

Sweep(self, client, entity, project, sweep_id, attrs={})

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

Sweep.best_run

source

Sweep.best_run(self, order=None)

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

Sweep.get

source

Sweep.get(client,
entity=None,
project=None,
sid=None,
withRuns=True,
order=None,
query=None,
**kwargs)

Execute a query against the cloud backend

Files

source

Files(self, client, run, names=[], per_page=50, upload=False)

Files is an iterable collection of File objects.

File

source

File(self, client, attrs)

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

File.download

source

File.download(self, replace=False, root='.')

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

Reports

source

Reports(self, client, project, name=None, entity=None, per_page=50)

Reports is an iterable collection of BetaReport objects.

QueryGenerator

source

QueryGenerator(self)

QueryGenerator is a helper object to write filters for runs

QueryGenerator.GROUP_OP_TO_MONGO

dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object's (key, value) pairs dict(iterable) -> new dictionary initialized as if via: d = {} for k, v in iterable: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2)

QueryGenerator.INDIVIDUAL_OP_TO_MONGO

dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object's (key, value) pairs dict(iterable) -> new dictionary initialized as if via: d = {} for k, v in iterable: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2)

BetaReport

source

BetaReport(self, client, attrs, entity=None, project=None)

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