How to use the orion.core.io.experiment_branch_builder.ExperimentBranchBuilder 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 / test_branch_config.py View on Github external
def test_bad_name_experiment(self, parent_config, child_config, monkeypatch):
        """Test if experiment name conflict is not resolved when invalid name is marked"""
        def _is_unique(self, *args, **kwargs):
            return False

        monkeypatch.setattr(ExperimentNameConflict.ExperimentNameResolution, "_name_is_unique",
                            _is_unique)

        conflicts = detect_conflicts(parent_config, child_config)
        ExperimentBranchBuilder(conflicts, {'branch': 'test2'})

        assert len(conflicts.get()) == 1
        assert len(conflicts.get_resolved()) == 0
github Epistimio / orion / tests / unittests / core / test_branch_config.py View on Github external
def test_remove_missing_bad_default(self, parent_config, child_config):
        """Test if missing dimension conflict raises an error if marked with invalid default"""
        child_config['metadata']['user_args'][1] = '-x~--100'
        backward.populate_priors(child_config['metadata'])
        conflicts = detect_conflicts(parent_config, child_config)
        ExperimentBranchBuilder(conflicts, {'manual_resolution': True})

        assert len(conflicts.get()) == 2
        assert len(conflicts.get_resolved()) == 1

        conflict = conflicts.get()[1]

        assert not conflict.is_resolved
        assert isinstance(conflict, MissingDimensionConflict)
github Epistimio / orion / tests / unittests / core / test_branch_config.py View on Github external
def test_add_new_default(self, parent_config, new_config):
        """Test if new dimension conflict is automatically resolved"""
        new_config['metadata']['user_args'][-1] = '-w_d~+normal(0,1,default_value=0)'
        backward.populate_priors(new_config['metadata'])
        conflicts = detect_conflicts(parent_config, new_config)
        ExperimentBranchBuilder(conflicts, {'manual_resolution': True})

        assert len(conflicts.get()) == 2
        assert len(conflicts.get_resolved()) == 2

        conflict = conflicts.get_resolved()[1]

        assert conflict.is_resolved
        assert isinstance(conflict.resolution, conflict.AddDimensionResolution)
        assert conflict.resolution.default_value == 0.0
github Epistimio / orion / tests / unittests / core / test_branch_config.py View on Github external
def test_add_changed(self, parent_config, changed_config):
        """Test if adding a changed dimension solves the conflict"""
        conflicts = detect_conflicts(parent_config, changed_config)
        branch_builder = ExperimentBranchBuilder(conflicts, {'manual_resolution': True})
        branch_builder.add_dimension('y')

        assert len(conflicts.get()) == 2
        assert len(conflicts.get_resolved()) == 2

        conflict = conflicts.get_resolved()[0]

        assert conflict.is_resolved
        assert isinstance(conflict.resolution, conflict.ChangeDimensionResolution)
github Epistimio / orion / tests / unittests / core / test_branch_config.py View on Github external
def test_name_experiment(self, parent_config, child_config, create_db_instance):
        """Test if experiment name conflict is automatically resolved"""
        new_name = 'test2'
        create_db_instance.write('experiments', parent_config)
        conflicts = detect_conflicts(parent_config, child_config)
        ExperimentBranchBuilder(conflicts, {'branch': new_name})

        assert len(conflicts.get()) == 1
        assert len(conflicts.get_resolved()) == 1

        conflict = conflicts.get()[0]

        assert conflict.resolution.new_name == new_name
        assert conflict.new_config['name'] == new_name
        assert conflict.is_resolved
github Epistimio / orion / tests / unittests / core / test_branch_config.py View on Github external
def test_rename_missing(self, parent_config, missing_config):
        """Test if renaming a dimension to another solves both conflicts"""
        missing_config['metadata']['user_args'].append('-w_d~uniform(0,1)')
        backward.populate_priors(missing_config['metadata'])
        conflicts = detect_conflicts(parent_config, missing_config)
        branch_builder = ExperimentBranchBuilder(conflicts, {'manual_resolution': True})
        branch_builder.rename_dimension('x', 'w_d')

        assert len(conflicts.get()) == 4

        assert conflicts.get([ExperimentNameConflict])[0].is_resolved
        assert conflicts.get([NewDimensionConflict])[0].is_resolved
        assert conflicts.get([MissingDimensionConflict])[0].is_resolved
        assert not conflicts.get([MissingDimensionConflict])[1].is_resolved

        resolved_conflicts = conflicts.get_resolved()
        assert len(resolved_conflicts) == 3
        assert resolved_conflicts[1].resolution is resolved_conflicts[2].resolution
        assert isinstance(resolved_conflicts[1].resolution,
                          resolved_conflicts[1].RenameDimensionResolution)
        assert resolved_conflicts[1].resolution.conflict.dimension.name == '/x'
        assert resolved_conflicts[1].resolution.new_dimension_conflict.dimension.name == '/w_d'
github Epistimio / orion / tests / unittests / core / test_branch_config.py View on Github external
def test_remove_missing(self, parent_config, missing_config):
        """Test if removing a missing dimension solves the conflict"""
        conflicts = detect_conflicts(parent_config, missing_config)
        branch_builder = ExperimentBranchBuilder(conflicts, {'manual_resolution': True})
        branch_builder.remove_dimension('x')

        assert len(conflicts.get()) == 3
        assert len(conflicts.get_resolved()) == 2

        conflict = conflicts.get_resolved()[1]

        assert conflict.is_resolved
        assert isinstance(conflict.resolution, conflict.RemoveDimensionResolution)
github Epistimio / orion / tests / unittests / core / test_branch_config.py View on Github external
def test_cli_change(self, parent_config, changed_cli_config):
        """Test if command line conflict is resolved automatically"""
        change_type = evc.adapters.CommandLineChange.types[0]
        changed_cli_config['cli_change_type'] = change_type
        conflicts = detect_conflicts(parent_config, changed_cli_config)
        ExperimentBranchBuilder(conflicts, {'manual_resolution': True})

        assert len(conflicts.get()) == 2
        assert len(conflicts.get_resolved()) == 2

        conflict = conflicts.get_resolved()[0]

        assert conflict.is_resolved
        assert isinstance(conflict.resolution, conflict.CommandLineResolution)
        assert conflict.resolution.type == change_type
github Epistimio / orion / tests / unittests / core / test_branch_config.py View on Github external
def test_rename_missing_changed_marked(self, parent_config, child_config):
        """Test if renaming is automatically applied with all conflicts resolved including
        the new one caused by prior change
        """
        child_config['metadata']['user_args'].append('-w_a~uniform(0,1)')
        child_config['metadata']['user_args'].append('-w_b~+normal(0,1)')
        child_config['metadata']['user_args'][1] = '-x~>w_b'
        backward.populate_priors(child_config['metadata'])
        conflicts = detect_conflicts(parent_config, child_config)
        ExperimentBranchBuilder(conflicts, {'manual_resolution': True})

        assert len(conflicts.get()) == 5

        assert conflicts.get([ExperimentNameConflict])[0].is_resolved
        assert conflicts.get(dimension_name='x')[0].is_resolved
        assert conflicts.get([NewDimensionConflict], dimension_name='w_b')[0].is_resolved
        assert conflicts.get([ChangedDimensionConflict], dimension_name='w_b')[0].is_resolved
        assert not conflicts.get(dimension_name='w_a')[0].is_resolved

        resolved_conflicts = conflicts.get_resolved()
        assert len(resolved_conflicts) == 4
        assert resolved_conflicts[1].resolution is resolved_conflicts[2].resolution
        assert isinstance(resolved_conflicts[1].resolution,
                          resolved_conflicts[1].RenameDimensionResolution)
        assert resolved_conflicts[1].resolution.conflict.dimension.name == '/x'
        assert resolved_conflicts[1].resolution.new_dimension_conflict.dimension.name == '/w_b'
github Epistimio / orion / tests / unittests / core / test_branch_config.py View on Github external
def test_algo_change(self, parent_config, changed_algo_config):
        """Test if algorithm conflict is resolved automatically"""
        changed_algo_config['algorithm_change'] = True
        conflicts = detect_conflicts(parent_config, changed_algo_config)
        ExperimentBranchBuilder(conflicts, {'manual_resolution': True})

        assert len(conflicts.get()) == 2
        assert len(conflicts.get_resolved()) == 2

        conflict = conflicts.get_resolved()[0]

        assert conflict.is_resolved
        assert isinstance(conflict.resolution, conflict.AlgorithmResolution)