How to use orion - 10 common examples

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 / functional / branching / test_branching.py View on Github external
def test_branch_from_selected_version(clean_db, monkeypatch, database):
    """Test that branching from a version passed with `--version` works."""
    monkeypatch.chdir(os.path.dirname(os.path.abspath(__file__)))
    orion.core.cli.main("init_only -n experiment ./black_box.py -x~normal(0,1)".split(" "))
    orion.core.cli.main("init_only -n experiment ./black_box.py -x~normal(0,1) -y~+normal(0,1)"
                        .split(" "))
    orion.core.cli.main("init_only -n experiment --version 1 -b experiment_2 ./black_box.py "
                        "-x~normal(0,1) -z~+normal(0,1)".split(" "))

    parent = database.experiments.find({'name': 'experiment', 'version': 1})[0]
    exp = database.experiments.find({'name': 'experiment_2'})[0]
    assert exp['refers']['parent_id'] == parent['_id']
github Epistimio / orion / tests / functional / branching / test_branching.py View on Github external
def test_init_w_version_from_parent_w_children(clean_db, monkeypatch):
    """Test that init of experiment from version with children fails."""
    monkeypatch.chdir(os.path.dirname(os.path.abspath(__file__)))
    orion.core.cli.main("init_only -n experiment ./black_box.py -x~normal(0,1)".split(" "))
    orion.core.cli.main("init_only -n experiment ./black_box.py -x~normal(0,1) "
                        "-y~+normal(0,1)".split(" "))

    with pytest.raises(ValueError) as exc:
        orion.core.cli.main("init_only -n experiment -v 1 ./black_box.py "
                            "-x~normal(0,1) -y~+normal(0,1) -z~normal(0,1)".split(" "))

    assert "Experiment name" in str(exc.value)
github Epistimio / orion / tests / unittests / core / worker / test_experiment.py View on Github external
def test_good_set_before_init_no_hit(self, random_dt, database, new_config):
        """Trying to set, overwrite everything from input."""
        exp = Experiment(new_config['name'])
        exp.configure(new_config)
        assert exp._init_done is True
        found_config = list(database.experiments.find({'name': 'supernaekei',
                                                       'metadata.user': 'tsirif'}))

        new_config['metadata']['datetime'] = exp.metadata['datetime']

        assert len(found_config) == 1
        _id = found_config[0].pop('_id')
        assert _id != 'fasdfasfa'
        assert exp._id == _id
        new_config['refers'] = {}
        new_config.pop('_id')
        new_config.pop('something_to_be_ignored')
        new_config['algorithms']['dumbalgo']['done'] = False
        new_config['algorithms']['dumbalgo']['judgement'] = None
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 / worker / test_experiment.py View on Github external
def test_instantiation_after_init(self, exp_config):
        """Verify that algo, space and refers was instanciated properly"""
        exp = Experiment('supernaedo2-dendi')
        assert not isinstance(exp.algorithms, BaseAlgorithm)
        assert not isinstance(exp.space, Space)
        assert not isinstance(exp.refers['adapter'], BaseAdapter)
        # Deliver an external configuration to finalize init
        exp.configure(exp_config[0][0])
        assert exp._init_done is True
        assert isinstance(exp.algorithms, BaseAlgorithm)
        assert isinstance(exp.space, Space)
        assert isinstance(exp.refers['adapter'], BaseAdapter)
github Epistimio / orion / tests / functional / branching / test_branching.py View on Github external
def test_init(init_full_x, create_db_instance):
    """Test if original experiment contains trial 0"""
    experiment = ExperimentView('full_x')
    pairs = get_name_value_pairs(experiment.fetch_trials())
    assert pairs == ((('/x', 0), ), )
github Epistimio / orion / tests / unittests / core / evc / test_adapters.py View on Github external
def test_code_change_init(self):
        """Test initialization of :class:`orion.core.evc.adapters.CodeChange`
        with valid change types
        """
        code_change_adapter = CodeChange(CodeChange.NOEFFECT)
        assert code_change_adapter.change_type == CodeChange.NOEFFECT

        code_change_adapter = CodeChange(CodeChange.BREAK)
        assert code_change_adapter.change_type == CodeChange.BREAK
github Epistimio / orion / tests / unittests / core / evc / test_adapters.py View on Github external
def test_code_change_init(self):
        """Test initialization of :class:`orion.core.evc.adapters.CodeChange`
        with valid change types
        """
        code_change_adapter = CodeChange(CodeChange.NOEFFECT)
        assert code_change_adapter.change_type == CodeChange.NOEFFECT

        code_change_adapter = CodeChange(CodeChange.BREAK)
        assert code_change_adapter.change_type == CodeChange.BREAK
github Epistimio / orion / tests / functional / commands / test_status_command.py View on Github external
def test_experiment_w_child_w_name(clean_db, three_experiments_with_trials, capsys):
    """Test status with the name argument and one child."""
    orion.core.cli.main(['status', '--name', 'test_double_exp'])

    captured = capsys.readouterr().out

    expected = """\
test_double_exp-v1
==================
status         quantity
-----------  ----------
broken                1
completed             1
interrupted           1
new                   1
reserved              1
suspended             1