description |
---|
wandb.apis.public |
Api(self, overrides={})
Used for querying the wandb server.
Examples:
Most common way to initialize
wandb.Api()
Arguments:
overrides
dict - You can setbase_url
if you are using a wandb server other than https://api.wandb.ai. You can also set defaults forentity
,project
, andrun
.
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(self, entity=None, per_page=200)
Get projects for a given entity.
Arguments:
entity
str - Name of the entity requested. If None will fallback to default entity passed toApi
. If no default entity, will raise aValueError
.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(self, path='', name=None, per_page=50)
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(self, path='', filters={}, order='-created_at', per_page=50)
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/queryorder
str - Order can becreated_at
,heartbeat_at
,config.*.value
, orsummary.*
. 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(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(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(self, client, entity, per_page=50)
An iterable collection of Project
objects.
Project(self, entity, project, attrs)
A project is a namespace for runs
Runs(self, client, entity, project, filters={}, order=None, per_page=50)
An iterable collection of runs associated with a project and optional filter. This is generally used indirectly via the Api
.runs method
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 runurl
str - the url of this runid
str - unique identifier for the run (defaults to eight characters)name
str - the name of the runstate
str - one of: running, finished, crashed, abortedconfig
dict - a dict of hyperparameters associated with the runcreated_at
str - ISO timestamp when the run was startedsystem_metrics
dict - the latest system metrics recorded for the runsummary
dict - A mutable dict-like property that holds the current summary. Calling update will persist any changes.project
str - the project associated with the runentity
str - the name of the entity associated with the runuser
str - the name of the user who created the runpath
str - Unique identifier [entity]/[project]/[run_id]notes
str - Notes about the runread_only
boolean - Whether the run is editablehistory_keys
str - Keys of the history metrics that have been logged withwandb.log({key: value})
Run.create(api, run_id=None, project=None, entity=None)
Create a run for the given project
Run.update(self)
Persists changes to the run object to the wandb backend.
Run.files(self, names=[], per_page=50)
Arguments:
names
list - names of the requested files, if empty returns all filesper_page
int - number of results per page
Returns:
A Files
object, which is an iterator over File
obejcts.
Run.file(self, name)
Arguments:
name
str - name of requested file.
Returns:
A File
matching the name argument.
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 returnpandas
bool, optional - Return a pandas dataframekeys
list, optional - Only return metrics for specific keysx_axis
str, optional - Use this metric as the xAxis defaults to _stepstream
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(self, keys=None, page_size=1000, min_step=None, max_step=None)
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(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 runsid
str - sweep idproject
str - name of projectconfig
str - dictionary of sweep configuration
Sweep.best_run(self, order=None)
Returns the best run sorted by the metric defined in config or the order passed in
Sweep.get(client,
entity=None,
project=None,
sid=None,
withRuns=True,
order=None,
query=None,
**kwargs)
Execute a query against the cloud backend
Files(self, client, run, names=[], per_page=50, upload=False)
Files is an iterable collection of File
objects.
File(self, client, attrs)
File is a class associated with a file saved by wandb.
Attributes:
name
string - filenameurl
string - path to filemd5
string - md5 of filemimetype
string - mimetype of fileupdated_at
string - timestamp of last updatesize
int - size of file in bytes
File.download(self, replace=False, root='.')
Downloads a file previously saved by a run from the wandb server.
Arguments:
replace
boolean - IfTrue
, download will overwrite a local file if it exists. Defaults toFalse
.root
str - Local directory to save the file. Defaults to ".".
Raises:
ValueError
if file already exists and replace=False
Reports(self, client, project, name=None, entity=None, per_page=50)
Reports is an iterable collection of BetaReport
objects.
QueryGenerator(self)
QueryGenerator is a helper object to write filters for runs
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)
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(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 namedescription
string - report descirpiton;user
User - the user that created the reportspec
dict - the spec off the report;updated_at
string - timestamp of last update