summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Kuhn <michael.kuhn@ovgu.de>2023-03-14 09:22:20 +0100
committerGitHub <noreply@github.com>2023-03-14 09:22:20 +0100
commit5bae7428261fa06ec60d66d7437d329ac0962a1a (patch)
treefcde4f3075b04e7f2628afcce4f0fd84dc06f591
parent03636cd6ac2859e800a23191b18de163de223a43 (diff)
downloadspack-5bae7428261fa06ec60d66d7437d329ac0962a1a.tar.gz
spack-5bae7428261fa06ec60d66d7437d329ac0962a1a.tar.bz2
spack-5bae7428261fa06ec60d66d7437d329ac0962a1a.tar.xz
spack-5bae7428261fa06ec60d66d7437d329ac0962a1a.zip
concretizer: add mode to reuse dependencies only (#30990)
This adds a new mode for `concretizer:reuse` called `dependencies`, which only reuses dependencies. Currently, `spack install foo` will reuse older versions of `foo`, which might be surprising to users.
-rw-r--r--etc/spack/defaults/concretizer.yaml5
-rw-r--r--lib/spack/spack/cmd/common/arguments.py10
-rw-r--r--lib/spack/spack/schema/concretizer.py4
-rw-r--r--lib/spack/spack/solver/asp.py13
-rw-r--r--lib/spack/spack/test/cmd/common/arguments.py13
-rwxr-xr-xshare/spack/spack-completion.bash18
6 files changed, 40 insertions, 23 deletions
diff --git a/etc/spack/defaults/concretizer.yaml b/etc/spack/defaults/concretizer.yaml
index df846c523a..caf500eb1f 100644
--- a/etc/spack/defaults/concretizer.yaml
+++ b/etc/spack/defaults/concretizer.yaml
@@ -13,8 +13,9 @@ concretizer:
# Whether to consider installed packages or packages from buildcaches when
# concretizing specs. If `true`, we'll try to use as many installs/binaries
# as possible, rather than building. If `false`, we'll always give you a fresh
- # concretization.
- reuse: true
+ # concretization. If `dependencies`, we'll only reuse dependencies but
+ # give you a fresh concretization for your root specs.
+ reuse: dependencies
# Options that tune which targets are considered for concretization. The
# concretization process is very sensitive to the number targets, and the time
# needed to reach a solution increases noticeably with the number of targets
diff --git a/lib/spack/spack/cmd/common/arguments.py b/lib/spack/spack/cmd/common/arguments.py
index 8302a43754..ae40f58fe0 100644
--- a/lib/spack/spack/cmd/common/arguments.py
+++ b/lib/spack/spack/cmd/common/arguments.py
@@ -514,7 +514,15 @@ def add_concretizer_args(subparser):
dest="concretizer:reuse",
const=True,
default=None,
- help="reuse installed dependencies/buildcaches when possible",
+ help="reuse installed packages/buildcaches when possible",
+ )
+ subgroup.add_argument(
+ "--reuse-deps",
+ action=ConfigSetAction,
+ dest="concretizer:reuse",
+ const="dependencies",
+ default=None,
+ help="reuse installed dependencies only",
)
diff --git a/lib/spack/spack/schema/concretizer.py b/lib/spack/spack/schema/concretizer.py
index cb021271c3..a62786f404 100644
--- a/lib/spack/spack/schema/concretizer.py
+++ b/lib/spack/spack/schema/concretizer.py
@@ -14,7 +14,9 @@ properties = {
"type": "object",
"additionalProperties": False,
"properties": {
- "reuse": {"type": "boolean"},
+ "reuse": {
+ "oneOf": [{"type": "boolean"}, {"type": "string", "enum": ["dependencies"]}]
+ },
"enable_node_namespace": {"type": "boolean"},
"targets": {
"type": "object",
diff --git a/lib/spack/spack/solver/asp.py b/lib/spack/spack/solver/asp.py
index 670dcf6ef9..1de346b80a 100644
--- a/lib/spack/spack/solver/asp.py
+++ b/lib/spack/spack/solver/asp.py
@@ -2502,7 +2502,7 @@ class Solver(object):
spack.spec.Spec.ensure_valid_variants(s)
return reusable
- def _reusable_specs(self):
+ def _reusable_specs(self, specs):
reusable_specs = []
if self.reuse:
# Specs from the local Database
@@ -2524,6 +2524,13 @@ class Solver(object):
# TODO: update mirror configuration so it can indicate that the
# TODO: source cache (or any mirror really) doesn't have binaries.
pass
+
+ # If we only want to reuse dependencies, remove the root specs
+ if self.reuse == "dependencies":
+ reusable_specs = [
+ spec for spec in reusable_specs if not any(root in spec for root in specs)
+ ]
+
return reusable_specs
def solve(self, specs, out=None, timers=False, stats=False, tests=False, setup_only=False):
@@ -2540,7 +2547,7 @@ class Solver(object):
"""
# Check upfront that the variants are admissible
reusable_specs = self._check_input_and_extract_concrete_specs(specs)
- reusable_specs.extend(self._reusable_specs())
+ reusable_specs.extend(self._reusable_specs(specs))
setup = SpackSolverSetup(tests=tests)
output = OutputConfiguration(timers=timers, stats=stats, out=out, setup_only=setup_only)
result, _, _ = self.driver.solve(setup, specs, reuse=reusable_specs, output=output)
@@ -2563,7 +2570,7 @@ class Solver(object):
tests (bool): add test dependencies to the solve
"""
reusable_specs = self._check_input_and_extract_concrete_specs(specs)
- reusable_specs.extend(self._reusable_specs())
+ reusable_specs.extend(self._reusable_specs(specs))
setup = SpackSolverSetup(tests=tests)
# Tell clingo that we don't have to solve all the inputs at once
diff --git a/lib/spack/spack/test/cmd/common/arguments.py b/lib/spack/spack/test/cmd/common/arguments.py
index f3348259e6..e889fe55d8 100644
--- a/lib/spack/spack/test/cmd/common/arguments.py
+++ b/lib/spack/spack/test/cmd/common/arguments.py
@@ -122,19 +122,18 @@ def test_root_and_dep_match_returns_root(mock_packages, mutable_mock_env_path):
assert env_spec2
-def test_concretizer_arguments(mutable_config, mock_packages):
+@pytest.mark.parametrize(
+ "arg,config", [("--reuse", True), ("--fresh", False), ("--reuse-deps", "dependencies")]
+)
+def test_concretizer_arguments(mutable_config, mock_packages, arg, config):
"""Ensure that ConfigSetAction is doing the right thing."""
spec = spack.main.SpackCommand("spec")
assert spack.config.get("concretizer:reuse", None) is None
- spec("--reuse", "zlib")
-
- assert spack.config.get("concretizer:reuse", None) is True
-
- spec("--fresh", "zlib")
+ spec(arg, "zlib")
- assert spack.config.get("concretizer:reuse", None) is False
+ assert spack.config.get("concretizer:reuse", None) == config
def test_use_buildcache_type():
diff --git a/share/spack/spack-completion.bash b/share/spack/spack-completion.bash
index 423e1a96c1..cae6d0cfce 100755
--- a/share/spack/spack-completion.bash
+++ b/share/spack/spack-completion.bash
@@ -480,7 +480,7 @@ _spack_bootstrap_mirror() {
_spack_build_env() {
if $list_options
then
- SPACK_COMPREPLY="-h --help --clean --dirty -U --fresh --reuse --dump --pickle"
+ SPACK_COMPREPLY="-h --help --clean --dirty -U --fresh --reuse --reuse-deps --dump --pickle"
else
_all_packages
fi
@@ -716,7 +716,7 @@ _spack_compilers() {
}
_spack_concretize() {
- SPACK_COMPREPLY="-h --help -f --force --test -q --quiet -U --fresh --reuse"
+ SPACK_COMPREPLY="-h --help -f --force --test -q --quiet -U --fresh --reuse --reuse-deps"
}
_spack_config() {
@@ -868,7 +868,7 @@ _spack_deprecate() {
_spack_dev_build() {
if $list_options
then
- SPACK_COMPREPLY="-h --help -j --jobs -d --source-path -i --ignore-dependencies -n --no-checksum --deprecated --keep-prefix --skip-patch -q --quiet --drop-in --test -b --before -u --until --clean --dirty -U --fresh --reuse"
+ SPACK_COMPREPLY="-h --help -j --jobs -d --source-path -i --ignore-dependencies -n --no-checksum --deprecated --keep-prefix --skip-patch -q --quiet --drop-in --test -b --before -u --until --clean --dirty -U --fresh --reuse --reuse-deps"
else
_all_packages
fi
@@ -1177,7 +1177,7 @@ _spack_info() {
_spack_install() {
if $list_options
then
- SPACK_COMPREPLY="-h --help --only -u --until -j --jobs --overwrite --fail-fast --keep-prefix --keep-stage --dont-restage --use-cache --no-cache --cache-only --use-buildcache --include-build-deps --no-check-signature --show-log-on-error --source -n --no-checksum --deprecated -v --verbose --fake --only-concrete --add --no-add -f --file --clean --dirty --test --log-format --log-file --help-cdash --cdash-upload-url --cdash-build --cdash-site --cdash-track --cdash-buildstamp -y --yes-to-all -U --fresh --reuse"
+ SPACK_COMPREPLY="-h --help --only -u --until -j --jobs --overwrite --fail-fast --keep-prefix --keep-stage --dont-restage --use-cache --no-cache --cache-only --use-buildcache --include-build-deps --no-check-signature --show-log-on-error --source -n --no-checksum --deprecated -v --verbose --fake --only-concrete --add --no-add -f --file --clean --dirty --test --log-format --log-file --help-cdash --cdash-upload-url --cdash-build --cdash-site --cdash-track --cdash-buildstamp -y --yes-to-all -U --fresh --reuse --reuse-deps"
else
_all_packages
fi
@@ -1449,7 +1449,7 @@ _spack_module_tcl_setdefault() {
_spack_patch() {
if $list_options
then
- SPACK_COMPREPLY="-h --help -n --no-checksum --deprecated -U --fresh --reuse"
+ SPACK_COMPREPLY="-h --help -n --no-checksum --deprecated -U --fresh --reuse --reuse-deps"
else
_all_packages
fi
@@ -1677,7 +1677,7 @@ _spack_restage() {
_spack_solve() {
if $list_options
then
- SPACK_COMPREPLY="-h --help --show -l --long -L --very-long -I --install-status -y --yaml -j --json -c --cover -N --namespaces -t --types --timers --stats -U --fresh --reuse"
+ SPACK_COMPREPLY="-h --help --show -l --long -L --very-long -I --install-status -y --yaml -j --json -c --cover -N --namespaces -t --types --timers --stats -U --fresh --reuse --reuse-deps"
else
_all_packages
fi
@@ -1686,7 +1686,7 @@ _spack_solve() {
_spack_spec() {
if $list_options
then
- SPACK_COMPREPLY="-h --help -l --long -L --very-long -I --install-status -y --yaml -j --json --format -c --cover -N --namespaces -t --types -U --fresh --reuse"
+ SPACK_COMPREPLY="-h --help -l --long -L --very-long -I --install-status -y --yaml -j --json --format -c --cover -N --namespaces -t --types -U --fresh --reuse --reuse-deps"
else
_all_packages
fi
@@ -1695,7 +1695,7 @@ _spack_spec() {
_spack_stage() {
if $list_options
then
- SPACK_COMPREPLY="-h --help -n --no-checksum --deprecated -p --path -U --fresh --reuse"
+ SPACK_COMPREPLY="-h --help -n --no-checksum --deprecated -p --path -U --fresh --reuse --reuse-deps"
else
_all_packages
fi
@@ -1785,7 +1785,7 @@ _spack_test_remove() {
_spack_test_env() {
if $list_options
then
- SPACK_COMPREPLY="-h --help --clean --dirty -U --fresh --reuse --dump --pickle"
+ SPACK_COMPREPLY="-h --help --clean --dirty -U --fresh --reuse --reuse-deps --dump --pickle"
else
_all_packages
fi