Skip to content

concretizer: don't change concrete environments without --force#37438

Merged
alalazo merged 6 commits intodevelopfrom
features/best-effort-iterative-coconcretization
May 14, 2023
Merged

concretizer: don't change concrete environments without --force#37438
alalazo merged 6 commits intodevelopfrom
features/best-effort-iterative-coconcretization

Conversation

@becker33
Copy link
Copy Markdown
Member

@becker33 becker33 commented May 4, 2023

Users generally don't want to change large chunks of their existing concrete environment, but Spack currently does that when using concretizer:unify:true (the default) and ``concretizer:unify:when_possible`. Reconcretizing large environments can also be slow, as Spack has to start from scratch and solve everything again.

We can do for unify:true and unify:when_possible what we already do for unify:false: preserve the existing concrete environment state. This PR adds that functionality, and it lets you invalidate the existing concrete state with spack concretize -f. Now, spack concretize will only concretize the new portions of the environment and spack concretize -f reconcretizes the entire environment.

@spackbot-app spackbot-app bot added commands core PR affects Spack core functionality documentation Improvements or additions to documentation environments tests General test capability(ies) labels May 4, 2023
@haampie
Copy link
Copy Markdown
Member

haampie commented May 4, 2023

I haven't looked at the code in detail, but it feels like a solid improvement to me, especially when you have a long list of specs already and just need to add a tiny package on top of it 👍

@becker33
Copy link
Copy Markdown
Member Author

becker33 commented May 4, 2023

@spackbot fix style

@spackbot-app
Copy link
Copy Markdown

spackbot-app bot commented May 4, 2023

Let me see if I can fix that for you!

@spackbot-app
Copy link
Copy Markdown

spackbot-app bot commented May 4, 2023

I was able to run spack style --fix for you!

spack style --fix
==> Running style checks on spack
  selected: isort, black, flake8, mypy
==> Modified files
  lib/spack/spack/environment/environment.py
  lib/spack/spack/test/cmd/env.py
==> Running isort checks
  isort checks were clean
==> Running black checks
reformatted lib/spack/spack/environment/environment.py
All done! ✨ 🍰 ✨
1 file reformatted, 1 file left unchanged.
  black checks were clean
==> Running flake8 checks
  flake8 checks were clean
==> Running mypy checks
Success: no issues found in 577 source files
  mypy checks were clean
==> spack style checks were clean
Keep in mind that I cannot fix your flake8 or mypy errors, so if you have any you'll need to fix them and update the pull request. If I was able to push to your branch, if you make further changes you will need to pull from your updated branch before pushing again.

I've updated the branch with style fixes.

@becker33 becker33 force-pushed the features/best-effort-iterative-coconcretization branch from 63695b2 to db9b860 Compare May 4, 2023 20:10
@becker33 becker33 added this to the v0.20.0 milestone May 8, 2023
@tgamblin tgamblin requested a review from alalazo May 13, 2023 08:43
@tgamblin
Copy link
Copy Markdown
Member

tgamblin commented May 13, 2023

@alalazo this is a really big improvement, IMO. Can you take a look at this for 0.20?

@becker33: I consolidated your original (duplicated) logic into a method and tweaked the docs and error messages a bit, but this looks great. See what you think of the changes.

I think this will make people way happier with Spack environments. IMO it's ready to go pending a confirming review.

tgamblin
tgamblin previously approved these changes May 13, 2023
@tgamblin tgamblin changed the title concretize unify: true and unify: when_possible without invalidating cached concrete specs concretizer: don't change concrete environments without --force May 13, 2023
@tgamblin
Copy link
Copy Markdown
Member

One thought on this (as a follow-on): I think it's actually good for Spack to fail fast if it would have to change any existing concrete specs in an env, but I also think that when using spack concretize -f without --fresh, that we should give higher weight to reusing existing concrete specs from the lock file than other specs in the DB. That would minimize changes to the existing env even with -f.

Copy link
Copy Markdown
Member

@alalazo alalazo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code LGTM. Test driven with the following example:
Screenshot from 2023-05-13 11-42-56

@alalazo alalazo merged commit a2a6e65 into develop May 14, 2023
@alalazo alalazo deleted the features/best-effort-iterative-coconcretization branch May 14, 2023 11:36
tgamblin pushed a commit that referenced this pull request May 16, 2023
…7681)

Two bugs came in from #37438

1. `unify: when_possible` was broken, because of an incorrect assertion. abstract/concrete
   spec pairs were compared against the results that were in the process of being computed,
   rather than against the previous results.
2. `unify: true` had an ordering bug that could mix the association between abstract and
   concrete specs

- [x] 1 is resolved by creating a lookup from old concrete specs to old abstract specs,
      and we use that to associate the "new" concrete specs that happen to be the old
      ones with their abstract specs (since those are stripped out for concretization
- [x] 2 is resolved by combining the new and old abstract as lists instead of combining
      them as sets. This is important because `set() | set()` does not make any ordering
      promises, even though set ordering is otherwise guaranteed in `python@3.7:`
alalazo pushed a commit that referenced this pull request May 16, 2023
…7681)

Two bugs came in from #37438

1. `unify: when_possible` was broken, because of an incorrect assertion. abstract/concrete
   spec pairs were compared against the results that were in the process of being computed,
   rather than against the previous results.
2. `unify: true` had an ordering bug that could mix the association between abstract and
   concrete specs

- [x] 1 is resolved by creating a lookup from old concrete specs to old abstract specs,
      and we use that to associate the "new" concrete specs that happen to be the old
      ones with their abstract specs (since those are stripped out for concretization
- [x] 2 is resolved by combining the new and old abstract as lists instead of combining
      them as sets. This is important because `set() | set()` does not make any ordering
      promises, even though set ordering is otherwise guaranteed in `python@3.7:`
alalazo pushed a commit that referenced this pull request May 16, 2023
…7681)

Two bugs came in from #37438

1. `unify: when_possible` was broken, because of an incorrect assertion. abstract/concrete
   spec pairs were compared against the results that were in the process of being computed,
   rather than against the previous results.
2. `unify: true` had an ordering bug that could mix the association between abstract and
   concrete specs

- [x] 1 is resolved by creating a lookup from old concrete specs to old abstract specs,
      and we use that to associate the "new" concrete specs that happen to be the old
      ones with their abstract specs (since those are stripped out for concretization
- [x] 2 is resolved by combining the new and old abstract as lists instead of combining
      them as sets. This is important because `set() | set()` does not make any ordering
      promises, even though set ordering is otherwise guaranteed in `python@3.7:`
haampie pushed a commit that referenced this pull request May 16, 2023
…7681)

Two bugs came in from #37438

1. `unify: when_possible` was broken, because of an incorrect assertion. abstract/concrete
   spec pairs were compared against the results that were in the process of being computed,
   rather than against the previous results.
2. `unify: true` had an ordering bug that could mix the association between abstract and
   concrete specs

- [x] 1 is resolved by creating a lookup from old concrete specs to old abstract specs,
      and we use that to associate the "new" concrete specs that happen to be the old
      ones with their abstract specs (since those are stripped out for concretization
- [x] 2 is resolved by combining the new and old abstract as lists instead of combining
      them as sets. This is important because `set() | set()` does not make any ordering
      promises, even though set ordering is otherwise guaranteed in `python@3.7:`
alalazo pushed a commit that referenced this pull request May 18, 2023
…7681)

Two bugs came in from #37438

1. `unify: when_possible` was broken, because of an incorrect assertion. abstract/concrete
   spec pairs were compared against the results that were in the process of being computed,
   rather than against the previous results.
2. `unify: true` had an ordering bug that could mix the association between abstract and
   concrete specs

- [x] 1 is resolved by creating a lookup from old concrete specs to old abstract specs,
      and we use that to associate the "new" concrete specs that happen to be the old
      ones with their abstract specs (since those are stripped out for concretization
- [x] 2 is resolved by combining the new and old abstract as lists instead of combining
      them as sets. This is important because `set() | set()` does not make any ordering
      promises, even though set ordering is otherwise guaranteed in `python@3.7:`
@uturuncoglu
Copy link
Copy Markdown
Contributor

@becker33 @alalazo I found an issue with this PR and I am not sure it is expected or not. It seems that it prevents me to install beta snapshots of the package (the tags that are not included into package.py). For example, following command spack install esmf@v8.5.0b10 creates following output with this PR,

==> Error: concretization failed for the following reasons:

   1. Cannot satisfy 'esmf@v8.5.0b10'

but if use the code without these changes, it installs the package without any issue. Anyway, I need to have this capability since we are testing different versions of the ESMF package and it would be hard to add all the beta snapshots to the package.py. So, is there any other way to workaround the issue. Is this a bug? Any idea?

@uturuncoglu
Copy link
Copy Markdown
Contributor

@becker33 @alalazo @tgamblin I could open an issue about it if you want.

vjranagit pushed a commit to vjranagit/spack that referenced this pull request Jan 18, 2026
…ack#37681)

Two bugs came in from spack#37438

1. `unify: when_possible` was broken, because of an incorrect assertion. abstract/concrete
   spec pairs were compared against the results that were in the process of being computed,
   rather than against the previous results.
2. `unify: true` had an ordering bug that could mix the association between abstract and
   concrete specs

- [x] 1 is resolved by creating a lookup from old concrete specs to old abstract specs,
      and we use that to associate the "new" concrete specs that happen to be the old
      ones with their abstract specs (since those are stripped out for concretization
- [x] 2 is resolved by combining the new and old abstract as lists instead of combining
      them as sets. This is important because `set() | set()` does not make any ordering
      promises, even though set ordering is otherwise guaranteed in `python@3.7:`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands core PR affects Spack core functionality documentation Improvements or additions to documentation environments tests General test capability(ies)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants