Managers
- class AssetManager(api_config: Configuration)[source]
AIoD - RAIL AssetManager class
Class containing methods that operate on simpler assets such as: models, datasets, publications, etc..
- __init__(api_config: Configuration)[source]
Initializes a new ExperimentRunManager.
- Parameters:
client_config – (Configuration): Instance of Configuration class.
- Returns:
Initialized AssetManager.
- Return type:
Examples
>>> config = Configuration(...) >>> AssetManager(config) AssetManager
- count_datasets(query: str = None) int[source]
Counts the number of datasets.
- Parameters:
query – (Optional[str]): Count only datasets that in their name contain a string given in this arg.
- Returns:
Number of datasets.
- Return type:
int
- Raises:
ApiException – In case of a failed HTTP request.
Examples
>>> asset_manager = AssetManager(...) >>> asset_manager.count_datasets() 4321 >>> asset_manager.count_datasets(query="Image") 1234 # count of datasets that contain the phrase "Image"
- count_models(query: str = None) int[source]
Counts the number of models.
- Parameters:
query – (Optional[str]): Count only models that contain in their name a string given by this arg.
- Returns:
Number of models.
- Return type:
int
- Raises:
ApiException – In case of a failed HTTP request.
Examples
>>> asset_manager = AssetManager(...) >>> asset_manager.count_models() 4321 >>> asset_manager.count_models(query="LLM") 1234 # count of models that contain the phrase "LLM"
- count_my_datasets() int[source]
Counts the number of datasets of the current user.
- Returns:
Number of datasets.
- Return type:
int
- Raises:
ApiException – In case of a failed HTTP request.
Examples
>>> asset_manager = AssetManager(...) >>> asset_manager.count_my_datasets() 123
- count_my_models() int[source]
Counts the number of models of the current user.
- Returns:
Number of models.
- Return type:
int
- Raises:
ApiException – In case of a failed HTTP request.
Examples
>>> asset_manager = AssetManager(...) >>> asset_manager.count_my_models() 123
- count_publications(query: str = None) int[source]
Counts the number of publications.
- Parameters:
query – (Optional[str]): Count only publications that contain a string given in this arg.
- Returns:
Number of publications.
- Return type:
int
- Raises:
ApiException – In case of a failed HTTP request.
Examples
>>> asset_manager = AssetManager(...) >>> asset_manager.count_publications() 4321 >>> asset_manager.count_publications(query="CNNs") 1234 # count of publications that contain the phrase "CNNs"
- get_dataset_by_id(id: str) Dataset[source]
Retrieves dataset specified by its ID.
- Parameters:
id (str) – Unique identifier of dataset in database.
- Returns:
The dataset corresponding to the given ID.
- Return type:
Dataset
- Raises:
ApiException – In case of a failed HTTP request.
Examples
>>> asset_manager = AssetManager(...) >>> asset_manager.get_dataset_by_id(id="data_000002AhzqHqOQwQLP0qCRds") Dataset
- get_datasets(query: str = None, enhanced: bool = False, offset: int = 0, limit: int = 100) List[Dataset][source]
Retrieves a list of available datasets.
- Parameters:
query (str, optional) – Search string used to filter datasets. Defaults to empty string,
default (which means that by)
used. (it's not)
enhanced (bool, optional) – If true and the query arg is also specified, a semantic search is performed.
offset (int, optional) – Starting index of from which to retrieve. Defaults to 0.
limit (int, optional) – How many items to retrieve. Defaults to 100.
- Returns:
The list of datasets.
- Return type:
List[Dataset]
- Raises:
ApiException – In case of a failed HTTP request.
Examples
>>> asset_manager = AssetManager(...) >>> asset_manager.get_datasets(query="AI", offset=2, limit=10) List[Dataset] # 10 datasets that contain the text "AI" in their name
- get_model_by_id(id: str) Model[source]
Retrieves a model specified by its ID.
- Parameters:
id (str) – Unique identifier of a model.
- Returns:
The model corresponding to the given ID.
- Return type:
Model
- Raises:
ApiException – In case of a failed HTTP request.
Examples
>>> asset_manager = AssetManager(...) >>> asset_manager.get_model_by_id(id="mdl_000028bcIa2SCbO9aVlIB0Xc") Model
- get_models(query: str = None, offset: int = 0, limit: int = 100) List[Model][source]
Retrieves a list of models.
- Parameters:
query (str, optional) – Search string used to filter models. Defaults to empty string,
default (which means that by)
used. (it's not)
offset (int, optional) – Starting index from which to retrieve. Defaults to 0.
limit (int, optional) – How many items to retrieve. Defaults to 100.
- Returns:
The list of models.
- Return type:
List[Model]
- Raises:
ApiException – In case of a failed HTTP request.
Examples
>>> asset_manager = AssetManager(...) >>> asset_manager.get_models(query="LLM", offset=2, limit=10) List[Model] # 10 models that contain the phrase "LLM" in their name
- get_my_datasets(offset: int = 0, limit: int = 100) List[Dataset][source]
Retrieves a list of datasets created by the current user.
- Parameters:
offset (int, optional) – Starting index from which to retrieve. Defaults to 0.
limit (int, optional) – How many items to retrieve. Defaults to 100.
- Returns:
The list of datasets.
- Return type:
List[Dataset]
- Raises:
ApiException – In case of a failed HTTP request.
Examples:
- get_my_models(offset: int = 0, limit: int = 100) List[Model][source]
Retrieves a list of models created by the current user.
- Parameters:
offset (int, optional) – Starting index from which to retrieve. Defaults to 0.
limit (int, optional) – How many items to retrieve. Defaults to 100.
- Returns:
A list of user’s models.
- Return type:
List[Model]
- Raises:
ApiException – In case of a failed HTTP request.
Examples
>>> asset_manager = AssetManager(...) >>> asset_manager.get_my_models(limit=2) List[Model] # first 2 models created by a current user
- get_platforms(offset: int = 0, limit: int = 100) List[Platform][source]
Retrieves a list of platforms.
- Parameters:
offset (int, optional) – Starting index from which to retrieve. Defaults to 0.
limit (int, optional) – How many items to retrieve. Defaults to 100.
- Returns:
The list of platforms.
- Return type:
List[Platform]
- Raises:
ApiException – In case of a failed HTTP request.
Examples
>>> asset_manager = AssetManager(...) >>> asset_manager.get_platforms(offset=2, limit=5) 5
- get_publication_by_id(id: str) Publication[source]
Retrieves a publication specified by its ID.
- Parameters:
id (str) – Unique identifier of a publication in database.
- Returns:
The publication corresponding to the given ID.
- Return type:
Dataset
- Raises:
ApiException – In case of a failed HTTP request.
Examples
>>> asset_manager = AssetManager(...) >>> asset_manager.get_publication_by_id(id="pub_03F6jLXedDDQSzc6expGpLGI") Publication
- get_publications(query: str = None, offset: int = 0, limit: int = 100) List[Publication][source]
Retrieves a list of publications.
- Parameters:
query (str, optional) – Search string used to filter publications. Defaults to empty string,
default (which means that by)
used. (it's not)
offset (int, optional) – Starting index from which to retrieve. Defaults to 0.
limit (int, optional) – How many items to retrieve. Defaults to 100.
- Returns:
The list of publications.
- Return type:
List[Publication]
- Raises:
ApiException – In case of a failed HTTP request.
Examples
>>> asset_manager = AssetManager(...) >>> asset_manager.get_publications(query="AI", offset=2, limit=10) List[Publication]
- upload_file_to_huggingface(id: str, name: str, huggingface_token: str, file_path: str) Dataset[source]
Uploads a file to Huggingface under the dataset specified by its id.
- Parameters:
id (str) – The ID of the dataset.
name (str) – The name of the file as it will appear on Huggingface.
huggingface_token – Authentication token from Huggingface.
file_path (str) – Path to the file to upload.
- Returns:
Dataset under which the file was uploaded.
- Return type:
Dataset
- Raises:
ApiException – In case of a failed HTTP request.
Examples
>>> asset_manager = AssetManager(...) >>> asset_manager.upload_file_to_huggingface("data_000017VBQZZ7s3cvm7Gx0AnT", "Example Name", "huggingface_token", "path/to/file.txt") Dataset
- class ExperimentTemplateManager(api_config: Configuration)[source]
AIoD - RAIL
ExperimentManager class
Class aggregating methods for operating on multiple experiments.
- __init__(api_config: Configuration)[source]
Initializes a new ExperimentTemplateManager.
- Parameters:
client_config – (Configuration): Instance of Configuration class.
- Returns:
Initialized ExperimentTemplateManager.
- Return type:
Examples
>>> config = Configuration(...) >>> ExperimentTemplateManager(config) ExperimentTemplateManager
- count(query: str = '', mine: bool | None = None, finalized: bool | None = None, approved: bool | None = None, public: bool | None = None) int[source]
Counts the number of experiments based on filters specified in Args.
- Parameters:
query (str, optional) – Query used to filter experiment templates. Defaults to empty string, which means that by default count is not filtered.
mine (bool, optional) – If own personal experiment templates should be counted or the opposite. Defaults to None.
finalized (bool, optional) – If experiment templates that are successfully build and ready to use should be counted or the opposite. Defaults to None.
approved (bool, optional) – If already approved experiments should be counted or the opposite. Defaults to None.
public (bool, optional) – If experiment templates flagged as public should be counted or the opposite. Defaults to None.
- Returns:
Number of experiment templates.
ApiException: In case of a failed HTTP request.
- Return type:
int
Raises:
Examples
>>> template_manager = ExperimentTemplateManager(...) >>> template_manager.count(finalized=True, approved=True, public=True) 1234
- create(template: dict | tuple[str, str, str, dict]) ExperimentTemplate[source]
Creates a new experiment template.
- Parameters:
template (requirements and docker image in this order and) – (dict | tuple[str, str, str, dict]):
json (The file can be passed either as full specified)
to (as a tuple of three strings with paths) – (script, requirements and docker image and a json
script ((dictionary) specifying the paths to)
template
description (name, description, task etc.)
- Returns:
Created experiment template.
- Return type:
- Raises:
ApiException – In case of a failed HTTP request.
Note
Successfully created template will need to be approved by an administrator and afterward built as a docker container by the backend service. Only after these operations are done can it be used to make new experiments.
Examples
>>> script_path = "path/to/script.py" >>> requirements_path = "path/to/requirements.txt" >>> base_image = "python:3.9" >>> template_config = { >>> "name": "Example Template", >>> "description": "Template in Examples", >>> "task": "TEXT_CLASSIFICATION", >>> "datasets_schema": { "cardinality": "1-1" }, >>> "models_schema": { "cardinality": "1-1" }, >>> "envs_required": [ { "name": "SPLIT_NAME", "description": "name of a subset" } ], >>> "envs_optional": [], >>> "available_metrics": [ "accuracy" ], >>> "is_public": True >>> } >>> template_manager.create((script_path, requirements_path, base_image, template_config)) ExperimentTemplate # newly created instance
- get(query: str = '', mine: bool | None = None, finalized: bool | None = None, approved: bool | None = None, public: bool | None = None, offset: int = 0, limit: int = 100) List[ExperimentTemplate][source]
Gets experiment templates based of on specified filters.
- Parameters:
query (str, optional) – Query used to filter experiment templates. This parameter is case-insensitive and matches full words in template names. Defaults to empty string, in which case it’s not used.
mine (bool, optional) – If own personal experiment templates should be included or the opposite. Defaults to None.
finalized (bool, optional) – If experiment templates that are successfully build and ready to use should be listed or the opposite. Defaults to None.
approved (bool, optional) – If already approved experiments should be listed or the opposite. Defaults to None.
public (bool, optional) – If experiment templates flagged as public should be listed or the opposite. Defaults to None.
offset (int, optional) – Starting index of experiment template range from which to retrieve Defaults to 0.
limit (int, optional) – Ending index of experiment template range to which to retrieve. Defaults to 100.
- Returns:
List of all experiments in given range
- Return type:
list[ExperimentTemplate]
- Raises:
ApiException – In case of a failed HTTP request.
Examples
>>> template_manager = ExperimentTemplateManager(...) >>> template_manager.get() List[ExperimentTemplate] >>> len(template_manager.get(finalized=True, approved=True, limit=1000)) 1000 >>> template_manager.get(query="Tutorial") List[ExperimentTemplate] # only templates that contain word "Tutorial" in their name.
- get_by_id(id: str) ExperimentTemplate[source]
Retrieves a specific experiment template by its ID.
- Parameters:
id (str) – ID of experiment template to be retrieved.
- Returns:
Experiment template given by ID.
- Return type:
- Raises:
ApiException – In case of a failed HTTP request.
Examples
>>> template_manager = ExperimentTemplateManager(...) >>> template_manager.get_by_id("685151f2d08da970a3a5d6ce") ExperimentTemplate
- class ExperimentManager(api_config: Configuration)[source]
AIoD - RAIL ExperimentManager class
Class aggregating methods for operating on multiple experiments.
- __init__(api_config: Configuration)[source]
Initializes a new ExperimentManager.
- Parameters:
client_config – (Configuration): Instance of Configuration class.
- Returns:
Initialized ExperimentManager.
- Return type:
Examples
>>> config = Configuration(...) >>> ExperimentManager(config) ExperimentManager
- count(query: str = '', mine: bool | None = None, archived: bool | None = None, public: bool | None = None) int[source]
Counts the number of experiments based on filters specified in Args.
- Parameters:
query (str, optional) – Query used to filter experiments. Defaults to empty string, which means that by default, it’s not used.
mine (bool, optional) – If own personal experiments should be counted or the opposite. Defaults to None.
archived (bool, optional) – If archived experiments should be counted or the opposite. Defaults to None.
public (bool, optional) – If experiment templates flagged as public should be counted or the opposite. Defaults to None.
- Returns:
Number of experiments.
- Return type:
int
- Raises:
ApiException – In case of a failed HTTP request.
Examples
>>> experiment_manager = ExperimentManager(...) >>> experiment_manager.count(query="Tutorial", mine=True, archived=True) ExperimentTemplate
- create(experiment: Dict) Experiment[source]
Creates experiment from specified experiment file. :param experiment: Experiment described in a dictionary. :type experiment: dict
- Returns:
Experiment created from given template.
- Return type:
- Raises:
ApiException – In case of a failed HTTP request.
Note
To create an experiment successfully, the template it is based on needs to be approved and built as a docker container.
Examples
>>> experiment_dict = { >>> "name": "test123", >>> "description": "321test", >>> "is_public": True, >>> "experiment_template_id": "685151f2d08da970a3a5d6ce", >>> "dataset_ids": ["data_000002AhzqHqOQwQLP0qCRds"], >>> "model_ids": ["mdl_003Csk8QjNfE80c7g6Rt8yVb"], >>> "publication_ids": [], >>> "env_vars": [{"key": "SPLIT_NAME", "value": "PES"} >>> ] >>> } >>> experiment_manager = ExperimentManager(...) >>> experiment_manager.create(experiment_dict) Experiment # Newly created experiment.
- get(query: str = '', mine: bool | None = None, archived: bool | None = None, public: bool | None = None, offset: int = 0, limit: int = 100) List[Experiment][source]
Retrieves a lis of experiments based on specific filters.
- Parameters:
query (str, optional) – Query used to filter experiments. Defaults to empty string, which means that by default, it’s not used.
mine (bool, optional) – If own personal experiments should be included or the opposite. Defaults to None.
archived (bool, optional) – If archived experiments should be listed or the opposite. Defaults to None.
public (bool, optional) – If experiment templates flagged as public should be listed or the opposite. Defaults to None.
offset (int, optional) – Starting index of experiment range from which to retrieve. Defaults to 0.
limit (int, optional) – Ending index of experiment range to which to retrieve. Defaults to 100.
- Returns:
The list of experiments.
- Return type:
list[Experiment]
- Raises:
ApiException – In case of a failed HTTP request.
Examples
>>> experiment_manager = ExperimentManager(...) >>> experiment_manager.get() List[Experiment] >>> len(experiment_manager.get(archived=False, public=True, limit=1000)) 1000 >>> template_manager.get(query="Tutorial") List[Experiment] # only experimenets that contain word "Tutorial" in their name.
- get_by_id(id: str) Experiment[source]
Gets specific experiment by its ID.
- Parameters:
id (str) – ID of experiment to be retrieved.
- Returns:
Experiment specified by its ID.
- Return type:
- Raises:
ApiException – In case of a failed HTTP request or failure to retrieve an experiment with given ID.
Examples
>>> experiment_manager = ExperimentManager(...) >>> experiment_manager.get_by_id("6861d3c954d2c02536469a30") Experiment
- class ExperimentRunManager(api_config: Configuration)[source]
AIoD - RAIL ExperimentRunManager class
Class aggregating methods for operating on multiple experiment runs and which are not restricted to a specific experiment.
- __init__(api_config: Configuration)[source]
Initializes a new ExperimentRunManager.
- Parameters:
client_config – (Configuration): Instance of Configuration class.
- Returns:
Initialized ExperimentRunManager.
- Return type:
Examples
>>> config = Configuration(...) >>> ExperimentRunManager(config) ExperimentRunManager
- get_by_id(id: str) ExperimentRun[source]
Gets specific experiment run by its ID.
- Parameters:
id (str) – ID of an experiment run to be retrieved.
- Returns:
Experiment run specified by its ID.
- Return type:
- Raises:
ApiException – In case of a failed HTTP request or failure to retrieve an experiment with given ID.
Examples
>>> run_manager = ExperimentRunManager(...) >>> run_manager.get_by_id("6861d3c954d2c02536469a30") ExperimentRun