minto.v1.exp_dataspace#

Classes#

Space

Enumeration defining the types of spaces in the experiment data structure.

ExperimentDataSpace

A container class for managing experimental data with multiple runs.

Module Contents#

class Space(*args, **kwds)#

Bases: enum.Enum

Enumeration defining the types of spaces in the experiment data structure.

EXPERIMENT#

Space for experiment-wide data

RUN#

Space for individual run data

EXPERIMENT = 'experiment'#
RUN = 'run'#
class ExperimentDataSpace#

A container class for managing experimental data with multiple runs.

This class provides a structured way to organize and manage data from optimization experiments, including both experiment-wide data and data from individual runs.

Directory structure when saved: ``` base_dir/ ├── experiment/ # Experiment-wide data │ ├── problems_*.problem │ ├── instances_*.instance │ └── … └── runs/ # Individual run data

├── 0/ # First run │ ├── problems_*.problem │ ├── solutions_*.solution │ └── … ├── 1/ # Second run └── …

```

experiment_name#

Name identifier for the experiment

Type:

str

experiment_datastore#

Storage for experiment-wide data

Type:

DataStore

run_datastores#

List of storage for individual runs

Type:

list[DataStore]

version#

Version of the data space format

Type:

ClassVar[str]

exp_dirname#

Name of the experiment directory

Type:

ClassVar[str]

runs_dirname#

Name of the runs directory

Type:

ClassVar[str]

experiment_name: str#
experiment_datastore: minto.v1.datastore.DataStore#
run_datastores: list[minto.v1.datastore.DataStore] = []#
version: ClassVar[str] = '1.0'#
exp_dirname: ClassVar[str] = 'experiment'#
runs_dirname: ClassVar[str] = 'runs'#
add_run_datastore(run_datastore: minto.v1.datastore.DataStore, with_save=False, save_dir: str | pathlib.Path = '.') int#

Add a new run datastore to the experiment.

Parameters:

run_datastore (DataStore) – The datastore for the new run

Returns:

ID assigned to the new run

Return type:

int

Example

>>> exp_space = ExperimentDataSpace("optimization_exp")
>>> run_store = DataStore()
>>> run_id = exp_space.add_run_datastore(run_store)
add_exp_data(name: str, obj, storage_name: str, with_save=False, save_dir: str | pathlib.Path = '.')#

Add data to the experiment-wide storage.

Parameters:
  • name (str) – Identifier for the data

  • obj (Any) – The data to store

  • storage_name (str) – Type of storage to use

  • with_save (bool, optional) – Whether to save immediately. Defaults to False.

  • save_dir (str | Path, optional) – Directory for saving. Defaults to “.”

Example

>>> exp_space.add_exp_data("config", {"param": 1}, "objects")
add_run_data(run_id: int, name: str, obj, storage_name: str, with_save=False, save_dir: str | pathlib.Path = '.')#

Add data to a specific run’s storage.

Parameters:
  • run_id (int) – ID of the run to add data to

  • name (str) – Identifier for the data

  • obj (Any) – The data to store

  • storage_name (str) – Type of storage to use

  • with_save (bool, optional) – Whether to save immediately. Defaults to False.

  • save_dir (str | Path, optional) – Directory for saving. Defaults to “.”

Raises:

ValueError – If run_id is not found in run_datastores

save_dir(base_dir: str | pathlib.Path)#

Save all experiment data to a directory structure.

Creates a directory structure containing all experiment and run data, organized according to the standard layout.

Parameters:

base_dir (str | Path) – Base directory for saving data

classmethod load_from_dir(base_dir: str | pathlib.Path) ExperimentDataSpace#

Load an experiment data space from a directory structure.

Parameters:

base_dir (str | Path) – Base directory containing the experiment data

Returns:

New instance containing the loaded data

Return type:

ExperimentDataSpace

Raises:

Example

>>> exp_space = ExperimentDataSpace.load_from_dir("./experiments/exp1")
add_to_artifact_builder(builder: ommx.artifact.ArtifactBuilder)#

Add all experiment data to an OMMX artifact builder.

Adds both experiment-wide data and run data to the artifact builder, with appropriate annotations to maintain the hierarchical structure.

Parameters:

builder (ox_art.ArtifactBuilder) – The artifact builder to add data to

classmethod load_from_ommx_archive(path: str | pathlib.Path) ExperimentDataSpace#

Create an experiment data space from an OMMX artifact.

Loads and organizes data from an OMMX artifact, reconstructing the experiment and run structure based on layer annotations.

Parameters:

path (str | Path) – Path to the OMMX artifact file

Returns:

New instance containing the loaded data

Return type:

ExperimentDataSpace

Raises:

Notes

  • Uses layer annotations to distinguish between experiment and run data

  • Creates empty datastores for missing runs to maintain run ID sequence

  • Sets experiment_name to “unknown” if not found in metadata

classmethod load_from_ommx_artifact(artifact: ommx.artifact.Artifact) ExperimentDataSpace#

Create an experiment data space from an OMMX artifact.

Loads and organizes data from an OMMX artifact, reconstructing the experiment and run structure based on layer annotations.

Parameters:

artifact (ox_art.Artifact) – The OMMX artifact containing the data

Returns:

New instance containing the loaded data

Return type:

ExperimentDataSpace

Raises: