-
- Downloads
Improve validation of modules.yaml (#9878)
This PR improves the validation of `modules.yaml` by introducing a custom validator that checks if an attribute listed in `properties` or `patternProperties` is a valid spec. This new check applied to the test case in #9857 gives: ```console $ spack install szip ==> Error: /home/mculpo/.spack/linux/modules.yaml:5: "^python@2.7@" is an invalid spec [Invalid version specifier] ``` Details: * Moved the set-up of a custom validator class to spack.schema * In Spack we use `jsonschema` to validate configuration files against a schema. We also need custom validators to enforce writing default values within "properties" or "patternProperties" attributes. * Currently, validators were customized at the place of use and with the recent introduction of environments that meant we were setting-up and using 2 different validator classes in two different modules. * This commit moves the set-up of a custom validator class in the `spack.schema` module and refactors the code in `spack.config` and `spack.environments` to use it. * Added a custom validator to check if an attribute is a valid spec * Added a custom validator that can be used on objects, which yields an error if the attribute is not a valid spec. * Updated the schema for modules.yaml * Updated modules.yaml to fix a few inconsistencies: - a few attributes were not tested properly using 'anyOf' - suffixes has been updated to also check that the attribute is a spec - hierarchical_scheme has been updated to hierarchy * Removed $ref from every schema * $ref is not composable or particularly legible * Use python dicts and regular old variables instead.
Showing
- lib/spack/llnl/util/lang.py 3 additions, 0 deletionslib/spack/llnl/util/lang.py
- lib/spack/spack/config.py 2 additions, 50 deletionslib/spack/spack/config.py
- lib/spack/spack/environment.py 2 additions, 8 deletionslib/spack/spack/environment.py
- lib/spack/spack/schema/__init__.py 78 additions, 0 deletionslib/spack/spack/schema/__init__.py
- lib/spack/spack/schema/env.py 0 additions, 2 deletionslib/spack/spack/schema/env.py
- lib/spack/spack/schema/merged.py 1 addition, 2 deletionslib/spack/spack/schema/merged.py
- lib/spack/spack/schema/modules.py 106 additions, 107 deletionslib/spack/spack/schema/modules.py
- lib/spack/spack/test/schema.py 77 additions, 0 deletionslib/spack/spack/test/schema.py
Loading
Please register or sign in to comment