spack: spec.satisfies needs to be refactored (behaves wrongly inside packages)
This may be the root of some weird behaviors seen around, given that currently this pattern is used in more than 40 packages. Short story: ~never use this inside packages:~ this line behaves wrongly in packages:
spec.satisfies('^foo') # or similar checks
while this behaves correctly:
'^foo' in spec
The point is that the first call is meant to be used inside the concretizer and has a weaker semantic on enforcing the constraint. The second call has a stronger semantic, and is equivalent to calling:
for s in self.traverse():
if s.satisfies('^foo', strict=True):
return True
where:
- we recurse on the spec
- we activate the
strict=Trueparameter which enforces the strong semantic
In other words (@tgamblin ™️ ) the first call means that spec could satisfy ^foo eventually. The second that spec can satisfy ^foo right now.
@scheibelp @becker33 @tgamblin Can you confirm that this could be a potential issue for packages?
About this issue
- Original URL
- State: closed
- Created 10 years ago
- Reactions: 2
- Comments: 18 (18 by maintainers)
Commits related to this issue
- cp2k: fixed compilation issues for intel stack Added DFLAGS to the `make.inc` file being written. These macros are also added to the language specific variables like CFLAGS, CXXFLAGS and FCFLAGS. Cha... — committed to epfl-scitas/spack by alalazo 10 years ago
- cp2k: fixed compilation issues for intel stack Added DFLAGS to the `make.inc` file being written. These macros are also added to the language specific variables like CFLAGS, CXXFLAGS and FCFLAGS. Cha... — committed to epfl-scitas/spack by alalazo 10 years ago
- cp2k: fixed compilation issues for intel stack Added DFLAGS to the `make.inc` file being written. These macros are also added to the language specific variables like CFLAGS, CXXFLAGS and FCFLAGS. Cha... — committed to epfl-scitas/spack by alalazo 10 years ago
- cp2k: fixed compilation issues for intel stack Added DFLAGS to the `make.inc` file being written. These macros are also added to the language specific variables like CFLAGS, CXXFLAGS and FCFLAGS. Cha... — committed to epfl-scitas/spack by alalazo 10 years ago
- self.spec.satisfies is unsatisfying, in is in instead See #4135, self.spec.satisfies has issues. @adamjstewart suggests simply using in. — committed to hartzell/spack by deleted user 10 years ago
- self.spec.satisfies is unsatisfying, in is in instead See #4135, self.spec.satisfies has issues. @adamjstewart suggests simply using in. — committed to hartzell/spack by deleted user 10 years ago
- Package for bcl2fastq2 (updates libxslt) (#4234) * Add v1.1.26 and make crypto a variant I need 1.1.26 for bcl2fastq2. I also need to build it without crypto support. * Initial support for b... — committed to spack/spack by hartzell 10 years ago
- cp2k: fixed compilation issues for intel stack Added DFLAGS to the `make.inc` file being written. These macros are also added to the language specific variables like CFLAGS, CXXFLAGS and FCFLAGS. Cha... — committed to diaena/spack by alalazo 10 years ago
- Package for bcl2fastq2 (updates libxslt) (#4234) * Add v1.1.26 and make crypto a variant I need 1.1.26 for bcl2fastq2. I also need to build it without crypto support. * Initial support for b... — committed to diaena/spack by hartzell 10 years ago
- cp2k: fixed compilation issues for intel stack Added DFLAGS to the `make.inc` file being written. These macros are also added to the language specific variables like CFLAGS, CXXFLAGS and FCFLAGS. Cha... — committed to xavierandrade/spack by alalazo 10 years ago
- Package for bcl2fastq2 (updates libxslt) (#4234) * Add v1.1.26 and make crypto a variant I need 1.1.26 for bcl2fastq2. I also need to build it without crypto support. * Initial support for b... — committed to xavierandrade/spack by hartzell 10 years ago
- cp2k: fixed compilation issues for intel stack Added DFLAGS to the `make.inc` file being written. These macros are also added to the language specific variables like CFLAGS, CXXFLAGS and FCFLAGS. Cha... — committed to EmreAtes/spack by alalazo 10 years ago
- Package for bcl2fastq2 (updates libxslt) (#4234) * Add v1.1.26 and make crypto a variant I need 1.1.26 for bcl2fastq2. I also need to build it without crypto support. * Initial support for b... — committed to EmreAtes/spack by hartzell 10 years ago
Another question kind of brought up by the last one: should
Spechave an__iter__method equivalent tospec.traverse()with no arguments? It would allow:You would still need
spec.traverse()for when you want something other than the default traversal over dependencies (different order, etc.)I would suggest these semantics:
spec.satisfies(other): same as current satisfies, but always strict. Concretizer usescould_satisfy. I actually have a branch where I started that refactor.other in spec: I like this notation a lot, and I think it makes the code more readable, both when you’re checking whether some package is in the DAG, and when you’re checking whether the spec itself satisfies an anonymous constraint. The most intuitive semantics for me would be:could_satisfy: new method for use by the concretizer, equivalent tosatisfieswithstrict=False.This makes
satisfiesdo what you’d expect, and it makes__contains__clear because it only applies to dependencies when you’re explicit about which one. If you want to check an anonymous spec against everything in the DAG, you have to be explicit and say:I was throwing out 1,2, and 3 as brainstorm alternatives. I would not expect we implement more than one of them.
I think that
spec.satisfies()feels more clear and explicit. But using__contains__()is so convenient… If I had to vote for getting rid of one, I’d get rid of__contains__()because it’s less clear.The main issue here is that satisfies() was written to be used in
Then maybe it’s mis-named, and the version used in concretization should be called
could_satisfy().OK, this is really subtle… It looks like a booby trap to me. I suggest we think through ways to get rid of the booby trap, instead of just documenting it. For example:
Change the default for
spec.satisfiesfromstrict=Falsetostrict=True. Then users can blithely use it inpackage.pywithout repercussions.Rename
spec.satisfiestospec._satisfies, it is therefore marked for internal use only.Remove the
strictparameter fromspec.satisfies(), and have the behavior of the newspec.satisfiesdefault tostrict=True. Then create a newspec.satisfies_permissive(), which is equivalent tostrict=False.Finally done in #35681
@melven this issue predates the environments feature: can you open a new issue including the commands, environment, and stack trace (when running with
spack -d)?I agree with @citibeth except on point 3. I think we should not augment the redundancy in the public API. If:
is equivalent to
then one of the two must disappear in the long run.
If instead we want a function that peeks only at this node in the DAG we should rename
satisfyto something else. I don’t think anybody used it on purpose to search only the current node in the DAG without traversing dependencies.I agree with @citibeth that this is a bug that should be fixed rather than advice we should give to packagers. I’ll look at what it would take to change.