Switch from pkg_resources (deprecated) to importlib - #1332
Merged
Conversation
A generic `except Exception:` clause is almost never a good idea.
Contributor
Author
|
@lee1043, this is also ready for review. Less critical for E3SM-Unified but a good idea to take care of any deprecation warnings before they start breaking things. |
|
For reference, this relates to the observations at E3SM-Project/zppy-interfaces#25 (comment) |
lee1043
self-requested a review
October 13, 2025 17:30
Contributor
|
@xylar thank you for the PR! Confirmed that
Also, the Demo 1b mean climate notebook that include |
lee1043
approved these changes
Oct 13, 2025
Contributor
Author
|
Thanks @lee1043! |
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.

This pull request updates the way package resources are located in the
pcmdi_metricspackage by replacing the deprecatedpkg_resourceswithimportlib.metadata. The changes affect both the resource location logic and related tests, ensuring compatibility with modern Python packaging practices.Migration from
pkg_resourcestoimportlib.metadata:pcmdi_metrics/resources.pyto useimportlib.metadatainstead ofpkg_resourcesfor locating package data files, specifically replacingpkg_resources.resource_filenamewithmetadata.distribution(...).locate_file(...). [1] [2]Test updates for new resource location logic:
tests/test_resources.pyto mockimportlib.metadata.distributioninstead ofpkg_resources.resource_filenameandpkg_resources.Requirement.parse, including the use of a dummy distribution object for resource location. [1] [2]