How to use the orion.core.evc.conflicts.detect_conflicts 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_add_new(self, parent_config, new_config):
        """Test if adding a new dimension solves the conflict"""
        conflicts = detect_conflicts(parent_config, new_config)
        branch_builder = ExperimentBranchBuilder(conflicts, {'manual_resolution': True})
        branch_builder.add_dimension('w_d')

        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)
github Epistimio / orion / tests / unittests / core / test_branch_config.py View on Github external
def test_remove_missing(self, parent_config, child_config):
        """Test if missing dimension conflict is automatically resolved"""
        child_config['metadata']['user_args'][1] = '-x~-'
        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()) == 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_algo_conflict(self, parent_config, changed_algo_config):
        """Test if algorithm changes are currently detected"""
        conflicts = detect_conflicts(parent_config, changed_algo_config)

        assert len(conflicts.get()) == 2
        conflict = conflicts.get()[0]

        assert conflict.is_resolved is False
        assert conflict.old_config['algorithms'] == 'random'
        assert conflict.new_config['algorithms'] == 'stupid-grid'
        assert isinstance(conflict, AlgorithmConflict)
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 giving a proper change-type solves the command line conflict"""
        conflicts = detect_conflicts(parent_config, changed_cli_config)
        branch_builder = ExperimentBranchBuilder(conflicts, {'manual_resolution': True})

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

        branch_builder.set_cli_change_type(evc.adapters.CommandLineChange.types[0])

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

        conflict = conflicts.get_resolved()[1]
        assert conflict.is_resolved
        assert isinstance(conflict, CommandLineConflict)
github Epistimio / orion / tests / unittests / core / test_branch_config.py View on Github external
def test_adapter_rename_different_prior(self, parent_config, cl_config):
        """Test if a DimensionRenaming is created when solving a new conflict"""
        cl_config['metadata']['user_args'] = ['-x~>w_d', '-w_d~+normal(0,1)']

        conflicts = detect_conflicts(parent_config, cl_config)
        branch_builder = ExperimentBranchBuilder(conflicts, {'manual_resolution': True})

        adapters = branch_builder.create_adapters().adapters

        assert len(conflicts.get_resolved()) == 4
        assert len(adapters) == 2
        assert isinstance(adapters[0], evc.adapters.DimensionRenaming)
        assert isinstance(adapters[1], evc.adapters.DimensionPriorChange)
github Epistimio / orion / tests / unittests / core / test_branch_config.py View on Github external
def test_add_bad_default(self, parent_config, new_config):
        """Test if new dimension conflict raises an error if marked with invalid default value"""
        new_config['metadata']['user_args'][-1] = '-w_d~+normal(0,1,default_value=\'a\')'
        backward.populate_priors(new_config['metadata'])
        with pytest.raises(TypeError) as exc:
            detect_conflicts(parent_config, new_config)
        assert "Parameter \'/w_d\': Incorrect arguments." in str(exc.value)
github Epistimio / orion / tests / unittests / core / test_branch_config.py View on Github external
def test_adapter_add_changed(self, parent_config, cl_config):
        """Test if a DimensionPriorChange is created when solving a new conflict"""
        cl_config['metadata']['user_args'] = ['-y~+uniform(0,1)']

        conflicts = detect_conflicts(parent_config, cl_config)
        branch_builder = ExperimentBranchBuilder(conflicts, {'manual_resolution': True})

        adapters = branch_builder.create_adapters().adapters

        assert len(conflicts.get_resolved()) == 2
        assert len(adapters) == 1
        assert isinstance(adapters[0], evc.adapters.DimensionPriorChange)
github Epistimio / orion / tests / unittests / core / test_branch_config.py View on Github external
def test_no_conflicts(self, parent_config, child_config):
        """Test the case where the child is the same as the parent"""
        conflicts = detect_conflicts(parent_config, child_config)

        assert len(conflicts.get()) == 1
        assert isinstance(conflicts.get()[0], ExperimentNameConflict)
github Epistimio / orion / tests / unittests / core / test_branch_config.py View on Github external
def test_cli_conflict(self, parent_config, changed_cli_config):
        """Test if changed command line call is detected as a conflict"""
        conflicts = detect_conflicts(parent_config, changed_cli_config)

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

        assert not conflicts.get([ExperimentNameConflict])[0].is_resolved
        assert not conflicts.get([CommandLineConflict])[0].is_resolved
github Epistimio / orion / tests / unittests / core / test_branch_config.py View on Github external
def test_rename_missing_changed(self, parent_config, missing_config):
        """Test if renaming a dimension to another with different prior solves both conflicts but
        creates a new one which is not solved
        """
        missing_config['metadata']['user_args'].append('-w_d~normal(0,1)')
        backward.populate_priors(missing_config['metadata'])
        conflicts = detect_conflicts(parent_config, missing_config)
        branch_builder = ExperimentBranchBuilder(conflicts, {'manual_resolution': True})

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

        branch_builder.rename_dimension('x', 'w_d')

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

        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
        assert not conflicts.get([ChangedDimensionConflict])[0].is_resolved

        resolved_conflicts = conflicts.get_resolved()
        assert len(resolved_conflicts) == 3