Skip to content

Commit

Permalink
Add generic run script for testing changes at runtime (#285)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomvothecoder authored Nov 11, 2024
1 parent 7321be0 commit 296f54f
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
2 changes: 2 additions & 0 deletions docs/source/development-guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ Python Execution
# `main()` creates an `E3SMtoCMIP` object and passes `args` to it, which sets the object parameters to execute a run.
main(args)
Note, a run script is provided at `/tests/run_script.py` to test changes at runtime.

Example 2 (info mode)
~~~~~~~~~~~~~~~~~~~~~

Expand Down
43 changes: 43 additions & 0 deletions tests/run_script.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
"""A generic run script for testing changes to `e3sm_to_cmip` at runtime.
This script is useful for testing code changes to `e3sm_to_cmip` without having
to install the package. It imports the `main` function from the `__main__`
module and passes a list of arguments to it. The arguments are the same as those
passed to the command line interface (CLI) of `e3sm_to_cmip`.
The script can be run from the command line or an IDE.
NOTE: This script can only be executed on LCRC machines.
"""

import datetime

from e3sm_to_cmip.__main__ import main

# The list of variables to process. Update as needed.
VAR_LIST = (
"pfull, phalf, tas, ts, psl, ps, sfcWind, huss, pr, prc, prsn, evspsbl, tauu, "
"tauv, hfls, clt, rlds, rlus, rsds, rsus, hfss, cl, clw, cli, clivi, clwvi, prw, "
"rldscs, rlut, rlutcs, rsdt, rsuscs, rsut, rsutcs, rtmt, abs550aer, od550aer "
"rsdscs, hur"
)

# The output path for CMORized datasets. Update as needed.
OUTPUT_PATH = f"../qa/run_{datetime.datetime.now().strftime('%Y%m%d_%H%M%S')}"

args = [
"--var-list",
f"{VAR_LIST}",
"--input",
"/lcrc/group/e3sm/e3sm_to_cmip/test-cases/atm-unified-eam/input-regridded",
"--output",
f"{OUTPUT_PATH}",
"--tables-path",
"/lcrc/group/e3sm/e3sm_to_cmip/cmip6-cmor-tables/Tables/",
"--user-metadata",
"/lcrc/group/e3sm/e3sm_to_cmip/CMIP6-Metadata/template.json",
"--serial",
]

# `main()` creates an `E3SMtoCMIP` object and passes `args` to it, which sets
# the object parameters to execute a run.
main(args)

0 comments on commit 296f54f

Please sign in to comment.