Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_try_resolve(self, cli_conflict):
"""Verify that resolution is achievable with valid cli change-type input"""
assert not cli_conflict.is_resolved
resolution = cli_conflict.try_resolve(evc.adapters.CommandLineChange.UNSURE)
assert isinstance(resolution, cli_conflict.CommandLineResolution)
assert cli_conflict.is_resolved
assert resolution.conflict is cli_conflict
assert resolution.type == evc.adapters.CommandLineChange.UNSURE
def test_adapters(self, change_dimension_resolution):
"""Verify adapters with old and new priors"""
name = "changed"
old_prior = "uniform(-10, 10)"
new_prior = "normal(0, 2)"
resolution_adapters = change_dimension_resolution.get_adapters()
assert len(resolution_adapters) == 1
assert (resolution_adapters[0].configuration ==
adapters.DimensionPriorChange(name, old_prior, new_prior).configuration)
def test_try_resolve(self, code_conflict):
"""Verify that resolution is achievable with valid code change-type input"""
assert not code_conflict.is_resolved
resolution = code_conflict.try_resolve(evc.adapters.CodeChange.UNSURE)
assert isinstance(resolution, code_conflict.CodeResolution)
assert code_conflict.is_resolved
assert resolution.conflict is code_conflict
assert resolution.type == evc.adapters.CodeChange.UNSURE
def test_adapters_with_default(self, missing_dimension_conflict):
"""Verify adapters with default value"""
param = {'name': 'missing', 'type': 'real', 'value': 1.2}
resolution = missing_dimension_conflict.RemoveDimensionResolution(
missing_dimension_conflict, default_value=1.2)
resolution_adapters = resolution.get_adapters()
assert len(resolution_adapters) == 1
assert (resolution_adapters[0].configuration ==
adapters.DimensionDeletion(param).configuration)
def code_resolution(code_conflict):
"""Create a resolution for a code conflict"""
return code_conflict.CodeResolution(code_conflict, adapters.CodeChange.BREAK)
def test_try_resolve(self, config_conflict):
"""Verify that resolution is achievable with valid config change-type input"""
assert not config_conflict.is_resolved
resolution = config_conflict.try_resolve(evc.adapters.ScriptConfigChange.UNSURE)
assert isinstance(resolution, config_conflict.ScriptConfigResolution)
assert config_conflict.is_resolved
assert resolution.conflict is config_conflict
assert resolution.type == evc.adapters.ScriptConfigChange.UNSURE
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)
def test_adapters(self, algorithm_resolution):
"""Verify shallow adapters for algorithm change"""
resolution_adapters = algorithm_resolution.get_adapters()
assert len(resolution_adapters) == 1
assert resolution_adapters[0].configuration == adapters.AlgorithmChange().configuration
def test_adapters_without_default(self, new_dimension_conflict):
"""Verify adapters without default values (filter everything out)"""
param = {'name': 'new', 'type': 'real', 'value': Dimension.NO_DEFAULT_VALUE}
resolution = new_dimension_conflict.AddDimensionResolution(new_dimension_conflict)
resolution_adapters = resolution.get_adapters()
assert len(resolution_adapters) == 1
assert (resolution_adapters[0].configuration ==
adapters.DimensionAddition(param).configuration)
def get_marked_arguments(self, conflicts):
"""Find and return marked arguments for cli change conflict
.. seealso::
:meth:`orion.core.evc.conflicts.Conflict.get_marked_arguments`
"""
change_type = self.new_config.get(self.CommandLineResolution.namespace())
if change_type:
return dict(change_type=change_type)
return dict(change_type=adapters.CommandLineChange.BREAK)