Skip to content
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

[develop]: Add GitHub Actions to check that Technical Docs are up-to-date #1152

Merged
merged 55 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from 54 commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
92690ef
add prelim wflow def and script
gspetro-NOAA Nov 1, 2024
6df170a
update workflow dispatch option
gspetro-NOAA Nov 1, 2024
7051424
update push option
gspetro-NOAA Nov 1, 2024
d5d4212
make doc_test.sh executable
gspetro-NOAA Nov 1, 2024
6342b00
rm erroneous pipefail cmd
gspetro-NOAA Nov 3, 2024
8510b03
make doc_build.sh executable
gspetro-NOAA Nov 3, 2024
a559dea
rm rtd theme & bibtex lines
gspetro-NOAA Nov 3, 2024
1f751b8
sudo install sphinx
gspetro-NOAA Nov 3, 2024
5a69f6a
fix paths
gspetro-NOAA Nov 3, 2024
f7ce17f
fix dir path?
gspetro-NOAA Nov 3, 2024
04f1586
fix dir path?
gspetro-NOAA Nov 3, 2024
28457a6
fix dir path?
gspetro-NOAA Nov 3, 2024
97b4e89
fix dir path?
gspetro-NOAA Nov 3, 2024
9f939cf
delete calculate_cost.py for testing purposes
gspetro-NOAA Nov 3, 2024
fe7cf3f
add git diff
gspetro-NOAA Nov 3, 2024
f72f244
test what's in dirs
gspetro-NOAA Nov 3, 2024
02c14dc
update paths
gspetro-NOAA Nov 3, 2024
8f11d3d
update script name; add build step
gspetro-NOAA Nov 3, 2024
b82dbb1
update file name:
gspetro-NOAA Nov 3, 2024
c50ddc1
install sphinx rtd theme
gspetro-NOAA Nov 3, 2024
ca2c338
update requirements files
gspetro-NOAA Nov 3, 2024
3268c37
rm autoyaml from conf.py
gspetro-NOAA Nov 3, 2024
f81e9a7
rm set_fv3 files
gspetro-NOAA Nov 3, 2024
ba5e95e
re-add set_fv3nml files
gspetro-NOAA Nov 3, 2024
fa3e59d
capture git diff output?
gspetro-NOAA Nov 4, 2024
86377a8
get git diff output?
gspetro-NOAA Nov 4, 2024
41ace75
close quotes
gspetro-NOAA Nov 4, 2024
eb88b2b
add warn as error
gspetro-NOAA Nov 4, 2024
163cc97
nitpick ignore Basemap
gspetro-NOAA Nov 4, 2024
9ff3632
fix link
gspetro-NOAA Nov 4, 2024
a884926
add git status
gspetro-NOAA Nov 4, 2024
9fdfcbd
check git status output
gspetro-NOAA Nov 4, 2024
6e2d202
clean up & rename check_tech_doc.sh
gspetro-NOAA Nov 4, 2024
2b08b87
add calculate_cost.rst back for testing
gspetro-NOAA Nov 4, 2024
cff4829
use short git status
gspetro-NOAA Nov 4, 2024
cb19a8e
fix git status command?
gspetro-NOAA Nov 4, 2024
97a09fb
fix bash variable ref
gspetro-NOAA Nov 4, 2024
602c9e9
troubleshooting git status
gspetro-NOAA Nov 4, 2024
1567d4b
troubleshooting status
gspetro-NOAA Nov 4, 2024
bca0f5d
clean up check_tech_doc.sh
gspetro-NOAA Nov 4, 2024
e63979c
update requirements files
gspetro-NOAA Nov 6, 2024
eec39e8
update tech doc GA w/--remove-old
gspetro-NOAA Nov 7, 2024
174a056
fix broken link in VX ch
gspetro-NOAA Nov 7, 2024
11b8d7e
set -leo pipefail
gspetro-NOAA Nov 7, 2024
baa3556
set -eo pipefail
gspetro-NOAA Nov 7, 2024
2a5d419
specify sphinx version
gspetro-NOAA Nov 7, 2024
22e8d1d
test pipefail
gspetro-NOAA Nov 7, 2024
88d4f0d
add back pip instal sphinx
gspetro-NOAA Nov 7, 2024
3416c15
testing new PY file w/o RST
gspetro-NOAA Nov 7, 2024
af116fb
test modules.rst w/o calc_cost listed
gspetro-NOAA Nov 7, 2024
3018cab
test modules.rst w/o calc_cost listed but w/test.rst
gspetro-NOAA Nov 7, 2024
c5a32fb
rm test.py; update modules.rst for passing test
gspetro-NOAA Nov 7, 2024
bd32d4a
update Contrib Guide w/info on documentation/tech docs
gspetro-NOAA Nov 7, 2024
4e71ec7
add instructions for tech doc updates
gspetro-NOAA Nov 12, 2024
eb84a17
rm wflow dispatch option on feature/doc-actions branch
gspetro-NOAA Nov 12, 2024
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
28 changes: 28 additions & 0 deletions .github/scripts/check_tech_doc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash
# This script recreates technical documentation for the ush and tests/WE2E Python scripts
# If the tech docs produced here do not match the branch's contents, the script will fail

