-
Notifications
You must be signed in to change notification settings - Fork 106
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
[feat] Enable YAML configuration files #3370
Open
vkarak
wants to merge
3
commits into
reframe-hpc:develop
Choose a base branch
from
vkarak:feat/yaml-config
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -6,9 +6,22 @@ ReFrame's behavior can be configured through its configuration file, environment | |||||
An option can be specified via multiple paths (e.g., a configuration file parameter and an environment variable), in which case command-line options precede environment variables, which in turn precede configuration file options. | ||||||
This section provides a complete reference guide of the configuration options of ReFrame that can be set in its configuration file or specified using environment variables. | ||||||
|
||||||
ReFrame's configuration is in JSON syntax. | ||||||
The full schema describing it can be found in |schemas/config.json|_ file. | ||||||
The final configuration for ReFrame is validated against this schema. | ||||||
ReFrame's configuration is a JSON object that is stored in either a Python, JSON or YAML file. | ||||||
In case of Python configuration, the configuration object must be stored in the special ``site_configuration`` variable: | ||||||
|
||||||
.. code-block:: python | ||||||
|
||||||
site_configuration = { | ||||||
.. # The configuration details. | ||||||
} | ||||||
|
||||||
The final configuration is validated against the schema |schemas/config.json|_. | ||||||
See also :ref:`manpage-configuration` for understanding how ReFrame builds its final configuration. | ||||||
|
||||||
.. warning:: | ||||||
.. versionchanged:: 4.8 | ||||||
|
||||||
Raw JSON configuration files are deprecated. | ||||||
|
||||||
The syntax we use to describe the different configuration objects follows the convention: ``OBJECT[.OBJECT]*.PROPERTY``. | ||||||
Even if a configuration object contains a list of other objects, this is not reflected in the above syntax, as all objects in a certain list are homogeneous. | ||||||
|
@@ -83,6 +96,10 @@ It consists of the following properties, which we also call conventionally *conf | |||||
2. Shell commands: Any string not prefixed with ``py::`` will be treated as a shell command and will be executed *during auto-detection* to retrieve the hostname. | ||||||
The standard output of the command will be used. | ||||||
|
||||||
.. note:: | ||||||
|
||||||
For YAML configuration files the ``py::`` prefixed strings cannot refer to user-defined functions. | ||||||
|
||||||
If the :option:`--system` option is not passed, ReFrame will try to autodetect the current system trying the methods in this list successively, until one of them succeeds. | ||||||
The resulting name will be matched against the :attr:`~config.systems.hostnames` patterns of each system and the system that matches first will be used as the current one. | ||||||
|
||||||
|
@@ -2288,3 +2305,51 @@ A *device info object* in ReFrame's configuration is used to hold information ab | |||||
:default: ``None`` | ||||||
|
||||||
Number of devices of this type inside the system partition. | ||||||
|
||||||
|
||||||
Dynamic configuration | ||||||
===================== | ||||||
|
||||||
One advantage of ReFrame's configuration is that it is programmable, especially if you are using the Python files. | ||||||
Since the configuration is loaded a Python module, you can generate parts of the configuration dynamically. | ||||||
|
||||||
The YAML configuration on the other hand is more static, although not fully. | ||||||
Code generation can still be used with the YAML configuration as it is treated as Jinja2 template, where ReFrame provides the following bindings: | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
- ``hostname``: The local host's hostname. | ||||||
- ``getenv(<envvar>)``: Retrieve an environment variable. | ||||||
- ``sh(<command>)``: Retrieve the standard output of a shell command. | ||||||
The command must be successful. | ||||||
|
||||||
These are two examples YAML logging configuration that uses one of those bindings: | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
.. code-block:: yaml | ||||||
|
||||||
logging: | ||||||
- handlers: | ||||||
- type: file | ||||||
name: reframe-{{ hostname }}.log | ||||||
level: debug2 | ||||||
format: "[%(asctime)s.%(msecs)03d] %(levelname)s: %(check_info)s: %(message)s" | ||||||
append: false | ||||||
|
||||||
|
||||||
.. code-block:: yaml | ||||||
|
||||||
logging: | ||||||
- handlers: | ||||||
- type: file | ||||||
name: reframe-{{ sh("hostname -s") }}.log | ||||||
level: debug2 | ||||||
format: "[%(asctime)s.%(msecs)03d] %(levelname)s: %(check_info)s: %(message)s" | ||||||
append: false | ||||||
|
||||||
.. code-block:: yaml | ||||||
|
||||||
logging: | ||||||
- handlers: | ||||||
- type: file | ||||||
name: reframe-{{ getenv("USER") }}.log | ||||||
level: debug2 | ||||||
format: "[%(asctime)s.%(msecs)03d] %(levelname)s: %(check_info)s: %(message)s" | ||||||
append: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,12 @@ | ||
archspec==0.2.5 | ||
docutils==0.18.1 | ||
jinja2==3.0.3; python_version == '3.6' | ||
jinja2==3.1.4; python_version >= '3.7' | ||
jsonschema==3.2.0 | ||
PyYAML==6.0.1; python_version < '3.8' | ||
PyYAML==6.0.2; python_version >= '3.8' | ||
semver==2.13.0; python_version == '3.6' | ||
semver==3.0.2; python_version >= '3.7' | ||
Sphinx==5.3.0; python_version < '3.8' | ||
Sphinx==7.1.2; python_version == '3.8' | ||
Sphinx==7.3.7; python_version >= '3.9' | ||
sphinx-rtd-theme==2.0.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -458,6 +458,25 @@ Note also that the system and environment specification in the test run output i | |||||
ReFrame has determined that the ``default`` partition and the ``baseline`` environment satisfy the test constraints and thus it has run the test with this partition/environment combination. | ||||||
|
||||||
|
||||||
YAML configuration | ||||||
------------------ | ||||||
|
||||||
.. versionadded:: 4.8 | ||||||
|
||||||
Apart from Python, ReFrame's configuration can be specified in a YAML file. | ||||||
The advantage is a more compact configuration, but it's not fully programmable as is the Python configuration. | ||||||
Below is the same configuration file presetend above, but in YAML: | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
|
||||||
.. literalinclude:: ../examples/tutorial/config/baseline.yaml | ||||||
:caption: | ||||||
:lines: 6- | ||||||
|
||||||
If you are using multiple configuration files, ReFrame allows you to "mix and match" the configuration file types: some of them can be in Python, others in YAML. | ||||||
|
||||||
Note that YAML configuration files offer a minimal programmability as they are essentially `Jinja2 <https://jinja.palletsprojects.com/>`__ templates where a few variables are substituted by ReFrame. | ||||||
Check the configuration reference for more information. | ||||||
|
||||||
.. _compiling-the-test-code: | ||||||
|
||||||
Compiling the test code | ||||||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Copyright 2016-2025 Swiss National Supercomputing Centre (CSCS/ETH Zurich) | ||
# ReFrame Project Developers. See the top-level LICENSE file for details. | ||
# | ||
# SPDX-License-Identifier: BSD-3-Clause | ||
|
||
systems: | ||
- name: tutorialsys | ||
descr: Example system | ||
hostnames: ['myhost'] | ||
partitions: | ||
- name: default | ||
descr: Example partition | ||
scheduler: local | ||
launcher: local | ||
environs: ['baseline'] | ||
environments: | ||
- name: baseline | ||
features: ['stream'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.