drytorch.core.experimenting
Module containing the Experiment and Run class.
Classes
|
Manage experiment configuration, directory, and tracking. |
|
Execution lifecycle for a single run of an Experiment. |
|
Metadata for a run. |
|
Creates and manages a JSON file for run metadata. |
- class Experiment(config: _T_co, *, name: str = '', par_dir: str | Path = PosixPath('.'), tags: list[str] | None = None)[source]
Bases:
Generic[_T_co]Manage experiment configuration, directory, and tracking.
This class associates a configuration file, a name, and a working directory with a machine learning experiment. It also contains the trackers responsible for tracking the metadata and metrics for the experiment. Finally, it allows global access to a configuration file with the correct type annotations.
- previous_runs
a list of all previous runs created by this class.
- Type:
ClassVar[list[drytorch.core.experimenting.Run]]
- par_dir
parent directory for experiment data.
- Type:
- trackers
dispatcher for publishing events.
Initialize.
- Parameters:
- property config: _T_co
Experiment configuration.
- create_run(*, run_id: str | None = None, resume: bool = False, record: bool = True) Run[_T_co][source]
Convenience constructor for a Run using this experiment.
- Parameters:
- Returns:
The created run object.
- Raises:
RunAlreadyRecordedError – if creating a new run with an existing id.
- Return type:
Run[_T_co]
- property run: Run[_T_co]
Get the current run.
- Raises:
NoActiveExperimentError – if no run is currently active.
- classmethod get_config() _T_co[source]
Retrieve the configuration of the current experiment.
- Return type:
_T_co
- classmethod get_current() Self[source]
Return the currently active experiment.
- Raises:
NoActiveExperimentError – if no experiment is currently active.
- Return type:
- static set_current(experiment: Experiment[_T_co]) None[source]
Set an experiment as active.
- Raises:
NestedScopeError – if there is an already active run.
- Parameters:
experiment (Experiment[_T_co])
- Return type:
None
- class Run(experiment: Experiment[_T_co], run_id: str | None, resumed: bool = False, record: bool = True)[source]
Bases:
CreatedAtMixin,Generic[_T_co]Execution lifecycle for a single run of an Experiment.
- status
Current status of the run.
- Type:
RunStatus
- metadata_manager
Manager for run metadata.
- Type:
Initialize.
- Parameters:
experiment (Experiment[_T_co]) – the experiment this run belongs to.
run_id (str | None) – identifier of the run.
resumed (bool) – whether the run was resumed.
record (bool) – record the run in the registry.
- property experiment: Experiment[_T_co]
The experiment this run belongs to.
- __exit__(exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None) None[source]
Exit the experiment scope.
- Parameters:
exc_type (type[BaseException] | None)
exc_val (BaseException | None)
exc_tb (TracebackType | None)
- Return type:
None