Skip to content

Commit 647988c

Browse files
Apps macro wps (#261)
1 parent cd108e6 commit 647988c

File tree

6 files changed

+102
-21
lines changed

6 files changed

+102
-21
lines changed

source/Reviewers/howtocommit.rst

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,18 @@ then you will need to upgrade the test-suite.
166166
where `vnX.Y_tZZZZ` is the `AFTER_TAG` of the latest upgrade macro.
167167
The upgrade is expected to fail for the `fab_jules`, `metadata_checker` and `umdp3_checker` apps.
168168

169+
.. tab-item:: LFRic Apps + Core
170+
171+
.. code-block:: RST
172+
173+
apply_macros.py vnX.Y_tZZZZ [--apps=/path/to/apps] [--core=/path/to/core] [--jules=/path/to/jules]
174+
175+
where `vnX.Y_tZZZZ` is the `AFTER_TAG` of the latest upgrade macro and the others are paths to the relevant sources. Apps defaults to the current location. Core and Jules default to reading the `dependencies.sh` file in the Apps source. A copy of `apply_macros.py` is available at `$UMDIR/SimSys_Scripts/lfric_macros`.
176+
177+
.. note::
178+
179+
All LFRic Core tickets with macros are expected to be linked with LFRic Apps, though they may not have required an LFRic Apps development branch (although an Apps ticket should be provided). This is fine - if there is no LFRic Apps branch just checkout the LFRic Apps trunk. Then run the apply_macros script as described above and this will share the upgrade macro across both LFRic Apps and LFRic Core as needed.
180+
169181
.. dropdown:: New rose-stem app?
170182

171183
If the ticket introduces a new rose-stem app, but doesn't otherwise have a macro
@@ -191,11 +203,12 @@ then you will need to upgrade the test-suite.
191203
rose macro --validate -M path/to/working_copy/rose-meta
192204
193205
.. note::
194-
For UM tickets, if there are linked `jules-shared
195-
<https://code.metoffice.gov.uk/trac/jules/browser/main/trunk/rose-meta/jules-shared>`_
196-
metadata changes these will need to be added to the metadata
197-
path. Please see the :ref:`rose config-edit
198-
example<metadata_changes>`.
206+
207+
LFRic Apps tickets will require an LFRic Core source to use. You can do this by checking out an appropriate working copy, and exporting the environment variable `ROSE_META_PATH=/path/to/core`.
208+
209+
For UM tickets, if there are linked `jules-shared
210+
<https://code.metoffice.gov.uk/trac/jules/browser/main/trunk/rose-meta/jules-shared>`_
211+
metadata changes then a suitable Jules source will need to be included in the `ROSE_META_PATH` as described above.
199212

200213

201214
.. dropdown:: Temporary Logical?
@@ -492,7 +505,6 @@ Supporting data is stored in the filesystems of our machines and changes to use
492505
.. note::
493506
The numbered run directory must be included in the suite name, eg. `name-of-suite/run1`.
494507

495-
496508
5. Verify the checksums updated properly by retriggering the failed checksums. First retrigger
497509
``export-source``, and then when complete ``export-source_xc40`` if new checksums are present
498510
there (there is no need to retigger spice). You may need to change the maximum window extent

source/WorkingPractices/TestSuites/ukca.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ Changes in UKCA that touch `src/science` or `src/control/core` must be tested
55
with both the UM and LFRic by following the :ref:`linked tickets guidance <multirepo>`.
66

77
For further guidance on testing and working with UKCA, including standard
8-
suites and box models see the
9-
`UKCA trac wiki<https://code.metoffice.gov.uk/trac/ukca/wiki/WorkingPractices>`_.
8+
suites and box models see the
9+
`UKCA trac wiki <https://code.metoffice.gov.uk/trac/ukca/wiki/WorkingPractices>`_.

source/WorkingPractices/documentation.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Most notably:
1515

1616
LFRic Apps and Core also use doxygen to document the code and all changes should
1717
include appropriate doxygen changes to go with them. Doxygen guidelines are
18-
available on the `LFRic Technical pages<https://code.metoffice.gov.uk/trac/lfric/wiki/LFRicTechnical/DoxygenUsage>`_.
18+
available on the `LFRic Technical pages <https://code.metoffice.gov.uk/trac/lfric/wiki/LFRicTechnical/DoxygenUsage>`_.
1919

2020
.. toctree::
2121
:hidden:

source/WorkingPractices/inputs.rst

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ metadata :ref:`is available <metadata_guidance>`.
5353
work with the model.
5454

5555
Changes to the metadata which don't involve namelist changes may or may not
56-
require an upgrade macro. If you are unsure whether a UM change needs an
56+
require an upgrade macro. If you are unsure whether a change needs an
5757
upgrade macro, then run the following command on your branch:
5858

5959
.. code-block::
@@ -63,10 +63,25 @@ upgrade macro, then run the following command on your branch:
6363
If all of the tests pass then there is no requirement to add an upgrade macro.
6464
If any of the metadata tests fail, then the developer should add a blank upgrade
6565
macro which contains no upgrade commands but simply points the rose stem suite
66-
to the new metadata.
66+
to the new metadata. The SSD team are also available to advise on whether an upgrade macro is necessary.
6767

68-
..
69-
The above should probably be extended to LFRic eventually.
68+
.. tip::
69+
70+
When editing metadata you should always check that the new metadata appears as expected in the gui, including testing that invalid settings raise appropriate warnings. The command to open the gui is in general:
71+
72+
.. code-block::
73+
74+
rose edit -C rose-stem/app/APP-NAME
75+
76+
For LFRic Apps a few extra changes are required:
77+
78+
.. code-block::
79+
80+
export ROSE_PYTHONPATH=$PYTHONPATH
81+
export ROSE_META_PATH=/path/to/valid/core
82+
rose edit -C rose-stem/app/APP-NAME
83+
84+
This requires an LFRic Core working copy at an appropriate revision to be available. It is also necessary to run from the top level of the Apps working copy to ensure rose metadata paths are valid.
7085

7186
How to add an upgrade macro to your branch
7287
------------------------------------------

source/WorkingPractices/macros.rst

Lines changed: 58 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
Upgrade Macros
44
==============
55

6-
To create an upgrade macro, the developer must edit a ``versions.py`` file which is used
7-
to update the various apps in the rose stem suite to accept the namelist changes. The upgrade
8-
macros also form the basis of the ``rose app-upgrade`` script applied by a user wishing to
9-
upgrade from one version of a model to the next.
6+
.. important::
7+
8+
When developing Upgrade Macros, they must be tested using a test branch (see :ref:`testing`).
9+
10+
To create an upgrade macro, the developer must edit a ``versions.py`` file which is used to update the various apps in the rose stem suite to accept the namelist changes. The upgrade macros also form the basis of the ``rose app-upgrade`` script applied by a user wishing to upgrade from one version of a model to the next.
1011

1112
The ``versions.py`` file containing upgrade macros can be found in the following locations:
1213

@@ -20,6 +21,11 @@ The ``versions.py`` file containing upgrade macros can be found in the followin
2021

2122
``rose-meta/jules-standalone/versions.py``
2223

24+
.. tab-item:: LFRic Core + Apps
25+
26+
| ``applications/<APPLICATION>/rose-meta/lfric-<APPLICATION>/versions.py``
27+
| Variations on this theme occur, eg. LFRic Apps science sections or Components in LFRic Core
28+
2329

2430
Within the file a blank upgrade macro will typically look like this:
2531

@@ -73,3 +79,51 @@ This command can then be run on a **test** branch (see :ref:`testing`).
7379
namelists and changing the value that a particular variable takes.
7480
A `tutorial <http://metomi.github.io/rose/doc/html/tutorial/rose/furthertopics/upgrading.html>`_
7581
is also available.
82+
83+
84+
Upgrade Macros in LFRic
85+
-----------------------
86+
87+
.. warning::
88+
89+
Namelist files in application example directories are not currently updated by the Apply Macros script. This feature is intended to be introduced, but for now, developers still need to manually update those files.
90+
91+
The organisation of LFRic metadata is different from other repositories (UM + Jules) as the metadata is stored with the Science or Application section it is associated with and is then imported by other apps that require it. This helps modularise the LFRic code but complicates macro chains.
92+
93+
To solve this, macros in LFRic Apps are applied using a wrapper script which will read the added macros and combine them into the versions.py files for the apps where that metadata is imported. Therefore when adding macros, the macro should be added in the versions.py file in the same metadata directory as the metadata change being made. It will then be shared as appropriate by the ``apply_macros.py`` script.
94+
95+
For example, if a change to metadata is made in ``science/gungho/rose-meta/lfric-gungho``, the macro should be added to the ``versions.py`` file in that directory. This will then be copied to other ``versions.py`` files that import gungho metadata, eg. lfric_atm, transport etc.
96+
97+
It is expected that all metadata changes in LFRic Core will require change to the rose-apps in LFRic Apps, but changes to Apps must not affect Core. Therefore, the apply_macros script requires a working copy of LFRic Apps to work, but will source it's own copy of Core if required. If your only changes are to LFRic Core metadata, then you will require a linked LFRic Apps ticket and test branch, but potentially not a development branch.
98+
99+
.. important::
100+
101+
Some complex macro commands may be dependent on the order in which they are applied. As macros are copied by the wrapper script, the order they are applied will always be determined by the reverse metadata import order. For example, lfric_atm imports gungho metadata, which itself imports components/driver. If all 3 sections have an associated macro, then the macro commands would be applied in the order: components/driver, gungho, lfric_atm.
102+
103+
.. tip::
104+
105+
The wrapper script will read the ``dependencies.sh`` file in your LFRic Apps working copy and will checkout a temporary copy of the LFRic Core source if required. Some Core metadata changes will also modify the Core rose apps. In this case make sure to also commit these changes back to the core branch.
106+
107+
To add upgrade macros to LFRic the following steps can be followed:
108+
109+
110+
111+
1. Checkout an LFRic Apps working copy and update the core source in ``dependencies.sh`` if you have LFRic Core changes.
112+
2. Add your upgrade macros. These **must** be added to the versions.py file in the same directory as the metadata being changed.
113+
3. Run the Upgrade Macro script in a test branch (see :ref:`testing`). This is located in the `SimSys_Scripts github repo <https://github.com/MetOffice/SimSys_Scripts>`_ (at meto an up to date clone is available in $UMDIR/SimSys_Scripts). The syntax for running is:
114+
115+
.. code-block::
116+
117+
SimSys_Scripts/lfric_macros/apply_macros.py vnXX.Y_tTTTT -a Apps -c Core -j Jules
118+
119+
.. important::
120+
121+
**Test branches must be used for running the Apply Macros script. Do not commit the changes made by apply_macros.py to a Dev Branch**
122+
123+
The Apps, Core and Jules options are paths to sources for each of these. Apps will default to the present location (so it is recommended to launch from an Apps working copy). Core and Jules will default to reading the ``dependencies.sh`` file in the Apps source if not provided.
124+
125+
The ``vnXX.Y_tTTTT`` option must match the After Tag of your upgrade macro. When setting this, the version is the last released version of LFRic Apps. If it's a linked Apps-Core ticket, then set the ticket number as the one where the most metadata changes are being made.
126+
127+
.. tip::
128+
129+
The apply_macros script requires python >= 3.9. At the Met Office this can be achieved by ``module load scitools``.

source/WorkingPractices/testing.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,12 @@ commands, noting that ``--jules-path`` is only required if you have
7979
+-------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
8080
| JULES | ``./bin/upgrade_jules_test_apps vnX.X_tXXXX`` |
8181
+-------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
82+
| LFRic | ``apply_macros.py vnX.Y_tZZZZ [--apps=/path/to/apps] [--core=/path/to/core] [--jules=/path/to/jules]`` |
83+
+-------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
8284

83-
..
84-
| LFRic | *Macro capabilities are currently in development* |
85-
+-------+------------------------------------------------------------------------------------------------------------------------------------------------+
85+
.. tip::
8686

87-
.. todo: add an LFRic upgrade macro command... and make these more consistent?
87+
The `apply_macros.py` script is located in the `SimSys_Scripts github repo <https://github.com/MetOffice/SimSys_Scripts>`_ (at meto an up to date clone is available in $UMDIR/SimSys_Scripts).
8888

8989
.. warning::
9090
Please ensure that Cylc7 is used with `update_all.py` @vn13.5. This is fixed at HoT and either Cylc7 or Cylc8 can be used.

0 commit comments

Comments
 (0)