Assign priorities to configuration scopes (take 2)#49187
Conversation
Signed-off-by: Massimiliano Culpo <[email protected]>
Signed-off-by: Massimiliano Culpo <[email protected]>
Signed-off-by: Massimiliano Culpo <[email protected]>
50de8de to
dcabe1b
Compare
|
@tgamblin @kwryankrattiger I'm looking back at this, and found setting the right priority of In the code we always added In #48420 I tried to set In this second attempt, I switched the priority of custom scopes and environment, so that This ordering reflects the docs, and should require no changes to pipelines. This seems also better in case other, non public, pipelines share the same Now, I'm just waiting for pipelines to build something correctly, then I'll revert dcabe1b Let me know if you have thoughts. |
kwryankrattiger
left a comment
There was a problem hiding this comment.
LGTM, I think overall a general improvement.
psakievich
left a comment
There was a problem hiding this comment.
The hero we didn't know we needed. Thanks @alalazo !
|
RE:
I think we're still not thinking about this quite right. There are a few things going on here:
I think The others are really all on the CLI, and I think we should respect the order they appear. e.g., if I do this: Then my/config/directory should be lowest precedence, Then I think So I think the scopes should really look more like this:
I realize this might be tricky, as I think environments are currently set up in a common way regardless of whether they are set by But as it is, the description of the PR is incorrect: it doesn't fix #48414, right? It's more of a wontfix? |
It makes the behavior consistent with docs (which I was not aware of, before this morning). So in that sense it fixes the issue, because the order will be the same before and after the context manager of the reproducer in #48414.
Breaking this into two PRs is not bad imo, as I think there are a few aspects to discuss for the breaking behavior. If we go for cli order, then do we allow: spack -e /path1 -e /path2 ...? Right now, on Also, while it makes sense to treat cli options positionally, it's probably breaking some existing workflows to consider: spack -c option -e /env-path ...different from the opposite: spack -e /env-path -c option ...so I would separate the changes in two PRs. Footnotes
|
|
There is another caveat to the breaking behavior. In this PR we have a single priority for the environment scope, meaning with environment(new_env):
...should modify the scopes, before, within and after the context manager. If we lump the
Overall this seems to complicate a lot the current mechanism. |
spack -e /path1 -e /path2 ...No, I don't think we do, as this sets the install behavior for
Yeah we'll need to work this out separately. Let's hold off on that until some subsequent PR to introduce breakage if needed. I don't like the current semantics (they are counterintuitive to me) but I also don't think they are frequently used, so holding off and just getting this in as-is is fine. I think we should consider breaking this before 1.0 though -- as I don't think it's a large break outside our CI and I think the ordering could end up being counterintuitive in the long run. |
|
Ok, errors in the pipelines are all system failures, so not relevant here. Linking for future reference:
The runner and builder images seem correct. |
This reverts commit dcabe1b. Signed-off-by: Massimiliano Culpo <[email protected]>
Currently, the custom config scopes are pushed at the top when constructing configuration, and are demoted whenever a context manager activating an environment is used - see #48414 for details. Workflows that rely on the order in the [docs](https://spack.readthedocs.io/en/latest/configuration.html#custom-scopes) are thus fragile, and may break This PR allows to assign priorities to scopes, and ensures that scopes of lower priorities are always "below" scopes of higher priorities. When scopes have the same priority, what matters is the insertion order. Modifications: - [x] Add a mapping that iterates over keys according to priorities set when adding the key/value pair - [x] Use that mapping to allow assigning priorities to configuration scopes - [x] Assign different priorities for different kind of scopes, to fix a bug, and add a regression test - [x] Simplify `Configuration` constructor - [x] Remove `Configuration.pop_scope` --------- Signed-off-by: Massimiliano Culpo <[email protected]>
Currently, active environments, from the CLI or from `$SPACK_ENV`, will override configuration set on the command line. This is confusing, as users would normally expect command line options to override environment options (e.g. SPACK_ENV). See [more discussion here](#49187 (comment)). This PR changes how we process configuration options on the CLI so that: 1. Any CLI option overrides an active environment from `SPACK_ENV` 2. CLI options that add config scopes (`-D`, `-C`, and `-e`) are now considered for scope precedence in the order they appear on the CLI. What this means is that if you write: * `spack -C config_dir`: `config_dir` will override any active enviornment. * `spack -C config_dir -e env`: `env` will override `config_dir` * `spack -e env -C config_dir -e env`: `config_dir` will override `env` And similar for `-D`. This makes the order much more obvious. This is a breaking change, in that historically environments have been higher precedence than config scopes. - [x] rework scope adding in `main.py` - [x] add an action to handle config from CLI - [x] add shell tests and unit tests Signed-off-by: Todd Gamblin <[email protected]>
Currently, active environments, from the CLI or from `$SPACK_ENV`, will override configuration set on the command line. This is confusing, as users would normally expect command line options to override environment options (e.g. SPACK_ENV). See [more discussion here](#49187 (comment)). This PR changes how we process configuration options on the CLI so that: 1. Any CLI option overrides an active environment from `SPACK_ENV` 2. CLI options that add config scopes (`-D`, `-C`, and `-e`) are now considered for scope precedence in the order they appear on the CLI. What this means is that if you write: * `spack -C config_dir`: `config_dir` will override any active enviornment. * `spack -C config_dir -e env`: `env` will override `config_dir` * `spack -e env -C config_dir -e env`: `config_dir` will override `env` And similar for `-D`. This makes the order much more obvious. This is a breaking change, in that historically environments have been higher precedence than config scopes. - [x] rework scope adding in `main.py` - [x] add an action to handle config from CLI - [x] add shell tests and unit tests Signed-off-by: Todd Gamblin <[email protected]>
Currently, active environments, from the CLI or from `$SPACK_ENV`, will override configuration set on the command line. This is confusing, as users would normally expect command line options to override environment options (e.g. SPACK_ENV). See [more discussion here](#49187 (comment)). This PR changes how we process configuration options on the CLI so that: 1. Any CLI option overrides an active environment from `SPACK_ENV` 2. CLI options that add config scopes (`-D`, `-C`, and `-e`) are now considered for scope precedence in the order they appear on the CLI. What this means is that if you write: * `spack -C config_dir`: `config_dir` will override any active enviornment. * `spack -C config_dir -e env`: `env` will override `config_dir` * `spack -e env -C config_dir -e env`: `config_dir` will override `env` And similar for `-D`. This makes the order much more obvious. This is a breaking change, in that historically environments have been higher precedence than config scopes. - [x] rework scope adding in `main.py` - [x] add an action to handle config from CLI - [x] add shell tests and unit tests Signed-off-by: Todd Gamblin <[email protected]>
Currently, active environments, from the CLI or from `$SPACK_ENV`, will override configuration set on the command line. This is confusing, as users would normally expect command line options to override environment options (e.g. SPACK_ENV). See [more discussion here](#49187 (comment)). This PR changes how we process configuration options on the CLI so that: 1. Any CLI option overrides an active environment from `SPACK_ENV` 2. CLI options that add config scopes (`-D`, `-C`, and `-e`) are now considered for scope precedence in the order they appear on the CLI. What this means is that if you write: * `spack -C config_dir`: `config_dir` will override any active enviornment. * `spack -C config_dir -e env`: `env` will override `config_dir` * `spack -e env -C config_dir -e env`: `config_dir` will override `env` And similar for `-D`. This makes the order much more obvious. This is a breaking change, in that historically environments have been higher precedence than config scopes. - [x] rework scope adding in `main.py` - [x] add an action to handle config from CLI - [x] add shell tests and unit tests --------- Signed-off-by: Todd Gamblin <[email protected]>
Reverts #49185
fixes #48414
fixes #49188
Currently, the custom config scopes are pushed at the top when constructing configuration, and are demoted whenever a context manager activating an environment is used - see #48414 for details. Workflows that rely on the order in the docs are thus fragile, and may break
This PR allows to assign priorities to scopes, and ensures that scopes of lower priorities are always "below" scopes of higher priorities. When scopes have the same priority, what matters is the insertion order.
Modifications:
adding the key/value pair
add a regression test
ConfigurationconstructorConfiguration.pop_scope