Skip to content

Finer selection of virtual providers#15569

Closed
alalazo wants to merge 33 commits intospack:developfrom
alalazo:features/finer_virtual_selection
Closed

Finer selection of virtual providers#15569
alalazo wants to merge 33 commits intospack:developfrom
alalazo:features/finer_virtual_selection

Conversation

@alalazo
Copy link
Copy Markdown
Member

@alalazo alalazo commented Mar 19, 2020

fixes #15443
closes #17439

This PR implements what is described in #15443:

@alalazo alalazo force-pushed the features/finer_virtual_selection branch from 116a236 to ded08d5 Compare March 24, 2020 13:22
@alalazo alalazo marked this pull request as ready for review March 24, 2020 14:00
@tgamblin tgamblin self-assigned this Mar 24, 2020
@tldahlgren
Copy link
Copy Markdown
Contributor

FYI. I provided feedback on #15505

@tldahlgren
Copy link
Copy Markdown
Contributor

I'll start #15570 now.

@alalazo alalazo force-pushed the features/finer_virtual_selection branch 2 times, most recently from 867248f to d2b6458 Compare March 25, 2020 17:27
@alalazo alalazo force-pushed the features/finer_virtual_selection branch from d16e364 to 70c58df Compare April 1, 2020 11:58
@alalazo
Copy link
Copy Markdown
Member Author

alalazo commented Apr 1, 2020

@becker33 @tgamblin Apparently the features added in #14934 didn't conflict with this PR. I have a question on semantics though. With this configuration:

packages:
  all:
    providers:
      lapack: [openblas]
  lapack:
    buildable: False
    paths:
      [email protected]: /usr

I obtain the following:

$ spack spec netlib-scalapack ^mpi=intel-parallel-studio@cluster+mpi
Input spec
--------------------------------
netlib-scalapack
    ^intel-parallel-studio@cluster+mpi

Concretized
--------------------------------
==> Error: The spec
    'intel-parallel-studio@cluster+mpi'
    is configured as not buildable, and no matching external installs were found

i.e. the configuration in packages.yaml has the meaning of "don't ever build anything that might provide lapack" (even if that lapack is not used in the spec). That seems sensible to me but I want to double check if we are considering a different behavior here.

@becker33
Copy link
Copy Markdown
Member

That is correct about what #14934 did. I'm not sure that we want to keep that behavior, we can update it later to be more expressive

Copy link
Copy Markdown
Member

@tgamblin tgamblin left a comment

Choose a reason for hiding this comment

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

@alalazo: this looks pretty good so far -- two major things:

  1. This needs to handle when conditionals for bound virtuals
  2. The resolved virtuals should be made into edge attributes in the DAG, so that we know what's providing what.

(2) would fix the big TODO for scalapack in intel-parallel-studio's libs method.

msg = 'virtual dependency "{0}" cannot be specified multiple times'
raise ValueError(msg.format(virtual))

self._explicit_providers[virtual] = spec
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is a fine check, (as it doesn't really know whether anything is virtual) but it may have to go away and be checked later. It is right on the edge of including package/concretization semantics in the spec parser.

I'm on the fence because while I can't think of a reason we would ever want the same virtual twice in a DAG, I don't see why we shouldn't be able to talk about a DAG with that property. A spec DAG can represent that -- it's just not a valid build.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I completely agree with the reasoning above: one thing is construct an abstract spec, another is trying to concretize it using some constraints. I added the check above as I was trying to follow a practice that is already present for non-virtual dependencies:

spack/lib/spack/spack/spec.py

Lines 1113 to 1117 in 04c6a78

def _add_dependency(self, spec, deptypes):
"""Called by the parser to add another spec as a dependency."""
if spec.name in self._dependencies:
raise DuplicateDependencyError(
"Cannot depend on '%s' twice" % spec)

This results in the following behavior:

Spack version 0.14.2
Python 3.7.4, Linux x86_64
>>> import spack.spec
>>> s = spack.spec.Spec('hdf5 ^zlib~shared ^zlib+shared')
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/home/culpo/PycharmProjects/spack/lib/spack/spack/spec.py", line 1035, in __init__
    spec_list = SpecParser(self).parse(spec_like)
  File "/home/culpo/PycharmProjects/spack/lib/spack/spack/parse.py", line 152, in parse
    return self.do_parse()
  File "/home/culpo/PycharmProjects/spack/lib/spack/spack/spec.py", line 4113, in do_parse
    self._parse_dependency(specs)
  File "/home/culpo/PycharmProjects/spack/lib/spack/spack/spec.py", line 4184, in _parse_dependency
    specs[-1]._add_dependency(dep, ())
  File "/home/culpo/PycharmProjects/spack/lib/spack/spack/spec.py", line 1144, in _add_dependency
    "Cannot depend on '%s' twice" % spec)
