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

Allow users to create and use generalized variables in yaml files #28027

Open
2 tasks done
psakievich opened this issue Dec 15, 2021 · 1 comment
Open
2 tasks done

Allow users to create and use generalized variables in yaml files #28027

psakievich opened this issue Dec 15, 2021 · 1 comment
Assignees
Labels

Comments

@psakievich
Copy link
Contributor

psakievich commented Dec 15, 2021

Summary

As a user I would like to see the concept of the definitions: section in the spack.yaml file extended to allow for arbitrary variables that can be used throughout all the config files. Essentially I would like to abstract out the concept of the $spack variable so that I can set similar variables myself.

A solution proposed by @becker33 in the weekly telecon would looks something like this:

spack:
  definitions:
     variables:
       - spack_manager: $spack/../ 
       - view_dir: $spack_manager/views/snapshots/20211231
     specs:
      - first: [trilinos]
      - cuda: ['+cuda cuda_arch=71', '~cuda']
      - second:
          - matrix:
              - [$first]
              - [$cuda]
  specs:
    - $second
    - cmake
  packages:
     hdf5:
        externals:
         - spec: hdf5@1.10.7
            prefix: $view_dir
         buildable: false

where the current definition of spack:definitions: now becomes spack:definitions:specs: since this section is constrained to defining specs. A second subsection spack:definitions:variables: is also added which will allow users to generate variables which can be used arbitrarily throughout the config files.

Further input from @scheibelp is that we should extend this functionality to all of the configs and allow a spack:definitions section in all of them to enable the use of user defined variables.

Tagging: @alalazo @tgamblin

Rationale

No response

Description

A preliminary attempt at this was made in #27925 was made to enable the concept of this feature through YAML anchors, but due to their more complicated syntax this is not the preferred path for a production capability. Additionally, it appears that the read/write operations with ruamel.yaml automatically overwrite the anchors and aliases. This issue may be addressed in the newer versions of ruamel and we should consider updating regardless. @alalazo mentioned he tried this recently but there is additional work that will be required with the update.

Additional information

No response

General information

  • I have run spack --version and reported the version of Spack
  • I have searched the issues of this repo and believe this is not a duplicate
@scheibelp scheibelp self-assigned this Dec 15, 2021
@alalazo
Copy link
Member

alalazo commented Dec 17, 2021

For the record the issue is mainly with:

def _mark_internal(data, name):

and similar functions that rely on undocumented internals of ruamel.yaml. The latest version of ruamel.yaml with Python 2.7 support is 0.16.13, see https://pypi.org/project/ruamel.yaml/0.16.13/ and the Mark class used in the function above has been removed.

@tgamblin tgamblin added this to the v0.20.0 milestone Nov 7, 2022
@alalazo alalazo removed this from the v0.20.0 milestone May 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants