Skip to content

cmd: Add new mark command#16662

Merged
tgamblin merged 3 commits intospack:developfrom
michaelkuhn:cmd-mark
Nov 18, 2020
Merged

cmd: Add new mark command#16662
tgamblin merged 3 commits intospack:developfrom
michaelkuhn:cmd-mark

Conversation

@michaelkuhn
Copy link
Copy Markdown
Member

This adds a new mark command that can be used to mark packages as either explicitly or implicitly installed. Apart from fixing the package database after installing a dependency manually, it can be used to implement upgrade workflows as outlined in #13385.

The following commands demonstrate how the mark and gc commands can be used to only keep the current version of a package installed:

$ spack install pkgA
$ spack install pkgB
$ git pull # Imagine new versions for pkgA and/or pkgB are introduced
$ spack mark -i -a
$ spack install pkgA
$ spack install pkgB
$ spack gc

If there is no new version for a package, install will simply mark it as explicitly installed and gc will not remove it.

Fixes #9626

@michaelkuhn
Copy link
Copy Markdown
Member Author

cc @SteVwonder (better late than never 😆)

@michaelkuhn
Copy link
Copy Markdown
Member Author

@alalazo Could you please review this? Thanks!

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.

In general I agree with the functionality added by this PR. I wonder if we should try to group this and other commands under a common umbrella. For instance:

$ spack store mark
$ spack store reindex
$ spack store find
...

instead of adding a new one. This is because:

$ ls -1 lib/spack/spack/cmd/ | wc -l
74

In case this discussion can be held in a separate issue.

@michaelkuhn
Copy link
Copy Markdown
Member Author

I don't have a strong opinion regarding the amount of commands. Git also has a lot of commands and I think useful help output also solves the problem. Especially for common operations such as spack find, I would rather keep them short. Having to type spack store find every time could get annoying quickly. But I agree, this is probably best discussed in a separate issue.

@alalazo
Copy link
Copy Markdown
Member

alalazo commented May 26, 2020

Especially for common operations such as spack find, I would rather keep them short.

We must have a spack find alias for spack store find in case. I agree discussing this in another issue. I don't have objections, but would like somebody else to chime in and comment on the opportunity to add a new command with such a narrow scope.

@michaelkuhn
Copy link
Copy Markdown
Member Author

@tgamblin @scheibelp @adamjstewart @becker33 ping

I use Spack for dependency management for projects outside of Spack. The mark command would allow an upgrade workflow as described in the initial post. Currently, whenever users run into problems with dependencies, I more or less have to tell them "delete and then rebuild everything".

@michaelkuhn michaelkuhn force-pushed the cmd-mark branch 3 times, most recently from b765672 to 0d140c2 Compare June 18, 2020 19:58
@michaelkuhn
Copy link
Copy Markdown
Member Author

@alalazo @becker33 ping

I just did a rebase to fix some conflicts and pushed the updated version.

Copy link
Copy Markdown
Member

@becker33 becker33 left a comment

Choose a reason for hiding this comment

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

I think this is useful, and an appropriately named command. I agree that the proliferation of commands is a concern, but I don't really see an obvious place to combine this command, and I think having poorly factored commands with suboptions that are unintuitive is a worse sin than too many commands. I think most users are able to find the (relatively few) commands they need, and documentation and the community support are able to point power users towards the more advanced commands they desire.

I think this PR probably requires documentation. I also have one note for code cleanup.

@michaelkuhn
Copy link
Copy Markdown
Member Author

I have just pushed an updated version that also includes documentation and some tests.

@michaelkuhn michaelkuhn force-pushed the cmd-mark branch 2 times, most recently from d162c27 to 0d04bdf Compare June 30, 2020 19:06
Copy link
Copy Markdown
Member

@SteVwonder SteVwonder left a comment

Choose a reason for hiding this comment

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

Thanks @michaelkuhn! This is a very useful feature. I just had a question about some of the terminology used in the documentation (see below):

Comment on lines +325 to +338
on different versions of ``libsigsegv``. ``spack gc`` will not remove any of
the packages since both versions of ``m4`` have been installed explicitly.

Copy link
Copy Markdown
Member

@SteVwonder SteVwonder Jun 30, 2020

Choose a reason for hiding this comment

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

Why are both versions of m4 considered being explicitly installed? Were they installed with spack install m4 ^[email protected] and spack install m4 ^[email protected]? If so, that makes sense to me.

If spack install m4 results in [email protected] getting marked as explicit, I'm confused. Are all packages marked as explict until someone comes by and manually marks them as implicit?

I could be wrong, but I think other package managers like apt use explicit to mean the package was explicitly mentioned by the user in a command line invocation, and implicit means the package was pulled in as a dependency of an explicit package.