spack.spec.DuplicateDependencyError: Cannot depend on 'zlib+shared' twice

Should we move both checks just before concretization and verify there the pre-requisites of an abstract spec?

@alalazo alalazo force-pushed the features/finer_virtual_selection branch 3 times, most recently from 1a12699 to b91f20f Compare April 20, 2020 10:42
@alalazo alalazo force-pushed the features/finer_virtual_selection branch from b91f20f to a5bfe28 Compare April 20, 2020 16:27
@alalazo

This comment has been minimized.

@alalazo alalazo force-pushed the features/finer_virtual_selection branch 2 times, most recently from 1dda5a7 to 4181bc7 Compare May 8, 2020 14:26
@alalazo
Copy link
Copy Markdown
Member Author

alalazo commented May 8, 2020

@tgamblin 4181bc7 solves the reindex issue (which doesn't fail) but doesn't go as far as recomputing edge attributes. For specs installed before this PR a reindex will always add an empty list under the provides attribute. I think this is fine, but let me know if some further action needs to be taken.

@alalazo alalazo force-pushed the features/finer_virtual_selection branch from 4181bc7 to afcfb74 Compare May 9, 2020 10:34
The root spec byte blob is now generated on the fly
for tests.
This should help to better convey the meaning of this attribute
i.e. store somewhere the user requested providers so that we
can honor those requests when concretizing.
Previously __contains__ was just checking nodes properties
i.e. it was checking whether a spec *might* provide a
virtual dependency or not.

Since this PR annotates virtual dependencies on edges, we
should now check that the edge provides the correct virtual.
@alalazo alalazo force-pushed the features/finer_virtual_selection branch from 2192088 to 4622489 Compare September 9, 2020 09:23
@alalazo alalazo marked this pull request as draft October 17, 2020 08:46
@alalazo
Copy link
Copy Markdown
Member Author

alalazo commented Oct 17, 2020

Converted the PR back to draft since:

  1. The syntax to specify virtual packages from command line needs to be revisited (it's in conflict with Environments: specify packages for developer builds #15256, now merged)
  2. It's highly probable that the new concretizer will be merged before this PR, so support for it needs to be added here.

@scheibelp scheibelp mentioned this pull request Apr 19, 2021
4 tasks
alalazo added a commit to alalazo/spack that referenced this pull request Oct 21, 2021
…e it

fixes spack#26866

This semantics fits with the way Spack currently treats providers of
virtual dependencies. It needs to be revisited when spack#15569 is reworked
with a new syntax.
alalazo added a commit to alalazo/spack that referenced this pull request Oct 21, 2021
…e it

fixes spack#26866

This semantics fits with the way Spack currently treats providers of
virtual dependencies. It needs to be revisited when spack#15569 is reworked
with a new syntax.
alalazo added a commit that referenced this pull request Oct 25, 2021
…e it

fixes #26866

This semantics fits with the way Spack currently treats providers of
virtual dependencies. It needs to be revisited when #15569 is reworked
with a new syntax.
@cosmicexplorer
Copy link
Copy Markdown
Contributor

The changes in #29093 may help to unblock the extension to the spec language mentioned in the final bullet of the OP:

@tgamblin tgamblin added this to the v0.20.0 milestone Nov 7, 2022
@alalazo
Copy link
Copy Markdown
Member Author

alalazo commented Feb 3, 2023

Superseded by #35322

@alalazo alalazo closed this Feb 3, 2023
@haampie haampie added the hash-change things that will change a lot of hashes label Nov 7, 2024
@alalazo alalazo deleted the features/finer_virtual_selection branch September 16, 2025 09:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

concretization hash-change things that will change a lot of hashes virtual-dependencies

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Finer selection of virtual providers in a DAG

7 participants