ASP-based solver: allow to reuse installed externals#31558
ASP-based solver: allow to reuse installed externals#31558becker33 merged 7 commits intospack:developfrom
Conversation
740297b to
e5ac540
Compare
lib/spack/spack/solver/concretize.lp
Outdated
|
|
||
| % if a package is not buildable (external_only), only externals are allowed | ||
| external(Package) :- external_only(Package), node(Package). | ||
| external(Package) :- external_only(Package), |
There was a problem hiding this comment.
I think this will allow you to reuse a non-external even when buildable: false for that package. Can you add a test for this?
There was a problem hiding this comment.
I don't think this is wrong. It will allow what you say only if the non-external is already installed, so not buildable, but built. Disallowing that case causes the bug in this way:
- Install an external that is not buildable
- Can't reuse the same external at the next concretization
adamjstewart
left a comment
There was a problem hiding this comment.
Works like a charm, thanks for the quick fix!
Also tested that the tests do indeed fail without this change.
lib/spack/spack/test/concretize.py
Outdated
| @pytest.mark.regression('31484') | ||
| def test_installed_builds_not_reused_buildable_false( | ||
| self, mutable_database, repo_with_changing_recipe | ||
| ): |
There was a problem hiding this comment.
@becker33 I have been getting back at this specific test, and I think this is behavior we don't want to add as it is coded here. The only things we currently say for buildable: false in our documentation are:
The addition of the buildable flag tells Spack that it should never build its own version of OpenMPI, and it will instead always rely on a pre-built OpenMPI.
The buildable does not need to be paired with external packages. It could also be used alone to forbid packages that may be buggy or otherwise undesirable.
[ ... ]
and they clearly stem from a world where reuse was not a considered at all. It seems thus a stretch to me to require that buildable: false prevents the reuse of software that is either installed locally or available from a buildcache.
That said, I concur, based on our discussion on Slack, that there's a gap in expressiveness that we need to fill. For instance, as you pointed out:
packages:
mpi:
buildable: falselikely means that the user wants to install only from one of the externals that might be listed in the same file. But what if it is:
packages:
trilinos:
buildable: falseCouldn't that be a way to say "Reuse a binary version of trilinos and never build that from sources"? I wouldn't find that request "crazy", if a binary cache is available.
I think the point is: buildable: false was added before reuse and we didn't figure out how the two should interact together. That is possibly what needs to get fixed (allow the user to express in which of the two cases they are), not excluding specs from reuse based on buildable: false.
TL;DR I agree that here we miss ways to express a few requests, but would it be possible to get the bugfix in as is, and work on a more extensive feature in a following PR? lf not I'm tempted to move this out of the v0.18.1 project, since it likely means it won't be solved soon.
There was a problem hiding this comment.
I still don't see how someone using this is supposed to use system mpi, and I don't think that's a use case we can afford to break.
@becker33 Fair, I already moved this to the next bugfix release. Do you agree though that the test, as is, is not something we want to force implicitly?
|
I still don't see how someone using this is supposed to use system mpi, and I don't think that's a use case we can afford to break. |
|
@becker33 @alalazo any updates on this? Spack is basically unusable on macOS if you update develop frequently. Not sure if there's a priority level higher than "impact-high" lol. I've been using this PR locally on a couple systems since this PR was first opened and I would like to no longer have to use that local modification. |
|
@adamjstewart There is currently an issue, that @becker33 pointed out, that is hard to solve in this PR alone. My thoughts on this are:
Rationale is that, if we have requirements, we can specify there what needs to be used. |
|
@alalazo @adamjstewart @becker33 is there a quick fix for getting this in for macos platforms? |
|
Amazing! Thanks @alalazo ! |
|
Is the test the only thing that was preventing this PR from being merged? I was under the impression that there was a problem with the solution itself. |
|
@adamjstewart The issue that @becker33 was raising is that we don't have a way to discriminate between an external and a binary package when mpi:
buildable: false
packages:
openmpi:
externals:
- spec: "[email protected]"and be sure it is using the external spec. I think with #27987 we can use hard-requirements to pin the required |
e386132 to
5d44b27
Compare
|
I added a new test. Currently users can select an external, by imposing unsatisfiable requirements on other providers that could otherwise be reused. This is not ideal, but works. If people agree (@adamjstewart @sethrj @becker33) I would merge the bug fix like it is for the time being, and then start working on extending the packages:
mpi:
buildable: false
require: '[email protected]'
openmpi:
externals:
- spec: '[email protected]'
prefix: /usrapplied whenever EDIT: Pinging @scheibelp as he may want to comment on the extension sketched above. |
5d44b27 to
1491716
Compare
|
@becker33 Would #31558 (comment) be fine with you? |
|
@becker33 any updates on this? |
|
For the record: I submitted #32369 today so I hope we'll converge to the syntax in #31558 (comment) pretty soon (no matter whether this PR or #32369 gets merged first). |
fixes spack#31484 Before this change if anything was matching an external condition, it was considered "external" and thus something to be "built". This was happening in particular to external packages that were re-read from the DB, which then couldn't be reused, causing the problems shown in spack#31484. This PR fixes the issue by excluding specs with a "hash" from being considered "external"
Currently, users have to resort to a workaround, i.e. they have to put unsatisfiable requirements on reusable packages they could otherwise pick. This ought to be solved by extending the "require" attribute to virtual packages, so that one can: ```yaml mpi: require: 'multi-provider-mpi' ```
1491716 to
ad7d74c
Compare
|
#32369 has just been merged, and the second unit test updated accordingly |
| assert external3.dag_hash() == external1.dag_hash() | ||
|
|
||
| @pytest.mark.regression("31484") | ||
| def test_user_can_select_externals_with_require(self, mutable_database): |
There was a problem hiding this comment.
If I understand correctly, this only ensures we can force the provider, not the specific spec.
$ spack install [email protected]
$ spack config add packages:mvapich2:buildable:false
$ spack config edit # add external for [email protected]
$ spack install mvapich2
would reuse the [email protected] installed on the first line, and there is no recourse to force it to use the external as far as I understand.
There was a problem hiding this comment.
True. Then you can call your external [email protected]. I hope this will be a niche case
|
@becker33 The bug occurring when:
has been fixed in 30e8edc, and a unit test has been included to avoid regressions. I checked the rules in which spack/lib/spack/spack/solver/concretize.lp Lines 450 to 461 in 1c22af8 If a package is Footnotes
|
Co-authored-by: Greg Becker <[email protected]>
|
Give @alalazo all the credit, I just complained about solutions and he came up with new ones |
|
Playing Devil's advocate and finding ways that a solution might break is just as important 😄 |
fixes spack#31484 Before this change if anything was matching an external condition, it was considered "external" and thus something to be "built". This was happening in particular to external packages that were re-read from the DB, which then couldn't be reused, causing the problems shown in spack#31484. This PR fixes the issue by excluding specs with a "hash" from being considered "external" * Test that users have a way to select a virtual This ought to be solved by extending the "require" attribute to virtual packages, so that one can: ```yaml mpi: require: 'multi-provider-mpi' ``` * Prevent conflicts to be enforced on specs that can be reused. * Rename the "external_only" fact to "buildable_false", to better reflect its origin
fixes #31484
fixes #31832
Before this change if anything was matching an external condition, it was considered "external" and thus something to be "built". This was happening in particular to external packages that were re-read from the DB, which then couldn't be reused, causing the problems shown in #31484.
This PR fixes the issue by excluding specs with a "hash" from being considered "external"