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

Add config.yaml file #2152

Merged
merged 12 commits into from
Oct 31, 2016
Merged

Add config.yaml file #2152

merged 12 commits into from
Oct 31, 2016

Conversation

tgamblin
Copy link
Member

@tgamblin tgamblin commented Oct 27, 2016

Rework of #908. Fixes #635, #1925.

This is a continuation of @hegner's #908, which allowed customizing the install location. This adds a top-level config.yaml with many commonly set properties. config.yaml consolidates a lot of the things currently in spack/__init__.py.

Todo:

  • Add config.yaml file
  • Add install_tree option to config.yaml
  • Move build_stage from __init__.py
  • Implement source_cache
  • Implement misc_cache
  • Move module install roots to config.yaml
  • Move verify_ssl from __init__.py
  • Move checksum from __init__.py
  • Move dirty from __init__.py
  • Update docs

Below is what the config.yaml file looks like currently. Just need to wire in the features.

Thoughts? @alalazo @adamjstewart @mamelara @mathstuf @justintoo @hegner

config:
  # This is the path to the root of the Spack install tree.
  # You can use $spack here to refer to the root of the spack instance.
  install_tree: $spack/opt/spack


  # Temporary locations Spack can try to use for builds.
  #
  # Spack will use the first one it finds that exists and is writable.
  # You can use $tempdir to refer to the system default temp directory
  # (as returned by tempfile.gettempdir()).
  #
  # A value of $local indicates that Spack should run builds directly
  # inside its install directory without staging them in temporary space.
  build_stage:
    - /usr/workspace/*/%u
    - $tempdir
    - /nfs/tmp2/%u
    - $local


  # Cache directory already downloaded source tarballs and archived
  # repositories. This can be purged with spack purge
  source_cache: $spack/var/spack/cache


  # Cache directory for miscellaneous files, like the package index.
  misc_cache: ~/.spack/cache


  # If this is false, tools like curl that use SSL will not verify
  # certifiates. (e.g., curl will use use the -k option)
  verify_ssl: true


  # If set to true, Spack will always check checksums after downloading
  # archives. If false, Spack skips the checksum step.
  checksum: true


  # If set to false, `spack install` and friends will NOT clean
  # potentially harmful variables from the build environment. Use wisely.
  clean: true

@adamjstewart
Copy link
Member

This looks awesome!

Only thing, can we change:

dirty: false

to

clean: true

@citibeth has mentioned avoiding negative logic before and I think it makes sense in this case.

@hegner
Copy link
Contributor

hegner commented Oct 27, 2016

Looks very good! Maybe docs could be added to your checklist.

@tgamblin
Copy link
Member Author

@adamjstewart: is dirty: false actually negative logic? dirty is the special case and we're saying it's true or false... not_dirty: true would be negative logic here I think.

I don't feel too strongly about this but dirty: true corresponds to the parameters on the commands.

@adamjstewart
Copy link
Member

@tgamblin In this case, "dirty" implies "not clean". It's a matter of whether or not we are cleaning up environment variables, not a matter of whether or not we want Spack to be "dirty". But I understand it matches the option flag. I guess the annoying thing is we don't have an option with the flag name.

@tgamblin
Copy link
Member Author

I could just was easily argue that clean implies not dirty...

@adamjstewart
Copy link
Member

Then why did you use "NOT clean" in the description of the flag? Because "dirty" doesn't actually mean anything 😆

@citibeth
Copy link
Member

I agree it's ambiguous here which one is negative logic. But I think the
"clean" terminology has the edge here because "dirty" has bad
connotations. Other things to consider might be "keep environment", which
is a more neutral term for what dirty does.

On Thu, Oct 27, 2016 at 4:13 PM, Adam J. Stewart notifications@github.com
wrote:

Then why did you use "NOT clean" in the description of the flag? Because
"dirty" doesn't actually mean anything 😆


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#2152 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AB1cdzFlVJqWaPSEL_tbugktyGSDDTOyks5q4QYDgaJpZM4KivqN
.

@tgamblin
Copy link
Member Author

Ok, everything but docs is done. Can people try this out?

I went with clean instead of dirty in config.yaml, and added --clean args to spack setup, spack diy, and spack install so you can be clean when Spack is dirty and vice versa.

@alalazo
Copy link
Member

alalazo commented Oct 28, 2016

From the tests :

==> List of failing tests:
  test_chdir (spack.test.stage.StageTest)
  test_expand_archive (spack.test.stage.StageTest)
  test_expand_archive_with_chdir (spack.test.stage.StageTest)
  test_fetch (spack.test.stage.StageTest)

@citibeth
Copy link
Member

Now that we have a config.yaml and a re-work of dirty/clean... would it be possible to integrate the functionality I removed in #1818 into config.yaml? (That is... add an option to config.yaml that is equivalent to always saying spack --dirty)

@tgamblin
Copy link
Member Author

@citibeth: I'm confused. That's is exactly what the "clean" option is. Note this also fixes #1925.

Maybe we should call it dirty after all?

@adamjstewart
Copy link
Member

That is... add an option to config.yaml that is equivalent to always saying spack --dirty

@citibeth That's what this PR does. You can set clean: False in config.yaml so Spack never cleans your paths. This can also be overridden on a case-by-case basis by running spack install --clean if you need to.

@citibeth
Copy link
Member

Great, thanks!

On Fri, Oct 28, 2016 at 11:06 AM, Adam J. Stewart notifications@github.com
wrote:

That is... add an option to config.yaml that is equivalent to always
saying spack --dirty

@citibeth https://github.com/citibeth That's what this PR does. You can
set clean: False in config.yaml so Spack never cleans your paths. This
can also be overridden on a case-by-case basis by running spack install
--clean if you need to.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#2152 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AB1cdyNV41iw6gPqSs9gTWH9zvx1VLTCks5q4g9kgaJpZM4KivqN
.

@pramodk
Copy link
Contributor

pramodk commented Oct 28, 2016

Wouldn't it be useful to have an option for --log-format as well?

@tgamblin
Copy link
Member Author

tgamblin commented Oct 28, 2016

@pramodk: what do you mean? You want to be able to default the log format to something? I think the raw output is a good default, and the XML output is good for tests -- is there a reason you'd want the XML output all the time?

@pramodk
Copy link
Contributor

pramodk commented Oct 28, 2016

I mean to enable --log-format. Correct me if I have misunderstood: XML report for a package is generated in var/spack/junit-report only when I specify --log-format=junit. I was wondering about an option to enable this (which could be useful during testing (?)).

@tgamblin
Copy link
Member Author

That might be useful -- let's get this merged and then see if we need it. I was thinking that for testing we would likely just call the command with the --log-format=junit option in the test script.

@tgamblin
Copy link
Member Author

tgamblin commented Oct 28, 2016

Ok this is all done and should be ready to go. Bugs are fixed and docs are in. Can I get a review?

@alalazo @adamjstewart @mamelara @mathstuf @justintoo @hegner

Will make Spack take compilers *only* from the user configuration, and
the site configuration will be ignored.
See the documentation on :ref:`configurations scopes
<configuration-scopes>`_ for details on how Spack's configuration system
Copy link
Member

Choose a reason for hiding this comment

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

The trailing underscore is causing the documentation tests to fail. I think the trailing underscore is only needed for external URLs, not internal references. Gotta love .rst!

@tgamblin
Copy link
Member Author

@adamjstewart Ok fixed up the docs. Added a bit more text to the page for spack.config, and the page for spack.schema now shows the schemas in the docs.

@tgamblin
Copy link
Member Author

Also, @hegner: I took out the ability to customize the DirectoryLayout class used for the install prefix.

My rationale is that I think if we allow install tree layouts to be customizable, it should be customizable through some configuration (e.g., install_tree.yaml?) in the directory layout itself, so that switching install trees does not require changing two configuration options (which is error-prone). Do you need that feature or can that wait?

#
# Per-spack-instance settings (overrides defaults):
# $SPACK_ROOT/etc/spack/config.yaml
#
Copy link
Member

Choose a reason for hiding this comment

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

etc/spack/config.yaml should be added to .gitignore. We don't want to normally check site configuration back into Spack. (If this is not added, config.yaml will end up accidentally in some PRs).

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes. /etc/spack/*.yaml is already in .gitignore

# This is the path to the root of the Spack install tree.
# You can use $spack here to refer to the root of the spack instance.
install_tree: $spack/opt/spack

Copy link
Member

Choose a reason for hiding this comment

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

Consider making $spack upper case, to align with common bash usage.

Copy link
Member Author

Choose a reason for hiding this comment

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

I really hate uppercase. And this is YAML. Also it's been this way for a while... the default repo location uses this syntax in /etc/spack/defaults/repos.yaml

# Locations where different types of modules should be installed.
module_roots:
tcl: $spack/share/spack/modules
lmod: $spack/share/spack/lmod
Copy link
Member

Choose a reason for hiding this comment

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

The Spack package for this is called environment-modules; I would suggest the same name be used here, rather than tcl.

Copy link
Member

Choose a reason for hiding this comment

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

I would not, as:

  1. this is consistent with the format in modules.yaml
  2. tcl identifies the type of module files written rather than the tools that understand them

The case for lmod was discussed in #107 and lmod was chosen over hierarchical_lua because of established conventions in the HPC communities.

Copy link
Member

Choose a reason for hiding this comment

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

As for (1)... if it were changed, it would have to be changed everywhere.

Copy link
Member Author

Choose a reason for hiding this comment

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

Personally I like the tcl designator, mainly because everything under modules: is technically an "environment module". But lmod, tcl, and dotkit is how most people (at least at LLNL) refer to them.

Copy link
Member

Choose a reason for hiding this comment

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

Probably should put parenthetically the first couple of times tcl is mentioned, that it's really environment-modules.


# Cache directory already downloaded source tarballs and archived
# repositories. This can be purged with spack purge
source_cache: $spack/var/spack/cache
Copy link
Member

Choose a reason for hiding this comment

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

I think spack cache purge or spack purge cache would be more descriptive than spack purge


# Cache directory for miscellaneous files, like the package index.
misc_cache: ~/.spack/cache

Copy link
Member

Choose a reason for hiding this comment

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

Is this also purged with spack purge?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point. I should put the right options to Spack purge on there. Yes, you can purge this with spack purge -u/--user-cache. That's kind of inconsistent with the naming here, so I'd say we should change the argument to spack purge -m/--misc-cache, since it could go someplace other than the user home directory. The distinction is really that the stuff in this cache is long-lived and small, so it doesn't need to be purged. The stuff in the build stage is short-lived, large, and purging doesn't hurt.

Copy link
Member

Choose a reason for hiding this comment

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

We need better terminology, the word "cache" is inherently confusing (since there are two caches). How about spack purge --misc-cache and spack purge download-cache?

higher precedence scopes, as defaults may change from version to
version.

2. **site**: Stored in ``$(prefix)/etc/spack/``. Settings here affect
Copy link
Member

Choose a reason for hiding this comment

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

So... the file is not copied from defaults to site?

Copy link
Member Author

Choose a reason for hiding this comment

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

No. The files have never been copied...

Copy link
Member

Choose a reason for hiding this comment

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

Needs to be made clear in the docs...


3. **user**: Stored in the home directory, ``~/.spack/``. These settings
affect all instances of Spack and take the highest precedence.

Copy link
Member

Choose a reason for hiding this comment

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

We also need a project scope. Typical use case... I'm building two software stacks with different version/dependency selections in them. Or I want to run an integration test with a packages.yaml different from my "normal" one. Suggested ways to find the project scope would be:

  1. An env var
  2. A command line argument. (This would have to be available on all commands, ideally parsed and set up before the command is run. So then one could alias myproject-spack 'spack --config ~/myproject/dotspack'
  3. Search up the source tree for a dotspack directory.

I would lean toward (2) as probably the best way to do this. As long as the Bash alias works, users can easily set up as many per-project Spack-like commands as they need.

Copy link
Member Author

Choose a reason for hiding this comment

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

I agree but this is a new feature not on the list for 0.10 and we should save it for another PR.

Commands that modify scopes (e.g., ``spack compilers``, ``spack repo``,
etc.) take a ``--scope=<name>`` parameter that you can use to control
which scope is modified.

Copy link
Member

Choose a reason for hiding this comment

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

Do any commands automagically modify scope? For example, the first time you run Spack? In that case, what scope will be modified? Should Spack ask for confirmation before modifying it?

Copy link
Member Author

Choose a reason for hiding this comment

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

The compiler detection is run the first time you start Spack, and compilers.yaml is put in the highest precedence scope available.

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think that should ask confirmation because first-time users have no idea what that means.

Copy link
Member

@citibeth citibeth Oct 30, 2016

Choose a reason for hiding this comment

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

OK, no asking for confirmation. It still needs to be decided (and documented) which scope is modified when there is a command that automagically modifies configuration.

4. ``site/<platform>``
5. ``user``
6. ``user/<platform>``

Copy link
Member

Choose a reason for hiding this comment

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

  1. How do we tell what <platform> is for our configuration?
  2. Are any platform-specific files included in defaults?

With per-project configurations, user/<platform> might be less necessary. But it's nice to have options...

Copy link
Member Author

Choose a reason for hiding this comment

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

I can make this clearer.

scopes, Spack will merge the settings between the two files. You can see
the results of this merge with the ``spack config get <configtype>``
command. For example, if your configurations look like this:

Copy link
Member

Choose a reason for hiding this comment

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

Nice

Copy link
Member Author

Choose a reason for hiding this comment

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

Most of this stuff has been there -- it just wasn't documented outside config.py. I realized that it probably needed to go in the real docs, since the config system in Spack is actually halfway decent at taking options from many different places/roles and combining them.

@citibeth
Copy link
Member

I look forward to seeing this merged (if nothing else because it touches so many files). The biggest thing I think is messing is per-project scope. I really think that needs to go in before this is merged.

@tgamblin tgamblin added the documentation Improvements or additions to documentation label Oct 30, 2016
@tgamblin tgamblin force-pushed the config_yaml branch 2 times, most recently from 8a1fbde to 1e07e4a Compare October 30, 2016 23:07
@tgamblin
Copy link
Member Author

Ok, @citibeth brought up some good points about the docs. I've reorganized them and tried to address all the concerns -- I think things are looking much better.

New stuff:

  • Refactored configuration section of the reference manual:
    • Top-level overview of how the config files and precedence work
    • "Basic settings" section on config.yaml
    • "Build settings" section covering the various uses of packages.yaml. This also makes the flexibility of packages.yaml more prominent in the docs (I think it was kind of buried before).
    • Modules stuff is all in one section. High level section is just called "Modules". @alalazo

Various refactors:

  • Reverted clean to dirty, because it was actually introducing a lot of negative logic because we usually talk about dirty things, not clean things. We're going to ask users "was your build dirty?" and not "was your build not clean?". And there was confusion with spack.clean and spack clean. I think it's clearer to leave it dirty.
  • Refactored clean and dirty args into spack.cmd.common.arguments.
  • Refactored spack.cmd.common.arguments so that the arguments are written the same way they are for argparse, which should make it easier to move args into there.

I think that is more than enough for one PR. FWIW, spack repo and repos.yaml still need to be documented a bit and needs a reference guide section. That can wait for another PR.

I'd like to get this merged soon so try to get any additional requests in soon.

Copy link
Member

@citibeth citibeth left a comment

Choose a reason for hiding this comment

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

LGTM, only minor docs suggestions.

etc.) take a ``--scope=<name>`` parameter that you can use to control
which scope is modified. By default they modify the highest-precedence
scope.

Copy link
Member

Choose a reason for hiding this comment

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

...meaning, they modify the highest-precedence scope that exists? So if you don't have a user scope, it will modify the site scope? This should be made crystal clear. Also, I'm not sure it's the right choice; since clueless users can then accidentally modify the site scope. Probably best for config-modifying commands to just modify the user scope by default --- creating a new one if none exists.


When spack queries for configuration parameters, it searches in
higher-precedence scopes first. So, settings in ab higher-precedence
file can override those with the same key in a lower-precedence one. For
Copy link
Member

Choose a reason for hiding this comment

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

ab is typo?

file can override those with the same key in a lower-precedence one. For
list-valued settings, Spack *prepends* higher-precedence settings to
lower-precedence settings.

Copy link
Member

Choose a reason for hiding this comment

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

How do you delete things from lower-precedence scope? If deleting is not yet possible, that should probably be noted in the docs. But I think it's a feature people will want at some point.

I see below that the double-colon notation is mentioned. It should probably be at least referenced right here, so readers aren't left on the hook wondering if deleting is possible.

override lower-precedence settings. To do this, you can use *two* colons
at the end of a key in a configuration file. For example, if the
**site** ``config.yaml`` above looks like this:

Copy link
Member

Choose a reason for hiding this comment

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

I see, this is how things can be "deleted". I think this makes sense to me, although the double-colon notation is somewhat subtle (but maybe standard YAML?)

hegner and others added 10 commits October 30, 2016 21:03
- Added a schema for config.yaml
- Moved install tree configuration to config.yaml
- Moved etc/spack/install.yaml to etc/spack/defaults/config.yaml
- renamed install_area to "store", to use a term in common with guix/nix.
  - in `config.yaml` file, it's called the `install_tree` to be more
    intuitive to users.
  - `install_tree` might've worked in the code, but `install_tree` is
    already a global function in the spack namespace, from
    llnl.util.filesystem.
- Moved temp finding logic to spack.stage
- Updated stage tests
- Added tests for new path substaitution of $user, $spack, $tempdir
- Added new preferences to config.yaml:
  - source_cache
  - misc_cache
  - verify_ssl
  - checksum
  - dirty
- generalized and fixed to work with any key in YAML file
- simplified schema writing, as well
- add more unit tests for the config system
- Rename test/yaml.py to test/spack_yaml.py
  - Add test/yaml.pyc to ignored pyc files.
@tgamblin
Copy link
Member Author

Ok this is (finally) done. This PR actually resulted in a lot more changes than @hegner's original, but it's a bunch of changes that Spack really needed. The config system is improved and had some bugs fixed, and things are documented much more thoroughly.

One thing that remains unfinished here is the default config scope behavior. Comment on #2184 if you care about that one -- I didn't feel like holding this up more for that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
configuration documentation Improvements or additions to documentation WIP
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants