Skip to content

Conversation

@joelheaps
Copy link

@joelheaps joelheaps commented Jun 22, 2025

Per #385, we have a use case for METdbLoad that involves installing METdataio as a package, importing METdbLoad.ush.met_db_load.main and 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:

  • Modifies met_db_load.main to accept standard keyword arguments, retaining the defaults that argparse currently uses.
  • Modifies met_db_load.print_version to use importlib.metadata to lookup the metdataio package version.
  • Removes self in the logger call in question. Also instantiates logger as 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 configured loglevel, for instance.)
  • Adds netcdf4 and metcalcpy to requirements.txt
  • Updates tests to use keyword arguments when calling met_db_load.main
  • Lastly, renames met_db_load.main to 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.

  • Add any new Python packages to the METplus Components Python Requirements table.
  • Review the source issue metadata (required labels, projects, and milestone).
  • Complete the PR definition above.
  • Ensure the PR title matches the feature or bugfix branch name.
  • Define the PR metadata, as permissions allow.
    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
  • After submitting the PR, select the ⚙️ icon in the Development section of the right hand sidebar. Search for the issue that this PR will close and select it, if it is not already selected.
  • After the PR is approved, merge your changes. If permissions do not allow this, request that the reviewer do the merge.
  • Close the linked issue and delete your feature or bugfix branch from GitHub.

@joelheaps joelheaps changed the title Feature 385 call met db load with args Implement keyword argument support in METdbLoad.met_db_load.main Jun 22, 2025
@joelheaps joelheaps changed the title Implement keyword argument support in METdbLoad.met_db_load.main Implement keyword argument support in METdbLoad.met_db_load.main and allow calling the function from other Python modules Jun 22, 2025
@joelheaps joelheaps changed the title Implement keyword argument support in METdbLoad.met_db_load.main and allow calling the function from other Python modules Implement keyword argument support in METdbLoad.met_db_load.main and allow calling the function from other Python modules Jun 22, 2025
@joelheaps joelheaps changed the title Implement keyword argument support in METdbLoad.met_db_load.main and allow calling the function from other Python modules Implement keyword argument support in METdbLoad.ush.met_db_load.main and allow calling the function from other Python modules Jun 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant