State (storage)

Mocks Oríon’s runtime

Boilerplate to simulate Oríon’s runtime and data sources.

class orion.testing.state.BaseOrionState(benchmarks=None, experiments=None, trials=None, workers=None, lies=None, resources=None, from_yaml=None, storage=None)[source]

Setup global variables and storage for tests.

It generates a new storage configuration and swaps it, the previous configuration is restored after the test. It also initializes PickleDB as the storage for testing. We use PickledDB as our storage mock

Parameters
benchmarks: List, optional

List of benchmarks to insert into the database

experiments: list, optional

List of experiments to insert into the database

trials: list, optional

List of trials to insert into the database

workers: list, optional

List of workers to insert into the database

lies: list, optional

List of lies to insert into the database

resources: list, optional

List of resources to insert into the database

from_yaml: YAML, optional

YAML config to apply for this test

storage: dict, optional

Configuration of the underlying storage backend

Examples

>>> my_config = {...}
>>> with OrionState(my_config):
    ...

Methods

add_experiments(*experiments)

Add experiments to the database

add_trials(*trials)

Add trials to the database

cleanup()

Cleanup after testing

get_experiment(name[, version])

Make experiment id deterministic

get_trial(index)

Return a Trial

init(config)

Initialize environment before testing

load_experience_configuration()

Load an example database.

make_config()

Iterate over the database configuration and replace ${file} by the name of a temporary file

setup_storage([config])

Return test storage

add_experiments(*experiments)[source]

Add experiments to the database

add_trials(*trials)[source]

Add trials to the database

cleanup()[source]

Cleanup after testing

get_experiment(name, version=None)[source]

Make experiment id deterministic

get_trial(index)[source]

Return a Trial

init(config)[source]

Initialize environment before testing

load_experience_configuration()[source]

Load an example database.

make_config()[source]

Iterate over the database configuration and replace ${file} by the name of a temporary file

setup_storage(config=None)[source]

Return test storage

class orion.testing.state.LegacyOrionState(*args, **kwargs)[source]

See BaseOrionState()

Attributes
database

Retrieve legacy database handle

Methods

cleanup()

Cleanup after testing

get_experiment(name[, version])

Make experiment id deterministic

init(config)

Initialize environment before testing

cleanup()[source]

Cleanup after testing

property database

Retrieve legacy database handle

get_experiment(name, version=None)[source]

Make experiment id deterministic

init(config)[source]

Initialize environment before testing

orion.testing.state.OrionState(*args, **kwargs)[source]

Build an orion state in function of the storage type