Skip to content

spack environment (3): expose a subset of packages to a user#8231

Closed
scheibelp wants to merge 16 commits intospack:developfrom
scheibelp:features/environments
Closed

spack environment (3): expose a subset of packages to a user#8231
scheibelp wants to merge 16 commits intospack:developfrom
scheibelp:features/environments

Conversation

@scheibelp
Copy link
Copy Markdown
Member

This is the same as #7843 but with factored commits. The attribution is incorrect on them (I need to use https://help.github.com/articles/creating-a-commit-with-multiple-authors/ to add @citibeth as a coauthor on most of these).

@tgamblin ready for review. In short this PR:

  • Adds the spack env command: This maintains an environment object which tracks a set of specs, a spack configuration, and a repository. The user
    • Adds documentation which explains the usage of this command
    • Adds unit tests
    • Renames the old spack env command to spack build-env
  • Refactors several common arguments in Spack commands so that e.g. spack install command options apply to spack env foo install
  • Addresses some issues with Spec.to_node_dict to preserve patches/concreteness, so that a spec is concrete & complete after converting to/from JSON

Unfortunately since this replaces the cmd/env.py file, the github diff presents this as if I had edited the file from it's original state (vs. actually I renamed env.py and started from scratch). That is to say: it would be easier to just read cmd/env.py in an editor since all of its content is new.

@citibeth
Copy link
Copy Markdown
Member

To see how I'm "going to town" with environments, look at:

https://github.com/citibeth/spack/tree/efischer/giss/var/spack/environments

(You need to switch to branch efischer/giss)

@citibeth
Copy link
Copy Markdown
Member

I am more concerned that this PR gets merged, than I get attribution for it. Once this PR is merged, I will be actively promoting the Spack Setup PR; and once that is done, I will seek to re-do the environment API so it's more integrated into all Spack commands. @scheibelp did the heavy lifting here, with me testing and tucking in around the edges.

@scheibelp
Copy link
Copy Markdown
Member Author

I am more concerned that this PR gets merged, than I get attribution for it.

@citibeth FYI the "fixing attribution" part of this should not consume a significant amount of time. @tgamblin can let me know if it looks good and then I can rebase it and merge myself (just editing the commit messages).

@scheibelp scheibelp force-pushed the features/environments branch 2 times, most recently from 0ddecbe to 41cc369 Compare June 8, 2018 02:11
@tgamblin tgamblin mentioned this pull request Jun 24, 2018
4 tasks
@tgamblin tgamblin self-requested a review July 12, 2018 16:56
@tgamblin tgamblin force-pushed the features/environments branch 2 times, most recently from 30fc088 to acdcc29 Compare July 22, 2018 00:15
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.

This is an awesome PR! Thanks @citibeth and @scheibelp for putting this together. I will definitely be taking advantage of this once it hits develop. As I was reading through the documentation, I noticed a few typos and figured I'd comment on them.


An environment is used to group together a set of specs for the
purpose of building, rebuilding and deploying in a coherent fashion.
Environments provide a number of advantages over the the a la carte
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.

the the -> the

install``.
#. An Environment that is built as a whole can be loaded as a whole.
Spack can generate a script of ``module load`` commands that load
the appropraite environment. And that script will work, without
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.

appropraite -> appropriate

<https://conda.io/docs/user-guide/tasks/manage-environments.html>`_ or
`Python Virtual Environments
<https://docs.python.org/3/tutorial/venv.html>`_. Spack environments
some distinctive features:
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.

Spack environments provide some distinctive features

<https://docs.python.org/3/tutorial/venv.html>`_. Spack environments
some distinctive features:

#. A spec installed "in" an environment is no different form the same
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.

form -> from

Here we follow a typical use case of creating, concretizing,
installing and loading an environment.

.. note::
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 doesn't seem to be rendering correctly on GitHub. I'm not familiar with restructured text, so I don't know if that is just GitHub's renderer or if the newlines need to be removed.

The following files may be added to this directory by the user or
Spack:

* ``env.yaml``: Addition environment specification and configuration
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.

Addition -> Additional

@scheibelp scheibelp force-pushed the features/environments branch 2 times, most recently from 7439b78 to 3529325 Compare July 31, 2018 01:47
@scheibelp
Copy link
Copy Markdown
Member Author

scheibelp commented Jul 31, 2018

I have rebased this to sync with develop. I plan on looking more into #8231 (review) tomorrow (thanks @SteVwonder!)

Edit: it appears that the flake checks have gotten more-strict recently as well and I'll address that too.

@tgamblin tgamblin force-pushed the features/environments branch 2 times, most recently from ed478e3 to 33bca07 Compare July 31, 2018 06:24
@tgamblin
Copy link
Copy Markdown
Member

tgamblin commented Jul 31, 2018

@scheibelp: sorry for not pushing earlier -- I was waiting to do this transactionally. I pushed my changes, which:

  1. fix some bugs that came up after the rebase (I think there were 3-ish bugs in the modules stuff after the initial rebase onto develop -- you had the same ones)
  2. fix flake8 issues (from pep8-naming)
  3. add @SteVwonder's feedback.

This also:

  • moves most of spack.environment to spack.util.environment
  • moves the core of spack environments to spack.environment instead of keeping it all in the command
  • makes the cmd/spack/env test use fixtures and pytest style
  • refactors cmd/env.py so that parsers are closer to the corresponding code

I'll post more in a follow up, but the above is a setup for some refactors I want before we put this in and allow people to rely on the API. Most of them are in line with what @citibeth has requested. I think this is going to look really good!

scheibelp and others added 8 commits July 31, 2018 10:42
Co-authored-by: Elizabeth Fischer <[email protected]>
- Instead of one method with all parsers, each subcommand gets two
  functions: `setup_<cmd>_parser()` and `environment_<cmd>()`

- the `setup_parser()` and `env()` functions now generate the parser
  based on these and a list of subcommands.

- it is now easier to associate the arguments with the subcommand.
- `spack.util.environment` is the new home for routines that modify
  environment variables.

- This is to make room for `spack.environment` to contain new routines
  for dealing with spack environments
- `spack.environment` is now the home for most of the infrastructure
   around Spack environments

- refactor `cmd/env.py` to use everything from spack.environment

- refactor the cmd/env test to use pytest and fixtures
…ther

- logic used in `spack find` was hiding duplicate installations if their
  hashes were different

- short hash doesn't work in this scenario, since specs are structurally
  identical

- ConstraintAction always works on a DB query, so use the DAG hash to
  ensure uniqueness
- add a common argument for `-e/--env`
- modify the database to support queries on subsets of hashes
- allow `spack find` to be filtered by hashes in an environment
@tgamblin
Copy link
Copy Markdown
Member

Superseded by #9612

@tgamblin tgamblin closed this Oct 23, 2018
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.

7 participants