set -eo pipefail

# Install prerequisites
pip install sphinx
pip install sphinx-rtd-theme
pip install sphinxcontrib-bibtex

# Regenerate tech docs in ush and tests/WE2E based on current state of scripts in those directories.
cd doc/TechDocs
sphinx-apidoc -fM --remove-old -o ./ush ../../ush
sphinx-apidoc -fM --remove-old -o ./tests/WE2E ../../tests/WE2E

# Check for mismatch between what comes out of this action and what is in the PR.
status=`git status -s`

if [ -n "${status}" ]; then
echo ${status}
echo ""
echo "Please update your Technical Documentation RST files."
exit 1
else
echo "Technical documentation is up-to-date."
exit 0
fi
27 changes: 27 additions & 0 deletions .github/workflows/doc_tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Doc Tests
on:
push:
pull_request:
branches:
- develop
- 'release/*'
workflow_dispatch:
branches:
- 'feature/doc-actions'
gspetro-NOAA marked this conversation as resolved.
Show resolved Hide resolved

defaults:
run:
shell: bash -leo pipefail {0}

jobs:
doc_tests:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Check tech docs
run: .github/scripts/check_tech_doc.sh
- name: Build documentation
run: |
cd doc
make doc
52 changes: 51 additions & 1 deletion doc/ContribGuide/documentation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,54 @@ Please follow these guidelines when contributing to the documentation:

.. code-block:: python

n = 88
n = 88

Troubleshooting Documentation
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

In the SRW App documentation Makefile (``ufs-srweather-app/doc/Makefile``), the ``-W`` option causes documentation builds to fail when there are errors or warnings in the build.
This ensures that the documentation remains up-to-date and notifies developers of any new issues (like failing links). However, the build will fail when it hits the first error without showing subsequent errors.
When troubleshooting, it can be useful to see all warnings and errors.
To see all warnings and errors, comment out the ``-W`` flag in ``SPHINXOPTS`` in the Makefile and build the documentation by running ``make doc`` from the ``doc`` directory.

Technical Documentation Guidelines
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Technical (API-like) documentation is generated for any Python scripts in the ``ush`` or ``tests/WE2E`` directories.
When developers change Python files in these directories, they need to update the Python docstrings (i.e., comments in ``"""triple quotes"""``) to reflect the changes they made.
Each Python script should include:

* A summary of the script's purpose/functionality

* Should start with a verb, e.g., "checks" or "loads" or "initializes"

* Docstrings for each method (except methods like ``_parse_args`` that start with an underscore). These docstrings should include:

* A description of what the method does (starting with a verb, e.g., "checks" or "parses")
* A list of method parameters, or ``Args:``, with a definition and expected data type for each
* A return statement (``Returns:``) -- if applicable
* List of exceptions (``Raises:``) -- if applicable

.. note::

Python does not have truly private methods, but methods that start with an underscore are the closest equivalent. In the SRW App, the underscore signals that this method is only accessed by the script within which it is called.

After updating the docstrings, developers need to update the corresponding RST files.
To do this successfully, developers must have *sphinx>=7.4.0* installed on their system. To update the RST files, run:

.. code-block:: console

cd ufs-srweather-app/doc/TechDoc
sphinx-apidoc -fM --remove-old -o ./ush ../../ush
sphinx-apidoc -fM --remove-old -o ./tests/WE2E ../../tests/WE2E

.. note::

Developers who do not have *sphinx>=7.4.0* installed may issue the following commands from ``ufs-srweather-app/doc/TechDoc`` before running the sphinx-apidoc commands above:

.. code-block:: console

rm -rf ush
rm -rf tests/WE2E

This will delete current RST files before recreating them with the ``sphinx-apidoc`` command based on the current contents of ``ush`` and ``tests/WE2E``. This step is necessary because the ``--remove-old`` flag does not work with earlier versions of sphinx.
2 changes: 1 addition & 1 deletion doc/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Makefile for Sphinx documentation

SPHINXOPTS = -a -n #-W
SPHINXOPTS = -a -n -W
SPHINXBUILD = sphinx-build
SOURCEDIR = .
BUILDDIR = build
Expand Down
3 changes: 2 additions & 1 deletion doc/UsersGuide/BuildingRunningTesting/VXCases.rst
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,8 @@ Point STAT Files

The Point-Stat files contain continuous variables like temperature, pressure, and wind speed. A description of the Point-Stat file can be found :ref:`here <met:point-stat>` in the MET documentation.

