Repository navigation
fix(python): resolve submodule paths and support nested CESM checkouts (resolves #2658, #3552) - #4207
Conversation
f2b43d2 to
7e24a94
Compare
e3a8344 to
85aafae
Compare
85aafae to
211a991
Compare
|
This seems like a helpful contribution, thanks @johnpaulalex. @slevis-lmwg will you work with @johnpaulalex to merge this? |
|
@mvdebolskiy commented that the changes needed here already exist as functions or routines in CIME's python tools. Matvey,
|
|
@slevis-lmwg nvm. I thought you can grab xml variables from cime itself, but you can't. There are bootstrap routines in cime itself to figure out where it is and set |
|
Testing on derecho shows failures, so I will bounce this PR back to you @johnpaulalex. OK FAIL
FAIL I suggest troubleshooting this last list of failures after you fix the six ctsm_py_tests failures above. I hope that fixing the ctsm_py_tests failures will resolve the last failure listed here. When you're ready to replicate this work, |
|
Hey @slevis-lmwg , I think those failures are orthogonal to this PR. but maybe needs its own PR? And there are layers and layers to the system tests issues, please bear with me. Apparently the python failure occurred because your derecho worktree didn't have tags fetched:
The latter error is what you saw per I wasn't aware tag-fetching was even a thing but AI says "When people create personal forks, or checkouts/worktrees with selective refspecs, git often skips tag propagation unless --tags is explicitly fetched." I got the same error on my derecho worktree (apparently because it, like your git_people/ subdir, was cloned from my github fork, which itself has no tags). But then running
made it all work. Two angles:
For the system tests:
In a full CESM checkout, libraries/FTorch exists at the CESM root, but in a standalone CTSM checkout, it is not present in .gitmodules." Looks like ftorch was briefly added to CTSM but then removed in #3214. Should I worry about this? I get the impression things are in flux with FTorch, I've been working on #3228 to help bring it in). But to make this test go, I could hack my CTSM to have that library; or I could turn off USE_FTORCH in that test case I think...
It is a roundoff difference in the 16th decimal place at machine precision (~1e-16). " (and ndep2 was the same) AI further asserts - please forgive its hyperbole, and I'm not sure it's right, but thinking you might know off-the-bat:"
Both NLCOMP and BASELINE ctsm5.4.058 PASSED completely!
Because he tested with stale, un-updated submodules from an older tree: His old cmeps1.1.47 wrote the old nuopc.runconfig (MED_model: cmeps instead of cesm), failing NLCOMP. So: I could hack up ftorch and rerun the suite, just to verify the above is true...but there's one more systemic issue that I've been meaning to ask someone about - I can't access the baseline files on derecho: "The baseline directory on Glade is owned by the NCAR internal group cgdtss with 750 permissions (drwxr-s---+): Your account (jpalex) is in group ncar / p93300041, but not cgdtss, so ls or reading the baseline files directly gives Permission denied." Ok. That's a lot. happy to chat offline if that helps. |
|
@johnpaulalex thank you, and I'm sorry.
The news seems good so far:
|
|
From my CESM checkout, Here's what I did so far: @johnpaulalex have you tested your PR in a CESM checkout? |
If git isn't going to check out a submodule, it still creates the submodule directory (apparently to reserve it, in case you check it out later). So we can't simply check for existence of a subdir to verify submodule, we need to look for files in it. Added unit test coverage in test_unit_path_utils.py.
- lilac_make_runtime_inputs was missing the add_cime_to_path that all the other scripts already have, to find CIME. - subset_data: resolve user_nl_clm from CTSM root and user_nl_datm_streams from enclosing CESM root (if present) in setup_user_mods(). Added unit tests too.
…CESM layouts Help two tests work in CESM as well as CTSM: - test_unit_sspmatrix.py is the sole caller of path_utils' add_ctsm_systests_to_path(), to find cime_config (within CTSM). Fixed that method to find CTSM in either scenario. - test_sys_lilac_build_ctsm: needs to find CIME, now calls add_cime_lib_to_path
…from any directory The short config modify_fsurdat_short.cfg points to a checked-in .nc file via a relative path, relative to CTSM/python/. That relative path only resolves correctly when the script is run from that python/ subdir. To fix it, we use the same search-and-replace pattern that the other tests do, to replace the relative path with an absolute path.
|
Hey @slevis-lmwg , I did not do manual test runs in a CESM repo. And actually I needed to run the automated tests themselves from both locations because they also had assumptions about where they were running(!). Also TIL that run_ctsm_py_tests exists. So, my bad - sorry about that. I guess I haven’t worked on CESM in a while, plus haven’t worked in this part of the code before - I had a too-low level of paranoia, in retrospect. I updated the PR description to list all the testing I’ve now done. Based on the manual runs, I added 3 more (tiny) commits to fix various things. Various questions:
1a. fwiw I just submitted #4231 which fixes one unit test that checks for a /glade path. (so now I can run all the unit tests on my mac, it's a convenient first pass)
|
|
What's the status on this PR? I can't really follow what next steps are needed here? |
|
Hi @wwieder , my newer commits need a review, and I have a couple of minor questions for the reviewer in my last post. friendly ping to @slevis-lmwg (and apologies for not being as rigorous in the initial testing as I should have been) |
|
Testing in ctsm checkout
Testing in cesm checkout
|
slevis-lmwg
left a comment
There was a problem hiding this comment.
Thank you @johnpaulalex for this PR!
Issues Resolved
ccs_configin standalone CTSM and CESM checkouts.subset_dataand other Python tools fail to resolve top-level CESM root in nested checkouts.Summary of Changes
(sorry github's markdown parsing appears to be buggy below)
32c268eb1refactor(path_utils): Renamedstandalone_onlyparameter toctsm_onlyacrosspath_utils, test suites, andrun_sys_tests.Clearer rename, no-op.
2. **`1f845a87c` `fix(path_utils)`**: Resolved `ccs_config` in standalone CTSM and CESM checkouts, updated `run_tower`, `tower_site`, `gen_mksurfdata_namelist`, and added comprehensive path resolution unit tests (resolves #2658).
3. **`211a991db` `fix(subset_data)`**: Resolved top-level CESM root in `subset_data` and Python tools (resolves #3552).
Added After Review
0fca53217fix(path_utils): Ignore empty submodule dirsIf git isn't going to check out a submodule, it still creates the submodule directory (apparently to reserve it, in case you check it out later). So we can't simply check for existence of a submodule subdir, we need to look for files in it.
5. **`a6ae10439` `fix(python)`**: Update specific scripts to use more path_utils
lilac_make_runtime_inputs.pywas missing theadd_cime_to_paththat all the other scripts already have, to find CIME.subset_data.py: resolve user_nl_clm from CTSM root and user_nl_datm_streams fromenclosing CESM root (if present) in setup_user_mods(). Added unit tests too.
6. **`244e2778c` `test(sys)`**: Use proper paths in script test suites for standalone and CESM layouts
Two tests needed more calls to path_utils
7.
36aec48cctest(fsurdat_modifier): Fix 'short config' test to be able to be run from any directoryThis one is orthogonal to everything else, it just gets all the system tests working again.
Answer Impact
Note
Bit-for-bit (B4B): This pull request contains purely Python infrastructure, path utility, and test harness changes. Zero Fortran or scientific model code was modified. Simulation answers are completely unchanged.
Verification & Test Results
The changes have been tested on derecho in both a standalone CTSM and a CTSM-within-CESM repo:
--lat1 -12 --lat2 -7 --lon1 291 --lon2 299
--create-mesh --create-domain --create-surface
--surf-year 2000 --create-user-mods
--outdir /tmp/subset_out --user-mods-dir /tmp/subset_usermods
--inputdata-dir python
--cfg-file python/ctsm/test/testinputs/subset_data_amazon.cfg
--overwrite --reg TMP
--neon-sites ABBY
--setup-only
--output-root /tmp/tower_out
--check-only
--testlist-file cime_config/testdefs/testlist_clm.xml
(The run_ctsm_py_tests -s system test pattern was to avoid the pre-existing CIME test breakage that's now fixed in ESMCI/cime#5067).
The repo dirs on derecho were:
/glade/work/jpalex/src/CTSM/worktree_issue2658/glade/work/jpalex/src/cesm/components/clmAI Disclosure
Used Antigravity 2.0.
Requirements before merge: