Skip to content

Allow users to specify root env dir#32836

Merged
becker33 merged 66 commits intospack:developfrom
psakievich:f/env-location
Feb 22, 2023
Merged

Allow users to specify root env dir#32836
becker33 merged 66 commits intospack:developfrom
psakievich:f/env-location

Conversation

@psakievich
Copy link
Copy Markdown
Contributor

Environments managed by spack have some advantages over anonymous Environments but they are tucked away inside spack's directory tree. This PR gives users the ability to specify where the environments should live.

See #32823

Environments managed by spack have some advantages over anonymous Environments
but they are tucked away inside spack's directory tree. This PR gives
users the ability to specify where the environments should live.

See #32823
@spackbot-app spackbot-app bot added core PR affects Spack core functionality defaults environments tests General test capability(ies) utilities labels Sep 27, 2022
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.

This is a great idea

psakievich and others added 2 commits September 27, 2022 11:17
@spackbot-app spackbot-app bot added the documentation Improvements or additions to documentation label Sep 27, 2022
@psakievich psakievich requested a review from becker33 September 27, 2022 18:05
@psakievich psakievich marked this pull request as ready for review September 27, 2022 18:05
@psakievich
Copy link
Copy Markdown
Contributor Author

Closes #32823

Copy link
Copy Markdown
Contributor

@tldahlgren tldahlgren left a comment

Choose a reason for hiding this comment

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

I suggest a few minor typo corrections and have a few questions.

@tgamblin @becker33 What would (or should) happen if a user already has environments defined in the default path then updates their configuration to point elsewhere?

Is it worth considering supporting a list of environment paths?

Copy link
Copy Markdown
Contributor

@tldahlgren tldahlgren left a comment

Choose a reason for hiding this comment

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

Switching from comment to request changes due to the typos needing fixed.

@psakievich
Copy link
Copy Markdown
Contributor Author

psakievich commented Sep 28, 2022

@tldahlgren I thought about having a list of directories. This is a good question. It complicated things a bit which is why I didn't pursue it.

One thing I'm not sure how to handle is where we add the new environments to. Thinking further, if we treat this like a stack then we could just add environments to the directory at the top of the stack. Another option could be to only allow two entries: the default directory and allow for a single option from the config. I think I like the second option more. I'm not sure the utility of expanding beyond a single user location and the default location.

In the current form the already created environments in the default directory would become anonymous environments. Speaking for myself I typically only use one or the other (registered vs anonymous) in a given spack instance but that may not be reflective of the broader community.

@psakievich
Copy link
Copy Markdown
Contributor Author

Hmm another potential issue for this is if the environments have the same name in both locations

@psakievich
Copy link
Copy Markdown
Contributor Author

@tldahlgren and @becker33 this is ready finally. After #34758 some of the logic regarding environment paths and avoiding circular imports was cleaned up. Most of the hang up on this was due to tests using the same mutable_mock_env_path in parallel. I addressed this by making the fixture use a function scope and then cleaning up two more sets of tests.

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.

Besides the one inline comment, everything looks good to me. I agree with your assessment on slack that it's confusing that this is coming up for this PR and not previously. My best guess without fully diving in to debug it is that previously things "just happened" to work because environments would coincidentally wind up in the same place, even though they weren't being mocked in a way that was thread safe.

root: $TMP_DIR/install
misc_cache: $$user_cache_path/cache
source_cache: $$user_cache_path/source
environments_root: $TMP_DIR/envs
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.

I'm having trouble tracking why this change is necessary.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This was a suggestion from @trws to sandbox parallel execution. I don't fully understand it either. @trws perhaps you could comment?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

That script is used to separate the unit tests when run in parallel. It ensures that each test runner gets its own separate spack environment so they don't tromp each other. If the environments_root defaults to being under user_cache_path or something then it's unnecessary, but if it's in the spack_root by default or something like that then the script needs to put it somewhere else.

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.

Yeah @psakievich and I came to the conclusion that this probably isn't technically necessary since all of the environment tests use a mock environment root anyway, but that we should keep it to ensure future tests are separated for parallel execution.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Sounds right to me. The script is meant to be a safety net and a workaround for all the tests that haven't been converted yet. It's also oddly useful as a way to do one-off testing without messing up a current environment just on the command line, so having it there helps with that kind of use.

becker33
becker33 previously approved these changes Feb 21, 2023
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'm sorry this became such an unholy pain to get ready to merge

Copy link
Copy Markdown
Contributor

@tldahlgren tldahlgren left a comment

Choose a reason for hiding this comment

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

LGTM. Just a couple of questions.

tldahlgren
tldahlgren previously approved these changes Feb 21, 2023
Copy link
Copy Markdown
Contributor

@tldahlgren tldahlgren left a comment

Choose a reason for hiding this comment

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

Would prefer the 'named' -> 'managed' comment change but won't require the change.

@psakievich psakievich dismissed stale reviews from tldahlgren and becker33 via c16f166 February 21, 2023 23:33
tldahlgren
tldahlgren previously approved these changes Feb 21, 2023
Copy link
Copy Markdown
Contributor

@tldahlgren tldahlgren left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Copy Markdown
Contributor

@tldahlgren tldahlgren left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks.

@becker33 becker33 enabled auto-merge (squash) February 22, 2023 00:04
@becker33 becker33 merged commit b8d15e8 into spack:develop Feb 22, 2023
matz-e pushed a commit to BlueBrain/spack that referenced this pull request Feb 24, 2023
* Allow users to specify root env dir

Environments managed by spack have some advantages over anonymous Environments
but they are tucked away inside spack's directory tree. This PR gives
users the ability to specify where the environments should live.

See spack#32823

This is also taken as an opportunity to ensure that all references are to "managed environments",
rather than "named environments". Prior to this PR some references to the latter persisted.

Co-authored-by: Tom Scogland <[email protected]>
Co-authored-by: Tamara Dahlgren <[email protected]>
Co-authored-by: Gregory Becker <[email protected]>
Conflicts:
	lib/spack/spack/test/cmd/env.py
	lib/spack/spack/test/env.py
jmcarcell pushed a commit to key4hep/spack that referenced this pull request Apr 13, 2023
* Allow users to specify root env dir

Environments managed by spack have some advantages over anonymous Environments
but they are tucked away inside spack's directory tree. This PR gives
users the ability to specify where the environments should live.

See spack#32823

This is also taken as an opportunity to ensure that all references are to "managed environments",
rather than "named environments". Prior to this PR some references to the latter persisted.

Co-authored-by: Tom Scogland <[email protected]>
Co-authored-by: Tamara Dahlgren <[email protected]>
Co-authored-by: Gregory Becker <[email protected]>
@psakievich psakievich deleted the f/env-location branch November 8, 2023 04:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands conflicts core PR affects Spack core functionality defaults documentation Improvements or additions to documentation environments sbang shell-support tests General test capability(ies) update-package utilities

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants