-
Notifications
You must be signed in to change notification settings - Fork 64
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
Refactor capgen branch #410
Conversation
Convert framework options to DDT with methods (runtime environment). Convert shebangs to python3 Change ccpp_error_flag to ccpp_error_code Add polymorphic variable property Remove optional variable property Introduct FortranVar to allow Fortran to have undocumented optional variables Cleanup ccpp_error_code usage Fix hang in datatable write plus catch more bad units Split var_props.py from metavar.py to allow independent development Added VarCompatObject to hold compatibility and transform information about a pair of Var objects. This object looks for compatible differences in units, kind, or dimensions. Created unit tests for variable compatibility. Move PrettyElementTree to xml_tools Refactor ccpp_suite to separate out SuiteObjects Created <root>/test/run_tests.sh to run all capgen tests.
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.
(1) Just for my understanding, in the PR description, you say:
Optional keyword removed from metadata. Optional Fortran variables should be omitted from metadata tables
From our previous conversation, my understanding was that optional Fortran variables may be omitted from metadata tables, but they can be present. It's a hardcoded choice which flavor of a scheme to run.
(2) Do you think the improved error handler will be ready before we transition the UFS to capgen
? I am asking because in this case we could "shield" the UFS from the extra step to rename ccpp_error_flag
to ccpp_error_code
and go straight to the new error handler. If not, we'll probably annoy some developers by changing a ton of files (Fortran and metadata, in both ccpp-physics and fv3atm/scm) twice to update the error handling.
(3) I think at least one more Python file needs the Python3 shebang:
index 45e7c14..110a37b
--- a/test/capgen_test/test_reports.py
+++ b/test/capgen_test/test_reports.py
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
"""
-----------------------------------------------------------------------
Description: Test capgen database report python interface
(4) The tests are failing on my mac (with (3) above included:
-- Build files have been written to: /Users/dom.heinzeller/work/ccpp-framework/ccpp-framework-capgen-refactor/test/ct_build
Running python interface tests
Traceback (most recent call last):
File "/Users/dom.heinzeller/work/ccpp-framework/ccpp-framework-capgen-refactor/test/capgen_test/test_reports.py", line 27, in <module>
from ccpp_datafile import datatable_report, DatatableReport
File "/Users/dom.heinzeller/work/ccpp-framework/ccpp-framework-capgen-refactor/scripts/ccpp_datafile.py", line 25, in <module>
from metadata_table import UNKNOWN_PROCESS_TYPE
File "/Users/dom.heinzeller/work/ccpp-framework/ccpp-framework-capgen-refactor/scripts/metadata_table.py", line 133, in <module>
from metavar import Var, VarDictionary, CCPP_CONSTANT_VARS
File "/Users/dom.heinzeller/work/ccpp-framework/ccpp-framework-capgen-refactor/scripts/metavar.py", line 340
context=self.context) from cperr
^
SyntaxError: invalid syntax
ERROR: python interface tests failed
ERROR: Failure running capgen test
(5) In general: This PR is extremely difficult if not impossible to review in a reasonable amount of time. There are many unrelated changes, and a lot of code is moved around (which makes it almost impossible to identify if anything has changed in those parts). I understand that this is to some extend the nature of "refactor" PRs and that breaking changes up takes more time. But it would be easier to review and lead to more robust reviews if, for example, all the "error flag" -> "error code" changes were its own PR, all the single underscore to double underscore changes were its own PR, the run_env
changes were its own PR, ... or combinations of those that are more manageable. I know I am guilty of big PRs myself, especially in the beginnings of CCPP, but I think we should try to be good stewards of GitHub code change practices and create smaller PRs that contain logically related changes but nothing else / not much else otherwise going forward.
(6) There are a few more comments below inline with the code.
def is_horizontal_dimension(cls, dim_name): | ||
"""Return True if it is a recognized horizontal | ||
dimension or index, otherwise, return False | ||
>>> Var.is_horizontal_dimension('horizontal_loop_extent') |
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.
What about testing
Var.is_horizontal_dimension('horizontal_dimension')
for the sake of completeness?
False | ||
>>> Var.is_vertical_dimension('ccpp_constant_one:vertical_interface_index') | ||
False | ||
>>> Var.is_vertical_dimension('horizontal_loop_extent') |
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.
We could also test for those additional vertical dimensions, like
vertical_layer_dimension_for_radiation
vertical_interface_dimension_for_radiation
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.
We have never discussed the semantics of these dimensions. If the CCPP framework is going to internally handle new dimensions, please open an issue where the full semantics of their usage (including any interaction with the standard vertical dimensions) can be discussed and agreed upon.
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, we never discussed this, I just noticed the additional dimension in the standard name dictionary and the UFS. Let's discuss this next week at the framework meeting when you are back, I will create an issue to remind us.
|
||
############################################################################### | ||
# Supported vertical dimensions (should be defined in CCPP_STANDARD_VARS) | ||
CCPP_VERTICAL_DIMENSIONS = ['ccpp_constant_one:vertical_layer_dimension', |
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.
We are missing the "decorated" versions
vertical_interface_dimension_for_radiation
vertical_layer_dimension_for_radiation
(these are defined in CCPP_STANDARD_VARS)
############################################################################### | ||
# Substituions for run time dimension control | ||
CCPP_LOOP_DIM_SUBSTS = {'ccpp_constant_one:horizontal_dimension' : | ||
'horizontal_loop_begin:horizontal_loop_end', |
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.
Do we need to add the _radiation
versions here as well?
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.
See comment above.
>>> is_vertical_dimension('ccpp_constant_one:vertical_layer_index') | ||
False | ||
>>> is_vertical_dimension('ccpp_constant_one:vertical_interface_index') | ||
False |
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.
Could test for _radiation
versions here
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.
See comment above.
@@ -53,9 +53,9 @@ | |||
kind = len=512 | |||
intent = out | |||
[ errflg ] |
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.
We should rename those as well.
[ errflg ] | |
[ errcode ] |
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 do local variable names need to match standard names? This has never been a requirement as far as I recall.
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.
That was just a suggestion for consistency, of course they can be different (and given the comment on the long name errflg
might be just as good).
Oops, bad communication. capgen does work this way, I added a test in capgen_test to verify that an |
I have not prioritized this work because it would delay unification readiness. We need to re-evaluate the schedule if you want to add this. |
Yep, I already found this by testing on a different machine (it turns out that the machine I was using had python ==> python3 so I did not see the problem. Unfortunately, in trying to clean up all this test stuff, I ended up touching a bunch of files so the PR grew. |
I agree with this comment and am happy to try and make shorter PRs. However, if we agree that I will do this, I need to go in and re-estimate all the task hours as a PR does take me a significant amount of time. Your call. |
It's a judgement call, I think we need to be pragmatic. Maybe along the lines "I can split this up easily without spending a lot of time, so let's to it" and "This would be a lot of overhead, let's keep it together". |
I ran the tests with your latest commit bbb668c on my Mac, and all tests passed. |
@gold2718 I am ok with this PR, do you want to make more changes or should I approve and merge? Thanks. |
From my point of view, it is okay to merge if you are comfortable with the current state. I can try to work in future PRs. |
Refactor capgen branch
User interface changes?: Yes
--kind-type
argument replaces--kind-phys
and takes a list of model kinds.Fixes: [Github issue #s]
addresses #329
addresses #378
addresses #403
fixes #408
Testing: