Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uniquify suffixes added to module names #14920

Merged
merged 3 commits into from
Feb 26, 2020

Conversation

sethrj
Copy link
Contributor

@sethrj sethrj commented Feb 12, 2020

Consider a user that wants to mark CUDA-enabled modules with a -cuda suffix. To also account for libraries that use cuda-enabled MPI (perhaps to differentiate them from the same library that uses non-cuda MPI), they set their modules.yaml file to:

modules:
  enable::
    - lmod
  lmod:
    all:
      suffixes:
        '+cuda': 'cuda'
        '^mpi+cuda': 'cuda'

Although this creates non-conflicting module names for foo ^mpi+cuda and foo ^mpi~cuda, it gives bar+cuda ^mpi+cuda an suffix of -cuda-cuda.

This patch deduplicates module extensions so that the latter suffix will simplify to -cuda. It also sorts the suffixes to improve robustness.

@alalazo
Copy link
Member

alalazo commented Feb 13, 2020

It also sorts the suffixes to improve robustness.

Right now suffixes are added in the order in which they are written. This PR change that behavior. I don't mind this behavior as long as it is documented, but are we sure that there won't be user requests to have mpi-cuda instead of cuda-mpi or similar things? Asking because my experience with modules is that people are very tied to their own way of naming things...

Although this creates non-conflicting module names for foo ^mpi+cuda and foo ^mpi~cuda, it gives bar+cuda ^mpi+cuda an suffix of -cuda-cuda

I see that the behavior of +foo in spec changed in 515b404. Previously it was not necessary to have ^mpi+cuda. I agree with deduplication, not sure about sorting. In case we have a function that performs stable deduplication in llnl.util.lang.dedupe.

@sethrj
Copy link
Contributor Author

sethrj commented Feb 13, 2020

@alalazo Great, I wasn't aware of the stable deduplication, and I wasn't aware any existing ordering was documented. I'm used to assuming that .items() returns an arbitrarily ordered sequence, but I am aware that many containers in Spack use YAML-constructed ordered dictionaries.

I will happily change sorted(set(suffixes)) to llnl.util.lang.dedupe(suffixes) if it'll make this PR less contentious.

@sethrj
Copy link
Contributor Author

sethrj commented Feb 13, 2020

@alalazo Judging by the Python 2 test failures after reverting the sort, the ordering of self.conf.get('suffixes') is not based on the order in modules.yaml, so different python versions generate different module names (yikes!). I'm going to revert that change so that suffixes will have a stable ordering from now on.

This reverts commit 989d860. Apparently
the suffix ordering is *not* based on user input, so sorting is the most
obvious way to guarantee a stable order.
@alalazo
Copy link
Member

alalazo commented Feb 17, 2020

Judging by the Python 2 test failures after reverting the sort, the ordering of self.conf.get('suffixes') is not based on the order in modules.yaml, so different python versions generate different module names (yikes!)

That must have changed at some point - shame for the lack of proper testing 😢 Well, giving thumbs up on this then, but waiting for somebody else to chime in before merging.

@sethrj
Copy link
Contributor Author

sethrj commented Feb 26, 2020

@alalazo It's been a week since the feedback request to #modules, so I believe there are no barriers to merging.

@alalazo
Copy link
Member

alalazo commented Feb 26, 2020

@sethrj Thanks for the reminder!

@alalazo alalazo merged commit 6c445a2 into spack:develop Feb 26, 2020
@alalazo alalazo added this to In progress in Spack v0.14.1 release via automation Feb 26, 2020
@alalazo alalazo moved this from In progress to Done in Spack v0.14.1 release Feb 26, 2020
@sethrj
Copy link
Contributor Author

sethrj commented Feb 26, 2020

Thanks for the review and merge!

@sethrj sethrj deleted the unique-module-suffix branch March 17, 2020 14:00
@tgamblin tgamblin moved this from Done to Reviewer approved in Spack v0.14.1 release Mar 19, 2020
@tgamblin tgamblin moved this from Reviewer approved to Done in Spack v0.14.1 release Mar 20, 2020
likask pushed a commit to likask/spack that referenced this pull request Apr 7, 2020
…upstream_master

* commit 'e2b1737a42c9c0c796671f9dd0c39f623e4c91c0': (1343 commits)
  update CHANGELOG.md for 0.14.1
  version bump: 0.14.1
  multiprocessing: allow Spack to run uninterrupted in background (spack#14682)
  Cray bugfix: TERM missing while reading default target (spack#15381)
  Upstreams: don't write metadata directory to upstream DB (spack#15526)
  Creating versions from urls doesn't modify class attributes (spack#15452)
  bugfix: fix install_missing_compilers option bug from v0.14.0 (spack#15416)
  bugfix: installer.py shouldn't be executable (spack#15386)
  Add function replace_prefix_nullterm for use on mach-o rpaths. (spack#15347)
  ArchSpec: fix semantics of satisfies when not concrete and strict is true (spack#15319)
  suite-sparse: fix installation for v5.X (spack#15326)
  testing:  increase installer coverage (spack#15237)
  bugfix: resolve undefined source_pkg_dir failure (spack#15339)
  Bugfix: resolve StopIteration message attribute failure (spack#15341)
  Recover coverage from subprocesses during unit tests (spack#15354)
  Correct pytest.raises matches to match (spack#15346)
  bugfix:  Add dependents when initializing spec from yaml (spack#15220)
  Uniquify suffixes added to module names (spack#14920)
  bugfix: ensure proper dependency handling for package-only installs (spack#15197)
  Fix for being able to 'spack load' packages that have been renamed. (spack#14348)
  ...

# Conflicts:
#	.travis.yml
#	lib/spack/spack/modules/common.py
#	var/spack/repos/builtin/packages/mofem-cephas/package.py
#	var/spack/repos/builtin/packages/mofem-fracture-module/package.py
#	var/spack/repos/builtin/packages/mofem-users-modules/package.py
#	var/spack/repos/builtin/packages/python/package.py
@RemiLacroix-IDRIS
Copy link
Contributor

RemiLacroix-IDRIS commented Aug 27, 2020

Right now suffixes are added in the order in which they are written. This PR change that behavior. I don't mind this behavior as long as it is documented, but are we sure that there won't be user requests to have mpi-cuda instead of cuda-mpi or similar things? Asking because my experience with modules is that people are very tied to their own way of naming things...

I am just noticing that the ordering changed now that the change is causing some issues with our modules. :(

foo/X.Y.Z-cuda-mpi becomes foo/X.Y.Z--cuda-mpi for example, which we aren't really happy about because it is causing duplicated modules if we don't pay attention and we cannot have consistent module naming without breaking existing submission scripts.

Additionally, the documentation was not updated as far as I can tell: https://spack.readthedocs.io/en/latest/module_file_support.html#selection-by-anonymous-specs

Order does matter
The modifications associated with the all keyword are always evaluated first, no matter where they appear in the configuration file. All the other spec constraints are instead evaluated top to bottom.

Edit: I am willing to contribute a PR that would make everybody happy (if that's possible).

@alalazo
Copy link
Member

alalazo commented Aug 28, 2020

Additionally, the documentation was not updated as far as I can tell:

Maybe we can word it better, but that sentence is meant to say that if you have:

modules:
  tcl:
    foo:
      kwd: ...
    all:
      kwd: ...
    bar:
      kwd: ...

The order in which kwd is constructed for foo is to evaluate all first and merge it with foo.

@RemiLacroix-IDRIS
Copy link
Contributor

@alalazo I would think it makes sense that "modifications" also applies to suffixes. In practice it was the case before.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

4 participants