The Point-Stat files contain a potentially overwhelming amount of information. Therefore, it is recommended that users focus on the CNT MET test, which contains the `RMSE <https://metplus.readthedocs.io/projects/met/en/latest/Users_Guide/appendixC.html#root-mean-squared-error-rmse>`_ and `MBIAS <https://metplus.readthedocs.io/projects/met/en/latest/Users_Guide/appendixC.html#multiplicative-bias>`_ statistics. The MET tests are defined in column 24 'LINE_TYPE' of the ``.stat`` file. Look for 'CNT' in this column. Then find column 66-68 for MBIAS and 78-80 for RMSE statistics. A full description of this file can be found :ref:`here <met:point_stat-output>`.
The Point-Stat files contain a potentially overwhelming amount of information. Therefore, it is recommended that users focus on the CNT MET test, which contains the Root Mean Squared Error (`RMSE <https://metplus.readthedocs.io/en/latest/Users_Guide/statistics_list.html#statistics-list-p-r>`_) and Magnitude &
Multiplicative bias (`MBIAS <https://metplus.readthedocs.io/en/latest/Users_Guide/statistics_list.html#statistics-list-g-m>`_) statistics. The MET tests are defined in column 24 'LINE_TYPE' of the ``.stat`` file. Look for 'CNT' in this column. Then find column 66-68 for MBIAS and 78-80 for RMSE statistics. A full description of this file can be found :ref:`here <met:point_stat-output>`.

To narrow down the variable field even further, users can focus on these weather variables:

Expand Down
2 changes: 1 addition & 1 deletion doc/UsersGuide/CustomizingTheWorkflow/DefineWorkflow.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Defining an SRW App Workflow

Many predefined workflows with optional variants exist within the Short-Range Weather Application, but the Application also includes the ability to define a new workflow from scratch. This functionality allows users to add tasks to the workflow to meet their scientific exploration needs.

Rocoto is the primary workflow manager software used by the UFS SRW App. Rocoto workflows are defined in an XML file (``FV3LAM_wflow.xml``) based on parameters set during experiment generation. This section explains how the Rocoto XML is built using a Jinja2 template (`Jinja docs here <https://jinja.palletsprojects.com/en/3.1.x/templates/>`__) and structured YAML files. The YAML follows the requirements in the `Rocoto documentation <http://christopherwharrop.github.io/rocoto/>`__ with a few exceptions or additions outlined in this documentation.
Rocoto is the primary workflow manager software used by the UFS SRW App. Rocoto workflows are defined in an XML file (``FV3LAM_wflow.xml``) based on parameters set during experiment generation. This section explains how the Rocoto XML is built using a Jinja2 template (`Jinja docs here <https://jinja.palletsprojects.com/en/stable/templates>`_) and structured YAML files. The YAML follows the requirements in the `Rocoto documentation <http://christopherwharrop.github.io/rocoto/>`__ with a few exceptions or additions outlined in this documentation.

The Jinja2 Template
===================
Expand Down
10 changes: 1 addition & 9 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,14 @@

nitpick_ignore = [('py:class', 'obj'),('py:class',
'yaml.dumper.Dumper'),('py:class',
'xml.etree.ElementTree'),]
'xml.etree.ElementTree'),('py:class', 'Basemap'),]

# -- General configuration ---------------------------------------------------

# Sphinx extension module names:
extensions = [
'sphinx_rtd_theme',
'sphinx.ext.autodoc',
'sphinxcontrib.autoyaml',
'sphinx.ext.doctest',
'sphinx.ext.intersphinx',
'sphinx.ext.extlinks',
Expand Down Expand Up @@ -310,10 +309,3 @@ def warn_undocumented_members(app, what, name, obj, options, lines):
'uw': ('https://uwtools.readthedocs.io/en/main/%s', '%s'),
}

# -- Options for autoyaml extension ---------------------------------------

autoyaml_root = "../ush"
autoyaml_doc_delimiter = "###" # Character(s) which start a documentation comment.
autoyaml_comment = "#" #Comment start character(s).
autoyaml_level = 6
#autoyaml_safe_loader = False
3 changes: 1 addition & 2 deletions doc/requirements.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
sphinx>=6.0.0
sphinx>=7.4.0
sphinx_rtd_theme
sphinxcontrib-bibtex
sphinxcontrib-autoyaml
9 changes: 2 additions & 7 deletions doc/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# This file is autogenerated by pip-compile with Python 3.11
# by the following command:
#
# pip-compile --strip-extras requirements.in
# pip-compile requirements.in
#
alabaster==0.7.16
# via sphinx
Expand Down Expand Up @@ -42,27 +42,22 @@ pyyaml==6.0.1
# via pybtex
requests==2.32.2
# via sphinx
ruamel-yaml==0.16.13
# via sphinxcontrib-autoyaml
six==1.16.0
# via
# latexcodec
# pybtex
snowballstemmer==2.2.0
# via sphinx
sphinx==7.2.6
sphinx==7.4.7
# via
# -r requirements.in
# sphinx-rtd-theme
# sphinxcontrib-autoyaml
# sphinxcontrib-bibtex
# sphinxcontrib-jquery
sphinx-rtd-theme==2.0.0
# via -r requirements.in
sphinxcontrib-applehelp==1.0.8
# via sphinx
sphinxcontrib-autoyaml==1.1.1
# via -r requirements.in
sphinxcontrib-bibtex==2.6.2
# via -r requirements.in
sphinxcontrib-devhelp==1.0.6
Expand Down
Loading