Compare commits

...

2 Commits

Author SHA1 Message Date
wdconinc
b7a2045c79 [@spackbot] updating style on behalf of wdconinc 2024-06-01 17:59:02 +00:00
Wouter Deconinck
2632106f1e feat: concretizer: prefer_older to force oldest dependency optimization 2024-06-01 09:46:56 -07:00
2 changed files with 11 additions and 4 deletions

View File

@@ -44,6 +44,7 @@
}, },
] ]
}, },
"prefer_older": {"type": "boolean"},
"enable_node_namespace": {"type": "boolean"}, "enable_node_namespace": {"type": "boolean"},
"targets": { "targets": {
"type": "object", "type": "object",

View File

@@ -1025,7 +1025,7 @@ def __iter__(self):
class SpackSolverSetup: class SpackSolverSetup:
"""Class to set up and run a Spack concretization solve.""" """Class to set up and run a Spack concretization solve."""
def __init__(self, tests: bool = False): def __init__(self, tests: bool = False, prefer_older=False):
# these are all initialized in setup() # these are all initialized in setup()
self.gen: "ProblemInstanceBuilder" = ProblemInstanceBuilder() self.gen: "ProblemInstanceBuilder" = ProblemInstanceBuilder()
self.possible_virtuals: Set[str] = set() self.possible_virtuals: Set[str] = set()
@@ -1058,6 +1058,8 @@ def __init__(self, tests: bool = False):
# whether to add installed/binary hashes to the solve # whether to add installed/binary hashes to the solve
self.tests = tests self.tests = tests
self.prefer_older = prefer_older
# If False allows for input specs that are not solved # If False allows for input specs that are not solved
self.concretize_everything = True self.concretize_everything = True
@@ -1091,7 +1093,9 @@ def key_fn(version):
list(sorted(group, reverse=True, key=lambda x: vn.ver(x.version))) list(sorted(group, reverse=True, key=lambda x: vn.ver(x.version)))
) )
for weight, declared_version in enumerate(most_to_least_preferred): for weight, declared_version in enumerate(
reversed(most_to_least_preferred) if self.prefer_older else most_to_least_preferred
):
self.gen.fact( self.gen.fact(
fn.pkg_fact( fn.pkg_fact(
pkg.name, pkg.name,
@@ -3800,6 +3804,8 @@ def __init__(self):
self.driver = PyclingoDriver() self.driver = PyclingoDriver()
self.selector = ReusableSpecsSelector(configuration=spack.config.CONFIG) self.selector = ReusableSpecsSelector(configuration=spack.config.CONFIG)
self.prefer_older = spack.config.get("concretizer:prefer_older", False)
@staticmethod @staticmethod
def _check_input_and_extract_concrete_specs(specs): def _check_input_and_extract_concrete_specs(specs):
reusable = [] reusable = []
@@ -3838,7 +3844,7 @@ def solve(
specs = [s.lookup_hash() for s in specs] specs = [s.lookup_hash() for s in specs]
reusable_specs = self._check_input_and_extract_concrete_specs(specs) reusable_specs = self._check_input_and_extract_concrete_specs(specs)
reusable_specs.extend(self.selector.reusable_specs(specs)) reusable_specs.extend(self.selector.reusable_specs(specs))
setup = SpackSolverSetup(tests=tests) setup = SpackSolverSetup(tests=tests, prefer_older=self.prefer_older)
output = OutputConfiguration(timers=timers, stats=stats, out=out, setup_only=setup_only) output = OutputConfiguration(timers=timers, stats=stats, out=out, setup_only=setup_only)
result, _, _ = self.driver.solve( result, _, _ = self.driver.solve(
setup, specs, reuse=reusable_specs, output=output, allow_deprecated=allow_deprecated setup, specs, reuse=reusable_specs, output=output, allow_deprecated=allow_deprecated
@@ -3867,7 +3873,7 @@ def solve_in_rounds(
specs = [s.lookup_hash() for s in specs] specs = [s.lookup_hash() for s in specs]
reusable_specs = self._check_input_and_extract_concrete_specs(specs) reusable_specs = self._check_input_and_extract_concrete_specs(specs)
reusable_specs.extend(self.selector.reusable_specs(specs)) reusable_specs.extend(self.selector.reusable_specs(specs))
setup = SpackSolverSetup(tests=tests) setup = SpackSolverSetup(tests=tests, prefer_older=self.prefer_older)
# Tell clingo that we don't have to solve all the inputs at once # Tell clingo that we don't have to solve all the inputs at once
setup.concretize_everything = False setup.concretize_everything = False