If the terms used here differ, it might be worth precisely defining what explicit and implicit mean in this documentation.

Copy link
Copy Markdown
Member Author

@michaelkuhn michaelkuhn Jun 30, 2020

Choose a reason for hiding this comment

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

Why are both versions of m4 considered being explicitly installed? Were they installed with spack install m4 ^[email protected] and spack install m4 ^[email protected]? If so, that makes sense to me.

Exactly. I have now added some more lines to the example that should hopefully make this more clear.

If spack install m4 results in [email protected] getting marked as explicit, I'm confused. Are all packages marked as explict until someone comes by and manually marks them as implicit?

No, only the two m4 packages will be marked as explicitly installed. I have also added a few sentences explaining this.

Thanks for your feedback! Let me know whether you think my changes are enough to clear things up.

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.

Awesome! Thanks for the clarifications. LGTM!

@michaelkuhn michaelkuhn force-pushed the cmd-mark branch 2 times, most recently from 9aa923f to 53deb4c Compare August 20, 2020 08:23
Copy link
Copy Markdown
Member

@becker33 becker33 left a comment

Choose a reason for hiding this comment

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

@michaelkuhn sorry I haven't gotten back to this sooner. I have one more request on this PR.

Comment on lines +76 to +78
print()
spack.cmd.display_specs(matching, **display_args)
print()
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 part of an error message, and should be printed to stderr

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 have added a new commit that should take care of this. It also fixes uninstall's error output.

@michaelkuhn
Copy link
Copy Markdown
Member Author

@becker33 ping

@michaelkuhn
Copy link
Copy Markdown
Member Author

@becker33 I have rebased the PR to current develop and it now applies again. Anything else I should work on to get this merged? Thanks!

Copy link
Copy Markdown
Member

@becker33 becker33 left a comment

Choose a reason for hiding this comment

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

It needs a rebase again, but it looks good. Sorry I dropped the ball on reviewing this.

michaelkuhn and others added 2 commits November 18, 2020 02:12
This adds a new `mark` command that can be used to mark packages as either
explicitly or implicitly installed. Apart from fixing the package
database after installing a dependency manually, it can be used to
implement upgrade workflows as outlined in spack#13385.

The following commands demonstrate how the `mark` and `gc` commands can be
used to only keep the current version of a package installed:
```console
$ spack install pkgA
$ spack install pkgB
$ git pull # Imagine new versions for pkgA and/or pkgB are introduced
$ spack mark -i -a
$ spack install pkgA
$ spack install pkgB
$ spack gc
```

If there is no new version for a package, `install` will simply mark it as
explicitly installed and `gc` will not remove it.

Fixes spack#9626
`output` can be used to redirect `display_specs`'s output to stderr.
@becker33
Copy link
Copy Markdown
Member

@michaelkuhn I took care of the rebase to get this into v0.16.0

@tgamblin tgamblin merged commit 20367e4 into spack:develop Nov 18, 2020
lorak41 pushed a commit to lorak41/spack that referenced this pull request Feb 19, 2021
* releases/v0.16: (6003 commits)
  update CHANGELOG.md for v0.16.0
  bump version number to 0.16.0
  clingo: add `master` branch version (spack#19958)
  cmd: add `spack mark` command (spack#16662)
  spack test (spack#15702)
  Added -level_zero -rocm -opencl flags and sha256 for TAU v2.30. (spack#19962)
  Improve warning message for deprecated attributes in "packages.yaml"
  Documentation: spack load/environments prefix inspections (spack#19961)
  spack load/environments: allow customization of prefix inspections (spack#18260)
  spack containerize: allow users to customize the base image (spack#15028)
  concretizer: modified weights for providers and matching for externals
  concretizer: maximize the number of default values used for a single variant
  concretizer: don't require a provider for virtual deps if spec is external
  concretizer: spec_clauses() shouldn't emit node_compiler_hard for rule bodies.
  concretizer: don't generate rules for empty version lists
  concretizer: add a rule to avoid cycles in the graph of dependencies
  External packages have a consistent hash across different concretizers
  Don't fail if MV variants have a tuple as default value
  Fixup for target preferences
  Added unit tests to for regressions on open concretizer bugs
  ...

# Conflicts:
#	.gitignore
#	lib/spack/spack/binary_distribution.py
#	lib/spack/spack/cmd/setup.py
#	lib/spack/spack/modules/common.py
#	var/spack/repos/builtin/packages/med/package.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/mpich/package.py
#	var/spack/repos/builtin/packages/petsc/package.py
#	var/spack/repos/builtin/packages/python/package.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature request: ability to mark an explicit package as implicit

6 participants