Instances

class ExperimentTemplate(*, id: Annotated[str, Strict(strict=True)], name: Annotated[str, Strict(strict=True)], state: Annotated[str, Strict(strict=True)], script: Annotated[str, Strict(strict=True)], created_at: Annotated[str, Strict(strict=True)], updated_at: Annotated[str, Strict(strict=True)], dockerfile: Annotated[str, Strict(strict=True)], base_image: Annotated[str, Strict(strict=True)], description: Annotated[str, Strict(strict=True)], pip_requirements: Annotated[str, Strict(strict=True)], is_mine: Annotated[bool, Strict(strict=True)], is_public: Annotated[bool, Strict(strict=True)], is_archived: Annotated[bool, Strict(strict=True)], is_approved: Annotated[bool, Strict(strict=True)] | None, task: TaskType, datasets_schema: AssetSchema, models_schema: AssetSchema, envs_required: List[EnvironmentVarDef], envs_optional: List[EnvironmentVarDef])[source]

AIoD - RAIL

ExperimentTemplate class.

Implementation of class representing an instance of experiment template and methods operating with this instance.

classmethod from_dict(obj: Dict[str, Any] | None, config: Configuration = None) Self | None[source]

Creates an instance of ExperimentTemplate from a dict.

Parameters:
  • obj (Optional[Dict[str, Any]]) – Dictionary representation of an ExperimentTemplate

  • config (Configuration) – Configuration associated with API calls.

Returns:

An instance of ExperimentTemplate.

Return type:

ExperimentTemplate

Examples

>>> template_dict = ...
>>> ExperimentTemplate.from_dict(template_dict)
ExperimentTemplate
classmethod from_json(json_str: str) Self | None[source]

Creates an instance of ExperimentTemplate from a JSON string.

Parameters:

json_str – The JSON string to create the instance from.

Returns:

Instance of ExperimentTemplate.

Return type:

ExperimentTemplate

Examples

>>> template_json = ...
>>> ExperimentTemplate.from_json(template_json)
ExperimentTemplate
archive(archive: bool = False) None[source]

Archives specific experiment template specified by ID.

Parameters:

archive (bool) – If experiment template should be archived or un-archived. Defaults to False.

Returns:

None.

Raises:

ApiException – In case of a failed HTTP request.

Examples

>>> self.archive(True)
>>> self.is_archived
True
delete() None[source]

Deletes the experiment template. After this method is called any operations on the template instance will result in an HTTP exception as the template no longer exists.

Returns:

None.

Raises:

ApiException – In case of a failed HTTP request.

Examples

>>> self.delete()
>>> self._deleted
True
update(template: dict | tuple[str, str, str, dict]) Self[source]

Updates specific experiment template.

Parameters:

template – (dict | tuple[str, str, str, dict]): The file can be passed either as full specified json (dictionary) or as a tuple of three strings and a json (dictionary) specifying the paths to script, requirements and docker image in this order and template description (name, description, task etc.).

Returns:

Updated Experiment template by given ID.

Return type:

ExperimentTemplateResponse

Raises:

