Implement keyword argument support in METdbLoad.ush.met_db_load.main and allow calling the function from other Python modules#386
Draft
joelheaps wants to merge 6 commits intodtcenter:developfrom
Conversation
accordingly Includes a fix for an erroneous reference to 'self.logger' when printing an exception.
METdbLoad.met_db_load.main
METdbLoad.met_db_load.mainMETdbLoad.met_db_load.main and allow calling the function from other Python modules
METdbLoad.met_db_load.main and allow calling the function from other Python modules
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Per #385, we have a use case for METdbLoad that involves installing METdataio as a package, importing
METdbLoad.ush.met_db_load.mainand calling it from our own Python module. However, we had a couple issues when we tried to do that; I won't rehash them here, but essentially this PR attempts to address most of them:met_db_load.mainto accept standard keyword arguments, retaining the defaults that argparse currently uses.met_db_load.print_versionto useimportlib.metadatato lookup themetdataiopackage version.selfin the logger call in question. Also instantiatesloggeras it's not always instantiated when an exception is caught. (I'm not 100% happy with the fix, but maybe it'll inspire someone else. Current implementation won't respect the configuredloglevel, for instance.)netcdf4andmetcalcpytorequirements.txtmet_db_load.mainmet_db_load.mainto use a more descriptive name (met_db_load.load_met_data).Pull Request Testing
Describe testing already performed for these changes:
Ran existing test suite using
python -m pytest, with a local SQL database running under Docker.Recommend testing for the reviewer(s) to perform, including the location of input datasets, and any additional instructions:
This shouldn't change any external behavior when calling
met_db_load.py, but if their are test suites in other DTCenter applications that import and call met_db_load functions directly, they may need edits now.Do these changes include sufficient documentation updates, ensuring that no errors or warnings exist in the build of the documentation? [Yes or No]
WIP
Do these changes include sufficient testing updates? [Yes or No]
Yes. Tests were adapted to use keyword arguments to call
main()load_met_data()Will this PR result in changes to the test suite? [Yes or No]
If yes, describe the new output and/or changes to the existing output:
Yes, although no significant changes. (No new tests, only argument changes in existing method calls.)
Do these changes introduce new SonarQube findings? [Yes or No]
If yes, please describe:
Unsure. Will edit once I figure out how to check.
Please complete this pull request review by [Fill in date].
None requested.
Pull Request Checklist
See the METplus Workflow for details.
Select: Reviewer(s) and Development issue
Select: Milestone as the version that will include these changes
Select: Coordinated METplus-X.Y Support project for bugfix releases or METdataio-X.Y.Z Development project for official releases