Aim SDK

aim.sdk.repo module

class aim.sdk.repo.Repo(path, *, read_only=None, init=False)[source]

Aim repository object.

Provides methods for repositories creation/opening/cleanup. Provides APIs for accessing Runs. Provides API for querying Runs/Metrics based on a given expression.

Parameters
  • path (str) – Path to Aim repository.

  • read_only (bool, optional) – Flag for opening Repo in readonly mode. False by default.

  • init (bool, optional) – Flag used to initialize new Repo. False by default. Recommended to use aim init command instead.

collect_metrics_info()[source]

Utility function for getting metric names and contexts for all runs.

Returns

Tree of metrics and their contexts.

Return type

dict

collect_params_info()[source]

Utility function for getting run meta-parameters.

Returns

All runs meta-parameters.

Return type

dict

classmethod default_repo(init=False)[source]

Named constructor for default repository.

Searches nearest .aim directory from current directory to roo directory. If not found, return Repo for current directory.

Parameters

init (bool, optional) – Flag used to initialize new Repo. False by default. Recommended to use aim init command instead.

Returns

Repo object.

classmethod exists(path)[source]

Check Aim repository existence.

Parameters

path (str) – Path to Aim repository.

Returns

True if repository exists, False otherwise.

classmethod from_path(path, read_only=None, init=False)[source]

Named constructor for Repo for given path.

Parameters
  • path (str) – Path to Aim repository.

  • read_only (bool, optional) – Flag for opening Repo in readonly mode. False by default.

  • init (bool, optional) – Flag used to initialize new Repo. False by default. Recommended to use aim init command instead.

Returns

Repo object.

get_run(run_hash)[source]

Get run if exists.

Parameters

run_hash (str) – Run hash.

Returns

Run object if hash is found in repository. None otherwise.

iter_runs()[source]

Iterate over Repo runs.

Yields

next Run in readonly mode .

query_metrics(query='')[source]

Get metrics satisfying query expression.

Parameters

query (str) – query expression.

Returns

Iterable for metrics matching query expression.

Return type

MetricCollection

query_runs(query='', paginated=False, offset=None)[source]

Get runs satisfying query expression.

Parameters
  • query (str, optional) – query expression. If not specified, query results will include all runs.

  • paginated (bool, optional) – query results pagination flag. False if not specified.

  • offset (str, optional) – hash of Run to skip to.

Returns

Iterable for runs/metrics matching query expression.

Return type

MetricCollection

classmethod rm(path)[source]

Remove Aim repository.

Parameters

path (str) – Path to Aim repository.

aim.sdk.run module

class aim.sdk.run.Run(run_hash=None, *, repo=None, read_only=False, experiment=None, system_tracking_interval=10)[source]

Run object used for tracking metrics.

Provides method track to track value series [metrics] for multiple metrics and contexts. Provides dictionary-like interface for Run object meta-parameters. Provides API for iterating tracked metrics.

Parameters
  • run_hash (str, optional) – Run’s hash. If skipped, generated automatically.

  • ( (repo) – obj:`Union[Repo,str], optional): Aim repository path or Repo object to which Run object is bound. If skipped, default Repo is used.

  • read_only (bool, optional) – Run creation mode. Default is False, meaning Run object can be used to track metrics.

  • experiment (str, optional) – Sets Run’s experiment property. ‘default’ if not specified. Can be used later to query runs/metrics.

  • system_tracking_interval (int, optional) – Sets the tracking interval in seconds for system usage metrics (CPU, Memory, etc.). Set to None to disable system metrics tracking.

__delitem__(key)[source]

Remove key from run meta-params. :param key: meta-parameter path

__getitem__(key)[source]

Get run meta-parameter by key.

Parameters

key – path to Run meta-parameter.

Returns

Collected sub-tree of Run meta-parameters.

Examples

>>> run = Run('3df703c')
>>> run['hparams']  # -> {'batch_size': 42}
>>> run['hparams', 'batch_size']  # -> 42
__setitem__(key, val)[source]

Set Run top-level meta-parameter.

Parameters
  • key (str) – Top-level meta-parameter name. Use ellipsis to reset run’s all meta-parameters.

  • val – Meta-parameter value.

Examples

>>> run = Run('3df703c')
>>> run[...] = params
>>> run['hparams'] = {'batch_size': 42}
add_tag(value)

Add tag to run

Parameters

value (str) – Tag to add.

collect_metrics_info()[source]

Retrieve Run’s all metrics general overview.

Returns

list of metric’s context, metric_name and last tracked value triplets.

Return type

list

get_metric(metric_name, context)[source]

Retrieve metric sequence by it’s name and context.

Parameters
  • metric_name (str) – Tracked metric name.

  • context (Context) – Tracking context.

Returns

Metric object if exists, None otherwise.

iter_metrics_info()[source]

Iterator for all run metrics info.

Yields

tuples of (metric_name, context, run) where run is the Run object itself.

metrics()[source]

Get iterable object for all run tracked metrics.

Returns

Iterable for run metrics.

Return type

MetricCollection

Examples

>>> run = Run('3df703c')
>>> for metric in run.metrics():
>>>     metric.values.sparse_numpy()
remove_tag(tag_id)

Remove run tag.

Parameters

tag_id (str) – uuid of tag to be removed.

track(value, name, step=None, epoch=None, *, context=None)[source]

Main method for tracking numeric value series.

Parameters
  • value – The tracked value.

  • name (str) – Tracked metric name.

  • step (int, optional) – Metric tracking iteration. Auto-incremented if not specified.

  • epoch (int, optional) – The training epoch.

  • context (dict, optional) – Metric racking context.

Appends the tracked value to metric series specified by name and context.

property archived

Check is run archived or not.

Getter

Returns run’s archived state.

Setter

Archive/un-archive run.

Type

bool

property created_at

Run object creation time [UTC] as datetime.

Getter

Returns run creation time.

property creation_time

Run object creation time [UTC] as timestamp.

Getter

Returns run creation time.

property description

Run description, set by user.

Getter

Returns run’s description.

Setter

Sets run’s description.

Type

string

property end_time

Run finalization time [UTC] as timestamp.

Getter

Returns run finalization time.

property experiment

Run experiment.

Getter

Returns run’s experiment name.

Setter

Sets run’s experiment.

Type

string

property finalized_at

Run finalization time [UTC] as datetime.

Getter

Returns run finalization time.

property name

Run name, set by user.

Getter

Returns run’s name.

Setter

Sets run’s name.

Type

string

property tags

List of run tags.

Getter

Returns run’s tag list.

aim.sdk.metric module

class aim.sdk.metric.Metric(name, context, run)[source]

Class representing series of numeric values.

classmethod allowed_dtypes()[source]

classmethod to get allowed object types for particular sequence

For example, numeric sequences a.k.a. Metric allow float and integer numbers. The base Sequence allows any value, and to indicate that, allowed_dtypes returns ‘*’.

dataframe(include_name=False, include_context=False, include_run=False, only_last=False)[source]

Get metric series as pandas DataFrame

Parameters
  • include_name – (int, optional): If true, include metric name in dataframe. False by default.

  • include_context – (int, optional): If true, include metric context path:value pairs in dataframe. False by default.

  • include_run – (int, optional): If true, include run run.hash and run hparams path:value pairs in dataframe. False by default.

  • only_last – (int, optional): If true return dataframe for only last value, step, timestamp and epoch. False by default.