deepcave.runs.run

# Run

This module provides utilities to create a new run and get its attributes.

## Classes
  • Run: Create a new run.

Classes

Run(name[, configspace, objectives, meta, path])

Create a new run and get its attributes.

class deepcave.runs.run.Run(name, configspace=None, objectives=None, meta=None, path=None)[source]

Bases: AbstractRun, ABC

Create a new run and get its attributes.

If path is given, runs are loaded from the path.

Properties

configspaceConfigurationSpace

The configuration space of the run.

pathOptional[Union[str, Path]]

The path of a run to be loaded. If path is not None, the given parameters are used. If path is None, the run is created from the given parameters.

metaDict[str, Any]

Contains serialized objectives and budgets.

prefixstr

The prefix for the id.

meta_fnPath

The path to the meta data.

configspace_fnPath

The path to the configuration space file.

configs_fnPath

The path to the configurations file.

origins_fnPath

The path to the origins file.

history_fnPath

The path to the history file.

models_dirPath

The path to the models directory.

configsDict[int, Configuration]

Containing the configurations.

modelsDict[int, Optional[Union[str, “torch.nn.Module”]]]

Contains the models.

add(costs, config, seed, budget=inf, start_time=0.0, end_time=0.0, status=Status.SUCCESS, origin=None, model=None, additional=None)[source]

Add a trial to the run.

If combination of config, seed, and budget already exists, it will be overwritten. Not successful runs are added with None costs.

Parameters:
  • costs (Union[List[float], float]) – Costs of the run. In case of multi-objective, a list of costs is expected.

  • config (Union[Dict, Configuration]) – The corresponding configuration.

  • seed (int) – Seed of the run.

  • budget (float, optional) – Budget of the run. By default np.inf

  • start_time (float, optional) – Start time. By default, 0.0

  • end_time (float, optional) – End time. By default, 0.0

  • status (Status, optional) – Status of the trial. By default, Status.SUCCESS

  • origin (str, optional) – Origin of the trial. By default, None

  • model (Union[str, "torch.nn.Module"], optional) – Model of the trial. By default, None

  • additional (Optional[Dict], optional) – Additional information of the trial. By default, None. Following information is used by DeepCAVE: * traceback

Raises:
  • RuntimeError – If number of costs does not match number of objectives.

  • ValueError – If config id is None.

Return type:

None

exists()[source]

Check if the run exists based on the internal path.

Returns:

If run exists.

Return type:

bool

abstract classmethod from_path(path)[source]

Based on a path, return a new Run object.

Parameters:

path (Path) – The path to get the run from.

Returns:

The run loaded from the path.

Return type:

“Run”

property id: str

Get a hash as id.

Returns:

The hashed id.

Return type:

str

load(path=None)[source]

Load the run.

Parameters:

path (Optional[Union[str, Path]], optional) – The path where to load the run from. Default is None.

Raises:

RuntimeError – If the path is None. If the trials were not found.

Return type:

None

property path: Path | None

Return the path of the run if it exists.

Returns:

The path of the run.

Return type:

Optional[Path]

save(path)[source]

Save the run and its information.

Parameters:

path (Optional[Union[str, Path]]) – The path in which to save the trials.

Raises:

RuntimeError – If the path is not specified.

Return type:

None