-
Notifications
You must be signed in to change notification settings - Fork 119
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] Refactor setup.py to remove use of global variables. #505
[develop] Refactor setup.py to remove use of global variables. #505
Conversation
{%- set fmtstr=" %0"~ndigits_ensmem_names~"d" -%} | ||
{{- fmtstr%m -}} | ||
{%- endfor %} </var> | ||
<var name="{{ ensmem_indx_name }}">{% for m in range(1, num_ens_members+1) %}{{ "%03d " % m }}{% endfor %}</var> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Members should be named with a consistent set of zeros so it's predictable from experiment to experiment. I set it to 3 here so that we can support the vast majority of use cases.
@@ -1026,7 +1030,7 @@ model_ver="we2e"" | |||
# | |||
# Set NCO mode OPSROOT | |||
# | |||
OPSROOT=\"${opsroot}\"" | |||
OPSROOT=\"${opsroot:-$OPSROOT}\"" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not use the default when the user does not provide a value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not related to this particular change, but have you tested that specifying OPSROOT from the command line still works. That and 5 other root directories are passed through the environment on WCOSS2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@danielabdi-noaa Thanks for bringing that to my attention. I did not notice that was a thing, and have most definitely messed it up.
I will look into that mechanism a bit more. Just to clarify, those env variables are passed at configuration time?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, they are available during worklfow generation and will override any config settings for OPSROOT, COMROOT etc.
DIAG_TABLE_TMPL_FN: diag_table | ||
FIELD_TABLE_TMPL_FN: field_table | ||
DIAG_TABLE_TMPL_FN: diag_table.FV3_GFS_v15p2 | ||
FIELD_TABLE_TMPL_FN: field_table.FV3_GFS_v15p2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The setup.py script no longer does this for us, so we need to specify it here in full.
METPLUS_CONF: '{{ [PARMdir, "metplus"]|path_join }}' | ||
MET_CONFIG: '{{ [PARMdir, "met"]|path_join }}' | ||
UFS_WTHR_MDL_DIR: '{{ user.UFS_WTHR_MDL_DIR }}' | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The added ability to use Jinja2 templates in the config decouples the setup.py script from the configuration for simple substitutions, path joining, math, etc. I think it also improves general readability and usability, too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I love that config files have templating option!
WRTCMP_write_groups: 1 | ||
WRTCMP_write_tasks_per_group: 20 | ||
WRTCMP_write_groups: "" | ||
WRTCMP_write_tasks_per_group: "" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we set these values here, and also provide LAYOUT_X and LAYOUT_Y from the user config, PE_MEMBER01 is computed before it should be. I thought it would be relevant to treat them just as all the other WRTCMP variables below.
params_dict["LAYOUT_Y"] = LAYOUT_Y | ||
if BLOCKSIZE is not None: | ||
params_dict["BLOCKSIZE"] = BLOCKSIZE | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Handled in setup.py
RUN_TASK_MAKE_GRID = True | ||
RUN_TASK_MAKE_OROG = True | ||
RUN_TASK_MAKE_SFC_CLIMO = True | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic for this has moved up to line 444, and has also been changed to raise an exception to tell the user that there's no way to get the files, instead of assuming this is what should be done.
"NY": NY, | ||
"NHW": NHW, | ||
"STRETCH_FAC": STRETCH_FAC, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This use case should never be realized. If it is, there should be an error. That logic is now near line 602.
# | ||
# ----------------------------------------------------------------------- | ||
# | ||
settings = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All of these were set in the expt_config already.
for sect, sect_keys in expt_config.items(): | ||
for k, v in sect_keys.items(): | ||
expt_config[sect][k] = str_to_list(v) | ||
extend_yaml(expt_config) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After all the validation and value-updating, iterate through filling any remaining jinja templates that may exist in the configuration.
@christinaholtNOAA This is great work! Especially, I like the jinja templating of config files which should bring a lot of power and flexibility to how we setup config files. |
Remove print statements from extend_yaml.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@christinaholtNOAA Thanks for addressing my suggestions! Looks good to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor merge issues.
Okay, I was able to successfully complete all the fundamental tests on Hera yesterday after my changes and do not expect that this morning's changes will make a difference. I can kick off the jet tests to see where this PR stands. |
@christinaholtNOAA Great to hear! Please try to run them on Jet, however, I think that Jet might be going down shortly for maintenance. |
Machine: hera |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@christinaholtNOAA I have manually submitted the fundamental tests manually on Hera and Cheyenne. All tests have successfully ran on these machines (no fatal errors were encountered). My concerns have also been addressed, so I will now approve this work. The Jenkins tests will be submitted first thing tomorrow morning, once Jet is back and (hopefully) the Gaea queue has been cleared.
Machine: jet |
@christinaholtNOAA While running the standard 9 fundamental tests on Gaea, I encountered a new fatal error -
I ran a test using develop and the test was submitted without issue. Please take a look at what might be happening here. Thanks! |
Additional details on the Gaea fatal error: The file in question should be:
I'm not sure why it is looking for Is this due to the following warning message seen?
|
I have definitely found room for improvement in terms of logging messages as I try to debug this one. I am seeing that there is a bit of a gap in the gaea machine file. It does not specify I will update the logic to match this behavior, but does it make sense to set these three in the test script and NOT set |
Change logic for handling grid_dir, etc. when specified separate from pregen_basedir.
@christinaholtNOAA I'm certainly open to this, but since the machine files are still necessary, and the locations for the |
Since I don't have Gaea access today, I tested this test again on hera, but without the |
@MichaelLueken I'm sorry, my suggestion/question wasn't clear! I definitely think we need to keep the machine files. I also think it's important to have all the machine files that have staged data include full information about that data. For example, as it currently stands, a user running on Gaea could not run their own NCO configuration easily without setting either I think that there are 2 ways to approach it (both could be applied):
One down-side...had those two things been done, we wouldn't have had a test that caught that I got rid of the logic for using a user-specified |
@christinaholtNOAA Ah, I see. I agree, adding Also, I have successfully submitted the nco test on gaea and it is has successfully passed. No more fatal errors! I'll go ahead and remove the DO_NOT_MERGE label now. I'm done for the day, so you can go ahead and merge this work if you are ready. Thanks again for working with me through the issues! |
@MichaelLueken I'll open a 2nd PR for gaea. I'll go ahead and merge this one now. |
DESCRIPTION OF CHANGES:
Global variable use has been removed in
setup.py
, and reduced ingenerate_FV3LAM_wflow.py
. The use of globals is a carry-over from the bash era of this utility, and does not meet modern coding standards.This work is one of the preparation steps for providing dictionary configuration objects to an XML generator (still to come).
I will leave a review of the changes made here shortly after I open the PR.
Type of change
TESTS CONDUCTED:
DEPENDENCIES:
None
CHECKLIST
LABELS (optional):
A Code Manager needs to add the following labels to this PR: