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 useaim init
command instead.
- collect_params_info()[source]
Utility function for getting run meta-parameters.
- Returns
All runs meta-parameters.
- Return type
dict
- collect_sequence_info(sequence_types)[source]
Utility function for getting sequence names and contexts for all runs by given sequence types.
- Parameters
sequence_types (
tuple[str]
, optional) – Sequence types to get tracked sequence names/contexts for.'metric'. (Defaults to) –
- Returns
Tree of sequences and their contexts groupped by sequence type.
- 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 useaim 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.
- query_audios(query='')[source]
Get audio collections satisfying query expression.
- Parameters
query (str) – query expression.
- Returns
Iterable for audio sequences matching query expression.
- Return type
SequenceCollection
- query_distributions(query='')[source]
Get distribution collections satisfying query expression.
- Parameters
query (str) – query expression.
- Returns
Iterable for distribution sequences matching query expression.
- Return type
SequenceCollection
- query_figure_objects(query='')[source]
Get Figures collections satisfying query expression.
- Parameters
query (str) – query expression.
- Returns
Iterable for Figure sequences matching query expression.
- Return type
SequenceCollection
- query_images(query='')[source]
Get image collections satisfying query expression.
- Parameters
query (str) – query expression.
- Returns
Iterable for image sequences matching query expression.
- Return type
SequenceCollection
- 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
SequenceCollection
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 and object series for multiple names and contexts. Provides dictionary-like interface for Run object meta-parameters. Provides API for iterating through tracked sequences.- 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/sequences.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.
- __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_sequence_info(sequence_types, skip_last_value=False)[source]
Retrieve Run’s all sequences general overview.
- Parameters
sequence_types – Type names of sequences for which to collect name/context pairs.
skip_last_value (
bool
, optional) – Boolean flag to include tracked sequence last value indefault. (sequence info. False by) –
- Returns
list of sequence’s context, name and optionally last tracked value triplets.
- Return type
list
- dataframe(include_props=True, include_params=True)[source]
Get run properties and params as pandas DataFrame
- Parameters
include_props – (
int
, optional): If true, include run structured propsinclude_params – (
int
, optional): If true, include run parameters
- get_audio_sequence(name, context)[source]
Retrieve audios sequence by its name and context.
- Parameters
name (str) – Tracked audios sequence name.
context (
Context
) – Tracking context.
- Returns
Audios
object if exists, None otherwise.
- get_distribution_sequence(name, context)[source]
Retrieve distributions sequence by it’s name and context.
- Parameters
name (str) – Tracked distribution sequence name.
context (
Context
) – Tracking context.
- Returns
Distributions
object if exists, None otherwise.
- get_figure_sequence(name, context)[source]
Retrieve figure sequence by its name and context.
- Parameters
name (str) – Tracked figure sequence name.
context (
Context
) – Tracking context.
- Returns
Figures
object if exists, None otherwise.
- get_image_sequence(name, context)[source]
Retrieve images sequence by it’s name and context.
- Parameters
name (str) – Tracked image sequence name.
context (
Context
) – Tracking context.
- Returns
Images
object if exists, None otherwise.
- get_metric(name, context)[source]
Retrieve metric sequence by it’s name and context.
- Parameters
name (str) – Tracked metric name.
context (
Context
) – Tracking context.
- Returns
Metric
object if exists, None otherwise.
- get_text_sequence(name, context)[source]
Retrieve texts sequence by it’s name and context.
- Parameters
name (str) – Tracked text sequence name.
context (
Context
) – Tracking context.
- Returns
Texts
object if exists, None otherwise.
- iter_metrics_info()[source]
Iterator for all run metrics info.
- Yields
tuples of (name, context, run) where run is the Run object itself and name, context defines Metric type sequence (with values of float and int).
- iter_sequence_info_by_type(dtypes)[source]
Iterator for run sequence infos for the given object data types
- Parameters
dtypes – The objects data types list.
- Yields
tuples of (name, context, run) where run is the Run object itself and name, context defines sequence for one of dtypes types.
- 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 and object series.
- Parameters
value – The tracked value.
name (str) – Tracked sequence name.
step (
int
, optional) – Sequence tracking iteration. Auto-incremented if not specified.epoch (
int
, optional) – The training epoch.context (
dict
, optional) – Sequence tracking context.
Appends the tracked value to sequence specified by name and context. Appended values should be of the same type, in other words, sequence is a homogeneous collection.
- 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.objects.image
- class aim.sdk.objects.image.Image(*args, **kwargs)[source]
Image object used to store image objects in Aim repository..
- Parameters
( (image) – obj:): pillow Image object or torch.Tensor or numpy.array used to construct aim.Image.
caption (
str
, optional) – Optional image caption. ‘’ by default.
- property caption
Image caption, set by user.
- Getter
Returns image caption.
- Setter
Sets image caption.
- Type
string
- property format
Stored image format.
- Getter
Returns image format.
- Type
string
- property height
Stored image height.
- Getter
Returns image height.
- Type
string
- property size
Stored image size.
- Getter
Returns image (width, height) pair.
- Type
string
- property width
Stored image width.
- Getter
Returns image width.
- Type
string
aim.sdk.objects.distribution
- class aim.sdk.objects.distribution.Distribution(*args, **kwargs)[source]
Distribution object used to store distribution objects in Aim repository.
- Parameters
( (distribution) – obj:): array-like object used to construct aim.Distribution.
bin_count (
int
, optional) – Optional distribution bin count. 64 by default, max 512.
- property bin_count
Stored distribution bin count
- Getter
Returns distribution bin_count.
- Type
string
- property range
Stored distribution range
- Getter
Returns distribution range.
- Type
List
- property ranges
Stored distribution ranges
- Getter
Returns distribution ranges as np.array.
- Type
np.ndarray
- property weights
Stored distribution weights
- Getter
Returns distribution weights as np.array.
- Type
np.ndarray
aim.sdk.sequence module
- class aim.sdk.sequence.Sequence(name, context, run)[source]
Class representing single series of tracked value.
Objects series can be retrieved as Sequence regardless the object’s type, but subclasses of Sequence might provide additional functionality. Provides interface to access tracked values, steps, timestamps and epochs. Values, epochs and timestamps are accessed via
aim.storage.arrayview.ArrayView
interface.- 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 ‘*’.
- property epochs
Tracked epochs array as
ArrayView
.- Getter
Returns epochs ArrayView.
- property indices
Metric tracking steps as
list
.- Getter
Returns steps list.
- property timestamps
Tracked timestamps array as
ArrayView
.- Getter
Returns timestamps ArrayView.
- property values
Tracked values array as
ArrayView
.- Getter
Returns values ArrayView.
aim.sdk.metric module
aim.sdk.image_sequence module
aim.sdk.distribution_sequence module
aim.sdk.sequence_collection module
- class aim.sdk.sequence_collection.SequenceCollection[source]
Abstract interface for collection of tracked series/sequences.
Typically represents sequences of a same run or sequences matching given query expression.
- class aim.sdk.sequence_collection.SingleRunSequenceCollection(run, seq_cls=<class 'aim.sdk.sequence.Sequence'>, query='')[source]
Bases:
aim.sdk.sequence_collection.SequenceCollection
Implementation of SequenceCollection interface for a single Run.
Method iter() returns Sequence iterator which yields Sequence matching query from run’s sequences. Method iter_runs() raises StopIteration, since the collection is bound to a single Run.
- Parameters
run (
Run
) – Run object for which sequences are queried.seq_cls (
type
) – The collection’s sequence class. Sequences not matching to seq_cls.allowed_dtypes will be skipped. Sequence by default, meaning all sequences will match.query (
str
, optional) – Query expression. If specified, method iter() will return iterator for sequences matching the query. If not, method iter() will return iterator for run’s all sequences.
- class aim.sdk.sequence_collection.QuerySequenceCollection(repo, seq_cls=<class 'aim.sdk.sequence.Sequence'>, query='')[source]
Bases:
aim.sdk.sequence_collection.SequenceCollection
Implementation of SequenceCollection interface for repository’s sequences matching given query.
Method iter() returns Sequence iterator, which yields Sequence matching query from currently iterated run’s sequences. Once there are no sequences left in current run, repository’s next run is considered. Method iter_runs() returns SequenceCollection iterator for repository’s runs.
- Parameters
repo (
Repo
) – Aim repository object.seq_cls (
type
) – The collection’s sequence class. Sequences not matching to seq_cls.allowed_dtypes will be skipped. Sequence by default, meaning all sequences will match.query (
str
, optional) – Query expression. If specified, method iter() will skip sequences not matching the query. If not, method iter() will return iterator for all sequences in repository (that’s a lot of sequences!).
- class aim.sdk.sequence_collection.QueryRunSequenceCollection(repo, seq_cls=<class 'aim.sdk.sequence.Sequence'>, query='', paginated=False, offset=None)[source]
Bases:
aim.sdk.sequence_collection.SequenceCollection
Implementation of SequenceCollection interface for repository’s runs matching given query.
Method iter() returns Sequence iterator which yields Sequence for current run’s all sequences. Method iter_runs() returns SequenceCollection iterator from repository’s runs matching given query.
- Parameters
repo (
Repo
) – Aim repository object.seq_cls (
type
) – The collection’s sequence class. Sequences not matching to seq_cls.allowed_dtypes will be skipped. Sequence by default, meaning all sequences will match.query (
str
, optional) – Query expression. If specified, method iter_runs() will skip runs not matching the query. If not, method iter_run() will return SequenceCollection iterator for all runs in repository.