-
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
Cleanup, adding unit tests for ccpp_track_variables.py
, activate "chunked data" CI test, add missing MPI target in src/CMakeLists.txt
#555
Conversation
…'t get debug test working so far
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 don't want to hold up this PR but I think docstrings for each test function would add helpful documentation of the tests and logical test coverage.
@@ -70,7 +70,7 @@ def import_config(configfile, builddir): | |||
if not os.path.isfile(configfile): | |||
logging.error("Configuration file {0} not found".format(configfile)) | |||
success = False | |||
return | |||
return(success, 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.
Why the tuple? Doesn't Python do that anyway? Is that a style thing and if so, do we want to be consistent?
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.
@gold2718 Sorry, I'm not sure what you mean. This function as called from main() expects two return values, and so currently when this block of code is executed (when there is no configuration file) it fails with a TypeError because it is not returning the expected values.
> ../scripts/ccpp_track_variables.py -s test_track_variables/suite_small_suite.xml -c test_track_variables/ccpp_prebuild_config -m test_track_variables/ -v air_pressure
ERROR:root:Configuration file test_track_variables/ccpp_prebuild_config not found
Traceback (most recent call last):
File "/glade/derecho/scratch/kavulich/CCPP/track_variables_unit_test/ccpp-framework/test_prebuild/../scripts/ccpp_track_variables.py", line 217, in <module>
track_variables(args.sdf,args.metadata_path,args.config,args.variable,args.debug)
File "/glade/derecho/scratch/kavulich/CCPP/track_variables_unit_test/ccpp-framework/test_prebuild/../scripts/ccpp_track_variables.py", line 191, in track_variables
(success, config) = import_config(config, None)
TypeError: cannot unpack non-iterable NoneType object
This change fixes the error.
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.
Sorry for the lack of clarity. All I was saying is that the parentheses are not needed so I was wondering why you use them. The same goes below where you call this function.
Is this a style thing we want to adopt? A quick look shows that the prebuild code seems to consistently use the parentheses syntax while the capgen code is . . . . mixed (I'm sure for good reasons :).
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.
Thanks for the clarification. I did not realize this until you brought this up, but parentheses are not strictly necessary for tuples, so this would be purely stylistic. Since the existing return tuples use parens I'll stick with that for now, especially since PEP8 doesn't seem to specify a preference from what I can tell.
|
||
(success, config) = import_config(args.config, None) | ||
(success, config) = import_config(config, None) |
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.
You also do not need the tuple to unpack the variables. Same questions as above.
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.
But it doesn't hurt, or? If so, then does it matter?
from ccpp_track_variables import track_variables | ||
|
||
def test_successful_match(capsys): | ||
expected_output = """For suite test_track_variables/suite_small_suite.xml, the following schemes (in order for each group) use the variable air_pressure: |
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.
A doc string explaining the purpose of the test (what is being tested, test limits, etc.) would be helpful here and for all the test functions below.
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.
Agreed
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.
Approving based on the CI tests all passing and the changes requested not absolutely necessary (but it would be nice to have a bit of documentation for the newly added track_variables test).
from ccpp_track_variables import track_variables | ||
|
||
def test_successful_match(capsys): | ||
expected_output = """For suite test_track_variables/suite_small_suite.xml, the following schemes (in order for each group) use the variable air_pressure: |
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.
Agreed
|
||
(success, config) = import_config(args.config, None) | ||
(success, config) = import_config(config, None) |
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.
But it doesn't hurt, or? If so, then does it matter?
@climbfuji @gold2718 I agree we should have some docstrings here before merge, I'll work on that today. |
@climbfuji @gold2718 I have added the requested docstrings, as well as updating the existing file-level docstring and adding a call to |
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 is great, thanks! One typo left to correct.
@@ -43,6 +47,11 @@ def test_successful_match(capsys): | |||
i+=1 | |||
|
|||
def test_successful_match_with_subcycles(capsys): | |||
"""Tests whether test_track_variables.py produces expected output from sample suite and | |||
metadata files for a case with a successful match(user provided a variable that exists |
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.
metadata files for a case with a successful match(user provided a variable that exists | |
metadata files for a case with a successful match (user provided a variable that exists |
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.
Looks great! Just had one minor change in mind that might be useful but please feel free to disregard if it's not ideal.
@climbfuji @mwaxmonsky Thanks for the reviews, I have adopted your suggested changes. |
@mkavulich Can you pull #556 into this so that I can add the latest hash of this branch to NOAA-EMC/fv3atm#816. |
@grantfirl Done |
ccpp_track_variables.py
, activate "chunked data" CI testccpp_track_variables.py
, activate "chunked data" CI test, add missing MPI target in src/CMakeLists.txt
This PR makes several related changes:
ccpp_track_variables.py
script, and run them automatically in CI, as requested in Implement CI for ccpp_track_variables.py #511. In addition, some cleanup changes were made toccpp_track_variables.py
to make implementing the CI test easier.ccpp_prebuild.py
to make theimport_config()
routine fail "correctly" when the config file is not present: previous behavior was an exception due to mismatched return values.User interface changes?: No
Fixes: #511
Testing:
test removed: None
unit tests: Adds
test_track_variables.py
to CI. Also, activatessystem tests: I am not sure what this means 🤷
manual testing: Ran new tests manually with
pytest