ApiException – In case of a failed HTTP request.

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
>>> }
>>> self.update((script_path, requirements_path, base_image, template_config))
Self # The instance is also updated in place.
model_config: ClassVar[ConfigDict] = {'populate_by_name': True, 'protected_namespaces': (), 'validate_assignment': True, 'validate_by_alias': True, 'validate_by_name': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class Experiment(*, id: Annotated[str, Strict(strict=True)], name: Annotated[str, Strict(strict=True)], description: Annotated[str, Strict(strict=True)], experiment_template_id: Annotated[str, Strict(strict=True)], is_mine: Annotated[bool, Strict(strict=True)], is_public: Annotated[bool, Strict(strict=True)], is_archived: Annotated[bool, Strict(strict=True)], created_at: datetime, updated_at: datetime, model_ids: List[Annotated[str, Strict(strict=True)]], dataset_ids: List[Annotated[str, Strict(strict=True)]], env_vars: List[EnvironmentVar], publication_ids: List[Annotated[str, Strict(strict=True)]] | None = None)[source]

AIoD - RAIL

Experiment class.

Implementation of class representing an instance of experiment and methods operating with this instance.

classmethod from_dict(obj: Dict[str, Any] | None, config: Configuration = None) Self | None[source]

Create an instance of Experiment from a dict.

Parameters:
  • obj (Optional[Dict[str, Any]]) – Obj representing the experiment in either a dictionary or

  • instance. (an already existing)

  • config (Configuration, optional) – The api configuration. Defaults to None.

Returns:

If input arg “obj” is None. Experiment: In successful conversion from dict.

Return type:

None

Examples

>>> experiment_dict = ...
>>> Experiment.from_dict(experiment_dict)
Experiment
classmethod from_json(json_str: str) Self[source]

Creates an instance of Experiment from a JSON string.

Parameters:

json_str – The JSON string to create the instance from.

Returns:

Instance of Experiment.

Return type:

Experiment

Examples

>>> experiment_json = ...
>>> Experiment.from_json(experiment_json)
Experiment
archive(archive: bool = False) None[source]

Archives specific experiment template specified by ID.

Parameters:

archive (bool) – If experiment should be archived or un-archived. Defaults to False.

Returns:

None.

Raises:

ApiException – In case of a failed HTTP request.

Examples

>>> self.archive(True)
>>> self.is_archived
True
count_runs() int[source]

Counts the number of runs of an experiment.

Returns:

Number of experiment runs of selected experiment.

Return type:

int

Raises:

ApiException – In case of a failed HTTP request.

Examples

>>> self.count_runs()
123
delete() None[source]

Delete specific experiment specified by ID.

Returns:

None.

Raises:

ApiException – In case of a failed HTTP request.

Examples

>>> self.delete()
>>> self._deleted
True
get_runs(offset: int = 0, limit: int = 100) List[ExperimentRun][source]

Gets runs of specified experiment in a selected range.

Parameters:
  • offset (int, optional) – Starting index of experiment run range from which to retrieve. Defaults to 0.

  • limit (int, optional) – Ending index of experiment run range to which to retrieve. Defaults to 100.

Returns:

None.

Raises:

ApiException – In case of a failed HTTP request.

Examples

>>> self.get_runs()
List[ExperimentRun] # associated with the specific experiment.
run() ExperimentRun[source]

Runs an experiment.

Returns:

Instance of the experiment run.

Return type:

ExperimentRun

Raises:

ApiException – In case of a failed HTTP request.

Examples

>>> self.run()
ExperimentRun
update(experiment: dict) Self[source]

Updates the experiment.

Parameters:

experiment (dict) – Dictionary containing updated experiment specification.

Returns:

Updated Experiment.

Return type:

Experiment

Raises:

ApiException – In case of a failed HTTP request.

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"}
>>>     ]
>>> }
>>> self.update(experiment_dict)
Self # The instance is also updated in place.
model_config: ClassVar[ConfigDict] = {'populate_by_name': True, 'protected_namespaces': (), 'validate_assignment': True, 'validate_by_alias': True, 'validate_by_name': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class ExperimentRun(*, id: Annotated[str, Strict(strict=True)], experiment_id: Annotated[str, Strict(strict=True)], retry_count: Annotated[int, Strict(strict=True)], is_mine: Annotated[bool, Strict(strict=True)], is_public: Annotated[bool, Strict(strict=True)], is_archived: Annotated[bool, Strict(strict=True)], created_at: datetime, updated_at: datetime, state: RunState, metrics: Dict[str, Annotated[float, Strict(strict=True)] | Annotated[int, Strict(strict=True)]])[source]

AIoD - RAIL

ExperimentRun class.

Implementation of class representing a specific experiment run with methods for operating on this run.

classmethod from_dict(obj: Dict[str, Any] | None, config: Configuration = None) Self | None[source]

Creates an instance of an ExperimentRun from dict.

Parameters:
  • obj (Optional[Dict[str, Any]]) – Obj representing the experiment run in either a dictionary or

  • instance. (an already existing)

  • config (Configuration, optional) – The configuration for api calls. Defaults to None.

Returns:

If input arg “obj” is None. ExperimentRun: In successful conversion from dict.

Return type:

None

Examples

>>> run_dict = ...
>>> ExperimentRun.from_dict(run_dict)
ExperimentRun
classmethod from_json(json_str: str) Self[source]

Creates an instance of Experiment run from a JSON string.

Parameters:

json_str – The JSON string to create the instance from.

Returns:

Instance of ExperimentRun.

Return type:

ExperimentRun

Examples

>>> run_json = ...
>>> ExperimentRun.from_json(run_json)
ExperimentRun
delete() None[source]

Deletes specific experiment run. Afterward, operations on deleted instance will result in HTTP exception.

Returns:

None.

Raises:

ApiException – In case of a failed HTTP request.

Examples

>>> self.delete()
>>> self._deleted
True
download_file(filepath: str, to_dir: str) None[source]

Downloads a specific file contained in outputs for the run.

Note

Based on the compute backend, it is quite possible that files from the experiment run will be stored under a directory named “output”. Therefore, if the download is failing, it is advised to try to prefix the desired path with “output”, e.g.: “output/path/to/remote.txt”

Parameters:
  • filepath (str) – File to be downloaded.

  • to_dir (Path) – Path to the local directory where the run file will be downloaded.

Returns:

None.

Raises:

ApiException: In case of a failed HTTP request.

Examples:
>>> self.download_file("output/path/to/remote.txt", "path/to/local/dir/")
None # a Specified file will be downloaded from the remote computing resource where the run is being executed.

logs() str[source]

Fetches the logs of the experiment run.

Returns:

Logs of experiment run.

Return type:

str

Raises:

ApiException – In case of a failed HTTP request.

Examples

>>> self.logs()
str # string dump of logs produced by the experiment run.
stop() None[source]

Stop the experiment run if it is currently executing.

Returns:

None.

Raises:

ApiException – In case of a failed HTTP request.

Examples

>>> self.stop()
>>> self.state
FINISHED
model_config: ClassVar[ConfigDict] = {'populate_by_name': True, 'protected_namespaces': (), 'validate_assignment': True, 'validate_by_alias': True, 'validate_by_name': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].