State management#
Experiment state#
The state of an experiment is defined by these attributes:
id_experiment
: UUID of the experiment.name
: Name of the experiment. If not provided, a short 6-alphanum hash ofid_experiment
is generated.db
: Database handler (discarded on pickling).fields
: Accessible at any time, with database storage.runs
: Collection ofruns
associated with the experiment implemented as a dictionary withrun
IDs as keys.
Run state#
The state of a run is defined by these attributes:
id_experiment
: UUID of the associated experiment.id_run
: UUID of the run.config
: Fixed parameters of therun
, cleared after execution.params
: Variable parameters of therun
, cleared after execution.vars
: Accessible only withinsteps
execution.state
: Accessible after execution ofsteps
.fields
: Accessible at any time, with database storage.exception
: Set transparently if thestep
raised an exception before raising the exception at experiment-level.steps
: Sequence of functions to execute, accessible only withinsteps
execution.
Tip
- For a comprehensive discussion of the semantics of the different attributes, see Model of computation.
- The
steps
attribute can be inspected by astep
function to read the Python source code of thesteps
, which can be used to track the state lineage and/or thesteps
code for backup and later analysis.
Example#
We programmatically print the attributes that constitute the strict state of experiments
and runs
, as well as the respective subsets that are considered for pickling. Declaring the __slots__ attribute allows us to declare explicitly which attributes are allowed, and deny the creation of new ones. This behaviour keeps these objects clean, and enforces the correct use of the available run
state attributes. The __state__
attribute is not inherited by Object, it simply defines a list of attributes to be considered by __getstate__ for pickling.
The state attributes of experiments and runs
Output
List of Experiment state attributes:
('id_experiment', 'name', 'fields', 'runs', 'db')
List of Experiment pickled attributes:
('id_experiment', 'name', 'fields', 'runs')
List of Run state attributes:
('id_experiment',
'id_run',
'config',
'params',
'fields',
'state',
'exception',
'vars',
'steps')
List of Run pickled attributes:
('id_experiment',
'id_run',
'config',
'params',
'fields',
'state',
'exception')