|
PHYEX 0.9.5
PHYsique EXternalisée
|
This document is intended for persons who want to use the tools provided with the PHYEX package: preparation of the source code for the different models and checks of the contributions (bit-reproducibility of the test cases between two commits, coding norms...).
The tools are provided as a python package (pyphyextools, in the tools directory) which must be installed in editable mode (the tools use the files of the repository), for instance in a virtual environment:
The python dependencies (listed in tools/pyproject.toml) are installed automatically. In addition, some tools need:
The tools can be used from a repository (the version of the tools is the version of the repository) to check another commit or another local repository.
${PHYEXCONF} (the PHYEXCONF environment variable defaults to ${HOME}/.phyex) is the user directory containing:
The phyex-check_<model> tools create their compilation directories in:
The PHYEXREPOuser (default: UMR-CNRM), PHYEXREPOprotocol (https or ssh) and PHYEXREPOrepo environment variables give the GitHub repository from which the commits are cloned.
All the commands have a -h option describing their arguments.
This command prepares the source code for a model: extraction of the source code (from a commit or from a local repository), transformations (with pyfortool), generation of the interface modules, and, optionally, push of the result as a new branch. It is used to build the model specific branches (see the Integrator documentation) and by the phyex-check_<model> tools.
These commands compile a model (IAL, Meso-NH, LMDZ) or the test programs using the PHYEX source code of a given commit (or of a local repository), execute the test cases and compare the results against a reference simulation.
The steps are selected with options: -p (creation of the compilation directory), -c (compilation), -r (execution), -C (comparison), –remove (suppression of the compilation directory). The first argument is the commit (or the directory) to test, the second one is the reference: a commit, a directory or REF (the references given, test case by test case, in the 'testing' entry of the src/phyex/<model>_version.json file).
The version of the model to use is described in the src/phyex/<model>_version.json file (for instance, repository and commit of IAL in ial_version.json); the model source code is downloaded automatically.
Example for the test programs, with the source code of a local repository:
The –computeRefIfNeeded option computes the reference simulations that do not exist yet.
This command checks the 1D model (see the phyex1d documentation) with the same steps and arguments as phyex-check_testprogs: the source code is copied (or cloned) in $PHYEX1DDIR/<name>/PHYEX, a virtual environment is created next to it (-p), the pyphyex package is compiled and installed in this virtual environment (-c, the architecture is given with -a as for phyex-check_testprogs), the 1D model is run on DEPHY-SCM cases (-r, ARMCU/REF and FIRE/REF by default, -t to give other cases; the cases are installed in ${PHYEXCONF}/phyex1d if needed) and the results are compared to the reference (-C). The reference commits are given, case by case, in the 'testing' entry of the src/phyex/phyex1d_version.json file. As for phyex-check_testprogs, the –expand and –shumantrans options apply the corresponding source code transformations when building the package (PHYEX_TRANSFORMATION CMake variable); the reference simulations are always computed without transformation.
Example, with the source code of a local repository:
After each simulation, phyex-check_testprogs and phyex-check_phyex1d write the hash of the results in a hash_result.txt file next to them (for the test programs, the hash of the output listing starting at the first 'IBL' line, normalised as for the comparison; for phyex1d, the hash of the datasets of the result file, the attributes being ignored). Two results have the same hash if, and only if, the comparison step considers them identical.
With the –refHashFile FILE option, the comparison step (-C) uses a json file containing, for each test case, the reference commit and the hash of its results:
The hashes depend on the configuration (architecture, compiler, precision...): a file must be used for a single configuration. This mechanism is used by the GitHub workflow (.github/workflows/tests.yaml), the files being stored in the GitHub cache (see .github/actions/refhash/action.yml): the references are compiled and run only when their hash is unknown.
The exit status of the comparison step is 0 when the results are identical, 50 when they differ and another value in case of error. The GitHub workflow uses it to give two statuses for each tool and configuration: the 'compil/exec' job fails only on a hard failure (compilation, execution, error of the tools), the 'reproduction' job fails when the results differ from the references.
This command checks the coding norms (described in the CodingNorms documentation) of the source code (for instance: phyex-check_norms -v src/phyex).
This command checks the consistency of the repository: the version (src/phyex/VERSION file) is the version of the last release tag, the minimal pyfortool version is the same everywhere.
This command performs all the checks (consistency, coding norms, documentation generation, python wheel creation and the test cases of IAL, Meso-NH, testprogs, LMDZ and phyex1d) on the repository containing the tools (with its uncommitted modifications); the –only option restricts the checks and the –parallel option checks the different models simultaneously. The report is written on the standard output; it can also be sent by email in case of an error (–mail) and attached as a status to a github commit (–github-status, the API url to use must be given).
This command lists the commits between two commits or tags (for instance: phyex-changelog v0.9.3 v0.9.4), merge commits excluded (–merges to include them), sorted by category according to the title of the pull request which introduced each commit (see the Developer documentation): bugfixes, features, bugfixes and features, and others (commits not coming from a pull request, or coming from a pull request whose title does not follow the rule). Each line gives the pull request number, the date, the hash, the author and the first line of the commit message; –format markdown produces a markdown output. The commits must be present in the local repository (the one containing the tools, or –git-dir) and on GitHub, which is requested to find the pull requests (one request per commit). A GitHub token is recommended (GITHUB_TOKEN or GH_TOKEN environment variable, or .netrc file): without token, GitHub limits the number of requests to 60 per hour.
This script, at the root of the repository, is designed to be run periodically by cron. It clones (or updates) the PHYEX repository in ${PHYEXWORKDIR} (default: $HOME/PHYEXTESTING), checks out the last commit of a branch (or a given commit), installs the tools and runs phyex-check_commit, the result being attached as a status to the commit on GitHub (and sent by email in case of an error).