How to use the orion.core.io.experiment_builder.build function in orion

To help you get started, we’ve selected a few orion examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Epistimio / orion / tests / unittests / core / io / test_experiment_builder.py View on Github external
def test_build_hit(python_api_config):
    """Try building experiment from config when in db (no branch)"""
    name = 'supernaekei'

    with OrionState(experiments=[python_api_config], trials=[]):

        # Test that experiment already exists (this should fail otherwise)
        experiment_builder.build_view(name=name)

        exp = experiment_builder.build(**python_api_config)

    assert exp._id == python_api_config['_id']
    assert exp.name == python_api_config['name']
    assert exp.configuration['refers'] == python_api_config['refers']
    python_api_config['metadata']['user'] = 'dendi'
    assert exp.metadata == python_api_config['metadata']
    assert exp.max_trials == python_api_config['max_trials']
    assert exp.algorithms.configuration == python_api_config['algorithms']
github Epistimio / orion / tests / unittests / core / io / test_experiment_builder.py View on Github external
def test_instantiation_after_init(self, new_config):
        """Verify that algo, space and refers was instanciated properly"""
        with OrionState(experiments=[new_config], trials=[]):
            exp = experiment_builder.build(**new_config)

        assert isinstance(exp.algorithms, BaseAlgorithm)
        assert isinstance(exp.space, Space)
        assert isinstance(exp.refers['adapter'], BaseAdapter)
github Epistimio / orion / tests / unittests / core / io / test_experiment_builder.py View on Github external
def test_algo_case_insensitive(self, new_config):
        """Verify that algo with uppercase or lowercase leads to same experiment"""
        with OrionState(experiments=[new_config], trials=[]):
            new_config['algorithms']['DUMBALGO'] = new_config['algorithms'].pop('dumbalgo')
            exp = experiment_builder.build(**new_config)

            assert exp.version == 1
github Epistimio / orion / tests / unittests / core / io / test_experiment_builder.py View on Github external
def test_working_dir_is_correctly_set(self, new_config):
        """Check if working_dir is correctly changed."""
        with OrionState():
            new_config['working_dir'] = './'
            exp = experiment_builder.build(**new_config)
            storage = get_storage()
            found_config = list(storage.fetch_experiments({'name': 'supernaekei',
                                                           'metadata.user': 'tsirif'}))

            found_config = found_config[0]
            exp = experiment_builder.build(**found_config)
            assert exp.working_dir == './'
github Epistimio / orion / tests / unittests / core / io / test_experiment_builder.py View on Github external
def test_no_increment_when_child_exist(self):
        """Check that experiment cannot be incremented when asked for v1 while v2 exists."""
        name = 'parent'
        space = {'x': 'uniform(0,10)'}

        with OrionState(experiments=[], trials=[]):
            parent = experiment_builder.build(name=name, space=space)
            child = experiment_builder.build(name=name, space={'x': 'loguniform(1,10)'})
            assert child.name == parent.name
            assert parent.version == 1
            assert child.version == 2

            with pytest.raises(BranchingEvent) as exc_info:
                experiment_builder.build(name=name, version=1, space={'x': 'loguniform(1,10)'})
            assert 'Configuration is different and generates a branching' in str(exc_info.value)
github Epistimio / orion / tests / unittests / core / io / test_experiment_builder.py View on Github external
def test_old_experiment_w_version(self, parent_version_config, child_version_config):
        """Create an already existing experiment with a version."""
        with OrionState(experiments=[parent_version_config, child_version_config]):
            exp = experiment_builder.build(name=parent_version_config["name"], version=1)

        assert exp.version == 1
github Epistimio / orion / tests / unittests / core / io / test_experiment_builder.py View on Github external
def test_algorithm_config_with_just_a_string(self):
        """Test that configuring an algorithm with just a string is OK."""
        name = 'supernaedo3'
        space = {'x': 'uniform(0,10)'}
        algorithms = 'dumbalgo'

        with OrionState(experiments=[], trials=[]):
            exp = experiment_builder.build(name=name, space=space, algorithms=algorithms)

        assert exp.configuration['algorithms'] == {
            'dumbalgo': {
                'done': False,
                'judgement': None,
                'scoring': 0,
                'suspend': False,
                'value': 5,
                'seed': None}}
github Epistimio / orion / tests / unittests / core / io / test_experiment_builder.py View on Github external
def test_working_dir_works_when_db_absent(self, database, new_config):
        """Check if working_dir is correctly when absent from the database."""
        with OrionState(experiments=[], trials=[]):
            exp = experiment_builder.build(**new_config)
            storage = get_storage()
            found_config = list(storage.fetch_experiments({'name': 'supernaekei',
                                                           'metadata.user': 'tsirif'}))

            found_config = found_config[0]
            exp = experiment_builder.build(**found_config)
            assert exp.working_dir == ''
github Epistimio / orion / tests / unittests / core / io / test_experiment_builder.py View on Github external
def test_working_dir_works_when_db_absent(self, database, new_config):
        """Check if working_dir is correctly when absent from the database."""
        with OrionState(experiments=[], trials=[]):
            exp = experiment_builder.build(**new_config)
            storage = get_storage()
            found_config = list(storage.fetch_experiments({'name': 'supernaekei',
                                                           'metadata.user': 'tsirif'}))

            found_config = found_config[0]
            exp = experiment_builder.build(**found_config)
            assert exp.working_dir == ''
github Epistimio / orion / tests / unittests / core / io / test_experiment_builder.py View on Github external
def test_backward_compatibility_no_version(self, parent_version_config):
        """Branch from parent that has no version field."""
        parent_version_config.pop('version')
        with OrionState(experiments=[parent_version_config]):
            exp = experiment_builder.build(name=parent_version_config["name"],
                                           space={'y': 'uniform(0, 10)'})

        assert exp.version == 2