Backends#
Backends are responsible for storing and retrieving experiment data. A single backend is instantiated and associated with an experiment when it is created. By saving observations to disk, backends allow follow up experiments and anaylsis to be performed in future python sessions.
Available backends#
- class digital_experiments.backends.PickleBackend(root: Path)#
The default backend for storing results.
Each observation is stored in
<root>/<id>.pkl
. The result and configuration of each observation can be (almost) any python object, provided it can be pickled.
Creating your own backend#
Creating your own backend involves subclassing Backend
, implementing the
abstract methods, and registering your implementation so that you can subsequently use it by name.
- digital_experiments.backends.register_backend(name: str)#
Use this decorator (along with subclassing
Backend
) to register a new custom backend.Example
from digital_experiments import register_backend, Backend @register_backend("my-backend") class MyBackend(Backend): ... @experiment(backend="my-backend") def my_experiment(): ...
- class digital_experiments.backends.Backend(root: Path)#
Abstract base class for backends.
A backend is responsible for recording and loading
Observation
objects. All subclasses must override therecord()
,load()
, andall_ids()
methods.Other methods are optional, but can be overridden to provide further custom behaviour.
- abstract record(observation: Observation) None #
Record an
Observation
- abstract load(id: str) Observation #
Load an
Observation
by its id
- load_all() list[Observation] #
Load all
Observation
objects currently stored in this backend, sorted by id.