Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions docs/migration_2_to_3.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,24 @@ As soon as it detects an old-style configuration file, it will convert it to the
./bin/reframe: the syntax of the configuration file 'unittests/resources/settings_old_syntax.py' is deprecated
./bin/reframe: configuration file has been converted to the new syntax here: '/var/folders/h7/k7cgrdl13r996m4dmsvjq7v80000gp/T/tmph5n8u3kf.py'

Alternatively, you can convert any old configuration file using the conversion tool ``tools/convert_config.py``:
Alternatively, you can convert any old configuration file using the conversion tool |convert_config|_:

.. |convert_config| replace:: :obj:`convert-config`
.. _convert_config: https://github.com/eth-cscs/reframe/blob/master/tools/convert-config

.. code-block:: none

$ ./tools/convert-config unittests/resources/settings_old_syntax.py
Conversion successful! The converted file can be found at '/var/folders/h7/k7cgrdl13r996m4dmsvjq7v80000gp/T/tmpz4f6yer4.py'.
$ ./tools/convert-config unittests/resources/settings_old_syntax.py new_config.py
Conversion successful! The converted file can be found at 'new_config.py'.


Another important change is that default locations for looking up a configuration file has changed (see `Configuring ReFrame for Your Site <configure.html>`__ for more details).
That practically means that if you were relying on ReFrame loading your ``reframe/settings.py`` by default, this is no longer true.
You have to move it to any of the default settings locations or set the corresponding command line option or environment variable.

.. note::
The conversion tool will create a JSON configuration file if the extension of the target file is ``.json``.


Automatic conversion limitations
================================
Expand Down
6 changes: 5 additions & 1 deletion reframe/core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,11 @@ def handler_list(handler_config):

if newfilename:
with open(newfilename, 'w') as fp:
fp.write(contents)
if newfilename.endswith('.json'):
json.dump(converted, fp, indent=4)
else:
fp.write(contents)

else:
with tempfile.NamedTemporaryFile(mode='w', suffix='.py',
delete=False) as fp:
Expand Down
3 changes: 3 additions & 0 deletions tools/convert_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
print(f'{sys.argv[0]}: too few arguments', file=sys.stderr)
print(f'Usage: {sys.argv[0]} OLD_CONFIG_FILE [NEW_CONFIG_FILE]',
file=sys.stderr)
print(' Use the extension of NEW_CONFIG_FILE to specify\n'
' python (.py) or json (.json) format.',
file=sys.stderr)
sys.exit(1)

try:
Expand Down