use Importlib.resources instead of (deprecated and slower) pkg resources.resource_filename #2157
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 is a cleanup PR which should fix #2018. It touches a lot of files but the changes are relatively minimal.
Note that a few modules imported
pkg_resources.resource_filename
but didn't actually use it, so I removed that import entirely. Also, I replacedpkg_resources.resource_exists()
withimportlib.resources.files('desispec').joinpath('desired_file_in_desispec').is_file()
, as recommended here.To find the impacted files, I did:
and then I also checked all the executable scripts in
desispec/bin/
.Hopefully I'm not missing any files but those can be cleaned up as needed in future PRs; this PR gets most of them (for
desispec
at least).Finally, I ran
pytest
at NERSC and I think everything passed, but I'm not sure how to interpret "2 xfailed" in the log, below (if this is something I introduced or if it's a known issue):