2. Utilities

2.1. Component Versions Script

metplus/component_versions.py

This script is used to query a METplus coordinated release component version number lookup table to determine a corresponding version number for another METplus component.

This script can be called directly from a script or the command line. It returns the version of the requested (output) METplus component. This functionality can also be imported in a Python script. See below for examples.

2.1.1. Usage Statement

usage: component_versions.py [-h] [-i INPUT_COMPONENT] [-v INPUT_VERSION] -o
                             OUTPUT_COMPONENT [-f OUTPUT_FORMAT]
                             [--get_dev_version | --no-get_dev_version]

options:
  -h, --help            show this help message and exit
  -i INPUT_COMPONENT, --input_component INPUT_COMPONENT
                        Name of METplus component to use to find version. Default
                        is METplus.
  -v INPUT_VERSION, --input_version INPUT_VERSION
                        version of input_component to search. Default is latest
                        official release
  -o OUTPUT_COMPONENT, --output_component OUTPUT_COMPONENT
                        name of METplus component to obtain version
  -f OUTPUT_FORMAT, --output_format OUTPUT_FORMAT
                        format to use to output version number.{X}, {Y}, and {Z}
                        will be replaced with x, y, and z version numbers from
                        X.Y.Z. {N} will be replaced with development version if
                        found in the input version, e.g. "-beta3" or "-rc1"
                        Default is v{X}.{Y}.{Z}{N}
  --get_dev_version, --no-get_dev_version
                        If True, get corresponding -beta or -rc version. If
                        False, return develop if development version. (default:
                        True)

2.1.2. Examples

These examples do not include the full path to the script.

2.1.2.1. Get MET vX.Y.Z version from METplus release

$ component_versions.py -v 5.1.0 -o MET
v11.1.1

If the input component is not specified, it will use the METplus version. The default output format is v{X}.{Y}.{Z}{N}.

2.1.2.2. Get MET vX.Y.Z version from coordinated release

$ component_versions.py -v 5.1 -o MET
v11.1.1

The coordinated release version matches the METplus X.Y version, so the coordinated release version can also be used as the input version.

2.1.2.3. Get MET vX.Y.Z development version from beta release

$ component_versions.py -v 6.0.0-beta3 -o MET
v12.0.0-beta3

If a beta release version is provided as the input, the output will include the same beta version.

2.1.2.4. Get MET vX.Y.Z development version from -dev version

$ component_versions.py -v 6.0.0-beta3-dev -o MET
develop

If the input version includes -dev, the result will always be develop.

2.1.2.5. Get MET vX.Y.Z development version from beta version

$ component_versions.py -v 6.0.0-beta3 -o MET --no-get_dev_version
develop

If the –no-get_dev_version argument is provided, an input version that includes -betaN or -rcN will return develop.

2.1.2.6. Get MET main_vX.Y version from METplus release

$ component_versions.py -v 5.1.0 -o MET -f main_v{X}.{Y}
main_v11.1

The output format can be specified using the -f argument. {X}, {Y}, {Z}, and {N} will be substituted with values based on the input.

2.1.2.7. Get METplotpy main_vX.Y version from METviewer release

$ component_versions.py -i METviewer -v 5.1.0 -o METplotpy -f main_v{X}.{Y}
main_v2.1

The -i argument can be used to specify the input component that corresponds to the input version number.

2.1.2.8. Get METplotpy main_vX.Y version from METviewer main_vX.Y branch

$ component_versions.py -i METviewer -v main_v5.1 -o METplotpy -f main_v{X}.{Y}
main_v2.1

The input version number can be provided in different formats, including main_vX.Y and vX.Y.Z.

2.1.2.9. Using Python Function

>>> from metplus.component_versions import get_component_version
>>> version = get_component_version(input_component='METplus',
                                    input_version='6.0.0',
                                    output_component='MET',
                                    output_format='main_v{X}.{Y}',
                                    get_dev=False)
>>> print(version)
main_v12.0

2.2. METplus Utils

These files are found under metplus/util.

Utility scripts used by the METplus Wrappers.

MORE INFO COMING SOON

2.2.1. config_metplus.py

2.2.2. config_util.py

2.2.3. config_validate.py

2.2.4. constants.py

2.2.5. diff_util.py

2.2.6. field_util.py

2.2.7. met_config.py

2.2.8. metplus_check.py

2.2.9. run_util.py

2.2.10. string_manip.py

2.2.11. string_template_substitution.py

2.2.12. system_util.py

2.2.13. time_looping.py

2.2.14. time_util.py

2.2.15. wrapper_init.py

2.3. Internal Development Tools

These utilities scripts can be found in internal/scripts/dev_tools. They were written to assist with common development tasks.

2.3.1. Add MET Config Helper

internal/scripts/dev_tools/add_met_config_helper.py

MORE INFO COMING SOON

2.3.2. Generate Release Notes

internal/scripts/dev_tools/generate_release_notes.py

This script queries METplus GitHub repositories and returns a formatted list of GitHub issues that were closed after the date provided. Note that this list may not correspond exactly to the issues from the latest development cycle, but it is a good start. The script also parses certain keywords from the beginning of the issue title and puts the issues under those section headings. If none of the keywords from the script can be parsed, the issues will be put under a catch-all group at the end. Developers should rearrange these issues as appropriate.

This script must be run using a version of Python that has the github Python package installed:

conda install -c conda-forge pygithub

OR:

mamba install pygithub

To run the script, first obtain a GitHub personal access token. Set the environment variable GITHUB_TOKEN with this value:

export GITHUB_TOKEN=gha_...

Call the script, passing as arguments the name of the release, e.g. 6.0.0-rc1, and the date when the development cycle started, e.g. 20241019:

~/METplus/internal/scripts/dev_tools/generate_release_notes.py 6.0.0-rc1 20241019

To parse issues from a repository other than METplus, provide the repository name using the -r argument:

~/METplus/internal/scripts/dev_tools/generate_release_notes.py 12.0.0-rc1 20241019 -r MET

Please note that additional review and cleanup of the generated content may be necessary.

The script will also output formatted table entries for the METplus Release Acceptance Testing GitHub Discussion. This content will need to be modified to include a description, assignee (if applicable), and updates to the status.