Aim Python SDK#
API Reference for Aim Python SDK classes#
Aim is designed to enable logging of any data type. This reference will guide you through the fundamental data building blocks, as well as data retrieval approaches.
Repo class reference#
The repo module contains implementation of class Repo; a core class for accessing the data logged in Aim. It provides interfaces for creating and managing Aim repositories, for both local and remote setups. Repo class can be used to query stored Containers and Sequences, as well as get the metadata about logs, such as registered types, actions, packages, summary of logged types, etc.
Repository management#
Determines if the provided path refers to a remote repository. |
|
Retrieves the default repository instance. |
|
Named constructor for Repo for given path. |
|
Retrieves the currently active repository. |
|
Checks if an Aim repository exists at the given path. |
|
Initializes a new Aim repository at the given path. |
|
Deletes an Aim repository at the given path. |
|
Retrieves the version of the Aim repository at the given path. |
Data access interface#
Retrieves a list of hashes for all tracked containers. |
|
Retrieves a container from the repository based on its hash. |
|
Retrieves a collection of containers based on the query expression and type. |
|
Retrieves a collection of sequences based on the query expression and type. |
|
Lists all container types being tracked in the repository. |
|
Lists all sequence types being tracked in the repository. |
|
Retrieves information for a specific sequence type. |
|
Retrieves all tracked parameters for the repository. |
|
Returns the storage engine associated with the repository. |
|
Returns the resource tracker associated with the repository. |
Package and Types information#
Lists all registered container types in the repository. |
|
Lists all registered sequence types in the repository. |
|
Lists all registered actions in the repository. |
|
Adds a package to the repository. |
|
Removes a package from the repository. |
|
Loads all active packages in the repository. |
Data management interface#
Deletes multiple Containers data from aim repository |
|
Delete Container data from aim repository |
|
Move multiple Containers data from current aim repository to destination aim repository |
|
Copy multiple Containers data from current aim repository to destination aim repository |
|
Removes dangling/orphan params/sequences with no referring containers. |
- class aim._sdk.repo.Repo(path, *, read_only=True)[source]#
Represents an Aim repository, handling both local and remote repositories.
Initializes a repository instance.
- Parameters:
path (str) β Path to the Aim repository.
read_only (bool, optional) β If True, opens the repo in read-only mode. Default is True.
- static is_remote_path(path)[source]#
Determines if the provided path refers to a remote repository.
- Parameters:
path (str) β The path to be checked.
- Returns:
True if the path is remote, otherwise False.
- Return type:
bool
- classmethod default()[source]#
Retrieves the default repository instance.
- Returns:
Default repository instance.
- Return type:
- classmethod from_path(path, read_only=True)[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.- Return type:
- classmethod get_version(path)[source]#
Retrieves the version of the Aim repository at the given path.
- Parameters:
path (str) β The repository path.
- Returns:
Version tuple if the path refers to a valid Aim repository, otherwise None.
- Return type:
Optional[Tuple[int, β¦]]
- classmethod active_repo()[source]#
Retrieves the currently active repository.
- Returns:
The active repository instance.
- Return type:
- Raises:
ValueError β If itβs not possible to determine the active repository.
- classmethod exists(path)[source]#
Checks if an Aim repository exists at the given path.
- Parameters:
path (str) β The path to check.
- Returns:
True if the Aim repository exists, otherwise False.
- Return type:
bool
- classmethod init(path)[source]#
Initializes a new Aim repository at the given path.
- Parameters:
path (str) β Path where the Aim repository should be created.
- Returns:
The newly initialized repository instance.
- Return type:
- classmethod rm(path)[source]#
Deletes an Aim repository at the given path.
- Parameters:
path (str) β The path to the Aim repository to be deleted.
- property storage_engine: StorageEngine#
Returns the storage engine associated with the repository.
- Returns:
The storage engine instance.
- Return type:
StorageEngine
- property resource_tracker: ResourceTracker#
Returns the resource tracker associated with the repository.
- Returns:
The resource tracker instance.
- Return type:
ResourceTracker
- tracked_container_types()[source]#
Lists all container types being tracked in the repository.
- Returns:
List of tracked container types.
- Return type:
List[str]
- tracked_sequence_types()[source]#
Lists all sequence types being tracked in the repository.
- Returns:
List of tracked sequence types.
- Return type:
List[str]
- tracked_sequence_infos(sequence_type)[source]#
Retrieves information for a specific sequence type.
- Parameters:
sequence_type (str) β The sequence type to retrieve information for.
- Returns:
Dictionary of tracked sequence names/contexts.
- Return type:
Dict[str, List]
- tracked_params()[source]#
Retrieves all tracked parameters for the repository.
- Returns:
Dictionary of tracked parameters.
- Return type:
Dict
- registered_container_types()[source]#
Lists all registered container types in the repository.
- Returns:
List of registered container types.
- Return type:
List[str]
- registered_sequence_types()[source]#
Lists all registered sequence types in the repository.
- Returns:
List of registered sequence types.
- Return type:
List[str]
- registered_actions()[source]#
Lists all registered actions in the repository.
- Returns:
List of registered actions.
- Return type:
List[str]
- property container_hashes#
Retrieves a list of hashes for all tracked containers.
- Returs:
List[str]: List of container hashes.
- get_container(hash_)[source]#
Retrieves a container from the repository based on its hash.
- Parameters:
hash (str) β The hash of the container to retrieve.
- Returns:
The corresponding container object.
- Return type:
- containers(query_=None, type_=<class 'aim._sdk.container.Container'>, **kwargs)[source]#
Retrieves a collection of containers based on the query expression and type.
- Parameters:
- Returns:
The resulting collection of containers.
- Return type:
ContainerCollection
- sequences(query_=None, type_=<class 'aim._sdk.sequence.Sequence'>, **kwargs)[source]#
Retrieves a collection of sequences based on the query expression and type.
- add_package(pkg_name)[source]#
Adds a package to the repository.
- Parameters:
pkg_name (str) β The name of the package to be added.
- Returns:
True if the package was added successfully, False if it already exists.
- Return type:
bool
- remove_package(pkg_name)[source]#
Removes a package from the repository.
- Parameters:
pkg_name (str) β The name of the package to be removed.
- Returns:
True if the package was removed successfully, False if it doesnβt exist.
- Return type:
bool
- load_active_packages()[source]#
Loads all active packages in the repository. Only applicable for local repositories.
Note
This method doesnβt return any value but has side effects on the state of loaded packages.
- delete_containers(container_hashes)[source]#
Deletes multiple Containers data from aim repository
This action removes containers data permanently and cannot be reverted. If you want to archive container but keep itβs data use repo.get_container(container_hash).archived = True.
- Parameters:
container_hashes (
str
) β list of Containers to be deleted.- Returns:
(True, []) if all containers deleted successfully, (False,
list
) with list of remaining containers otherwise.- Return type:
Tuple[bool, List[str]]
- delete_container(container_hash)[source]#
Delete Container data from aim repository
This action removes container data permanently and cannot be reverted. If you want to archive container but keep itβs data use repo.get_container(container_hash).archived = True.
- Parameters:
container_hash (
str
) β Container to be deleted.- Returns:
True if container deleted successfully, False otherwise.
- Return type:
bool
- move_containers(container_hashes, dest_repo)[source]#
Move multiple Containers data from current aim repository to destination aim repository
- Parameters:
container_hashes (
str
) β list of Containers to be moved.dest_repo (
Repo
) β destination Repo instance to move Containers
- Returns:
(True, []) if all containers were moved successfully, (False,
list
) with list of remaining containers otherwise.- Return type:
Tuple[bool, List[str]]
- copy_containers(container_hashes, dest_repo)[source]#
Copy multiple Containers data from current aim repository to destination aim repository
- Parameters:
container_hashes (
str
) β list of Containers to be copied.dest_repo (
Repo
) β destination Repo instance to copy Containers
- Returns:
(True, []) if all containers were copied successfully, (False,
list
) with list of remaining containers otherwise.- Return type:
Tuple[bool, List[str]]
Container class interface#
The container module provides implementation of a Container class. Container is a core class, representing a inter-related set of properties, parameters, Sequence and Record entities. Specific Container types can be used to collect and store data representing a process execution, such as model training, LLM chain execution, etc. Container class provides interface for getting and setting itβs pre-defined Properties as well as free-form dict-like parameters. Container class has an interface for managing sequence objects.
Container creation and retrieval#
Restores a serialized container instance from given storage and meta tree. |
|
Filters the containers based on the given expression and repository. |
|
Finds and returns a container instance based on the given hash. |
|
Checks if the container matches the given expression. |
Params and properties management#
Sets a value in the container for a given key. |
|
Sets a value in the container for a given key with optional strictness. |
|
Retrieves a value from the container based on the given key. |
|
Retrieves a value from the container based on the key or returns a default value. |
|
Deletes a value in the container based on the given key. |
|
Collects and returns all properties associated with the container as a dictionary object. |
|
|
|
|
Sequence data management#
Deletes a sequence from the container based on the given name and context. |
|
Returns a map of sequences associated with the container. |
|
Retrieves a sequence of specified type based on the given name and context. |
|
Retrieves a sequence collection based on a query expression. |
|
Returns an iterator over the sequences. |
|
Retrieves a sequence based on the given item (name or tuple of name and context). |
|
Deletes a sequence based on the given item (name or tuple of name and context). |
Container metadata and management#
Deletes the container and its associated data. |
|
Closes the container and releases any associated resources. |
|
Returns the typename of the logged data in the container. |
|
|
|
|
|
|
- class aim._sdk.container.Container(hash_=None, *, repo=None, mode=ContainerOpenMode.WRITE)[source]#
Initializes the Container instance.
- Parameters:
hash (str, optional) β Unique identifier for the container.
repo (Union[str, 'Repo'], optional) β Repository path or Repo object.
mode (Union[str, ContainerOpenMode], optional) β Mode for the container (e.g., βREADONLYβ or βWRITEβ). Defaults to βWRITEβ.
hash_ (Optional[str]) β
- classmethod from_storage(storage, meta_tree, *, hash_)[source]#
Restores a serialized container instance from given storage and meta tree.
- Parameters:
storage β Storage backend instance.
meta_tree ('TreeView') β Tree view of the metadata.
hash (str) β Unique identifier for the container.
hash_ (str) β
- classmethod filter(expr='', repo=None)[source]#
Filters the containers based on the given expression and repository.
- Parameters:
expr (str, optional) β Query expression for filtering.
repo ('Repo', optional) β Repository instance. Defaults to the active Repo.
- Return type:
ContainerCollection
- classmethod find(hash_)[source]#
Finds and returns a container instance based on the given hash.
- Parameters:
hash (str) β Unique identifier for the container.
hash_ (str) β
- Return type:
Optional[Container]
- __setitem__(key, value)[source]#
Sets a value in the container for a given key.
- Parameters:
key β Key to set the value for.
value β Value to be set.
- set(key, value, strict)[source]#
Sets a value in the container for a given key with optional strictness.
- Parameters:
key β Key to set the value for.
value β Value to be set.
strict (bool) β Whether to enforce strict setting.
- __getitem__(key)[source]#
Retrieves a value from the container based on the given key.
- Parameters:
key β Key for which value is to be retrieved.
- get(key, default=None, strict=False)[source]#
Retrieves a value from the container based on the key or returns a default value.
- Parameters:
key β Key for which value is to be retrieved.
default (optional) β Default value to return if key doesnβt exist.
strict (bool, optional) β Whether to enforce strict retrieval.
- __delitem__(key)[source]#
Deletes a value in the container based on the given key.
- Parameters:
key β Key for which the value is to be deleted.
- collect_properties()[source]#
Collects and returns all properties associated with the container as a dictionary object.
- Return type:
Dict
- get_logged_typename()[source]#
Returns the typename of the logged data in the container.
- Return type:
str
- delete_sequence(name, context=None)[source]#
Deletes a sequence from the container based on the given name and context.
- Parameters:
name β Name of the sequence to delete.
context (optional) β Contextual information for the sequence. {} if not specified.
- property sequences: ContainerSequenceMap#
Returns a map of sequences associated with the container.
- class aim._sdk.container.ContainerSequenceMap(container, sequence_cls)[source]#
- __call__(query_=None, type_=<class 'aim._sdk.sequence.Sequence'>, **kwargs)[source]#
Retrieves a sequence collection based on a query expression.
- Parameters:
- Returns:
The filtered sequence collection.
- Return type:
SequenceCollection
- __iter__()[source]#
Returns an iterator over the sequences.
- Yields:
Sequence β The next sequence in the container.
- Return type:
Iterator[Sequence]
- __getitem__(item)[source]#
Retrieves a sequence based on the given item (name or tuple of name and context).
- Parameters:
item (Union[str, Tuple[str, Dict]]) β Name of the sequence or a tuple of name and context.
- Returns:
The retrieved sequence.
- Return type:
Sequence class interface#
Tracks a given value at a specific step in the sequence. |
|
Filters sequences based on a given expression. |
|
Finds a Sequence based on container hash, name, and context. |
|
Checks if the sequence matches a given expression. |
- class aim._sdk.sequence.Sequence(container, *, name, context)[source]#
Initializes a Sequence with the given container, name, and context.
- Parameters:
container (Container) β The enclosing container for the sequence.
name (str) β The name of the sequence.
context (_ContextInfo) β The context for the sequence.
- classmethod from_storage(storage, meta_tree, *, hash_, name, context)[source]#
Creates a Sequence instance from the provided storage and metadata.
- Parameters:
storage β The storage object where the sequence is stored.
meta_tree (TreeView) β The tree view of metadata.
hash (str) β The hash of the enclosing container.
name (str) β The name of the sequence.
context (_ContextInfo) β The context for the sequence.
hash_ (str) β
- Returns:
A Sequence instance.
- Return type:
- classmethod filter(expr='', repo=None)[source]#
Filters sequences based on a given expression.
- Parameters:
expr (str, optional) β The query expression for filtering. Defaults to an empty string.
repo (Repo, optional) β The repository to filter from. If not provided, uses the active repo.
- Returns:
A collection of sequences satisfying the filter.
- Return type:
SequenceCollection
- classmethod find(hash_, name, context)[source]#
Finds a Sequence based on container hash, name, and context.
- Parameters:
hash (str) β The hash identifier of the enclosing container.
name (str) β The name of the sequence.
context (Dict) β The context for the sequence.
hash_ (str) β
- Returns:
Returns a Sequence if found, otherwise None.
- Return type:
Sequence or None
- property name#
Gets the name of the sequence.
- Type:
str
- property context: Dict#
Gets the context dictionary of the sequence.
- Type:
Dict
- property type: str#
Gets the type of the tracked items.
- Type:
str
- property allowed_value_types: Tuple[str]#
Gets the allowed value types for the sequence.
- Type:
Tuple[str]
- property is_empty: bool#
Returns True if the sequence is empty, otherwise False.
- Type:
bool
- property start: int#
Gets the first step of the sequence.
- Type:
int
- property stop: int#
Gets the last step of the sequence.
- Type:
int
- property next_step: int#
Gets the next available step for the sequence.
- Type:
int
- match(expr)[source]#
Checks if the sequence matches a given expression.
- Parameters:
expr β The expression to check.
- Returns:
True if the sequence matches the expression, otherwise False.
- Return type:
bool
- property axis_names: Tuple[str]#
Gets the names of the axis for the sequence.
- Type:
Tuple[str]
- axis(name)[source]#
Gets the axis values for a given axis name.
- Parameters:
name (str) β The name of the axis.
- Returns:
An iterator over the axis values.
- Return type:
Iterator[Any]
- items()[source]#
Iterator[Tuple[int, Any]]: Returns an iterator over the sequence items (steps and their values).
- Return type:
Iterator[Tuple[int, Any]]
- values()[source]#
Iterator[Any]: Returns an iterator over the sequence values.
- Return type:
Iterator[Any]
- sample(k)[source]#
Samples k items from the sequence.
- Parameters:
k (int) β The number of items to sample.
- Returns:
A list of sampled items.
- Return type:
List[Any]
- track(value, *, step=None, **axis)[source]#
Tracks a given value at a specific step in the sequence.
- Parameters:
value (Any) β The value to be tracked.
step (Optional[int], optional) β The step at which the value should be tracked. If not provided, it will be determined automatically.
**axis β Additional axis values.
- Raises:
ValueError β If the provided value type is not supported by the sequence.
- get_logged_typename()[source]#
Retrieves the type name of the logged sequence.
- Returns:
The type name of the logged sequence.
- Return type:
str
- __iter__()[source]#
Returns an iterator over the steps and their associated values in the sequence.
- Returns:
An iterator over the sequence items.
- Return type:
Iterator[Tuple[int, Tuple[Any, β¦]]]
- class aim._sdk.sequence.SequenceView(sequence, *, columns, start=None, stop=None)[source]#
- Parameters:
sequence (Sequence) β
columns (Tuple[str]) β
start (int) β
stop (int) β