Skip to content
On this page

Running experiments

Executing experiments

Once implemented and configured, experiments can be executed by calling execute():

python
>>> from machinable import Experiment
>>> experiment = Experiment.instance('estimate_gravity')
>>> experiment.execute()
Assuming height of 52 and time of 0.3
The gravity on the exoplanet is:  1155.5555555555557

If the execution is successful, the experiment is marked as finished.

python
>>> experiment.is_finished()
True

Reproducibility

By design, experiment instances can only be executed once. They are automatically assigned a unique experiment ID, a random seed, as well as a nickname for easy identification.

python
>>> gravity = Experiment.instance('estimate_gravity')
>>> gravity.experiment_id
'GDCN4d'
>>> gravity.nickname
'jet_oak'
>>> gravity.seed
1632827863

Repeated invocations of execute() after the initial execution, are simply ignored. On the other hand, if an execution failed, calling execute() will resume the execution with the same random seed.

To replicate or reproduce a experiment, create a new experiment instance with the same configuration. Learn more about continuing and repeating experiments.

Execution implementations

Experiments can be executed in different ways. You may, for example, like to run experiments using multiprocessing. To configure the execution, execute() adopts the same module convention as Experiment.instance(). You can specify the execution implementation that you like to use by its module name and optionally provide configuration options in form of a dictionary, for example:

python
experiment.execute('myproject.execution.multiprocessing', {'processes': 1})

Just like in the case of experiments, this will instantiate a Execution class in the module myproject.execution.multiprocessing which will handle the execution.

Check out the execution guide to learn more about executions. You may also be interested in the execution examples that you may like to use in your projects.

MIT Licensed