Skip to content
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

Address pkg_resources deprecation warnings #1249

Merged
merged 3 commits into from
Sep 21, 2023

Conversation

victorlin
Copy link
Member

@victorlin victorlin commented Jun 30, 2023

Description of proposed changes

Previously, some warnings were visible upon running pytest.

Related issue(s)

N/A, I came across this while looking at CI logs.

Testing

  • Checks pass
  • Warnings no longer appear in CI logs (all but devel/release are covered by tests)
  • The next release is successful

Checklist

  • Add a message in CHANGES.md summarizing the changes in this PR that are end user focused. Keep headers and formatting consistent with the rest of the file. N/A, no functional changes

@victorlin victorlin requested a review from a team June 30, 2023 22:02
@victorlin victorlin self-assigned this Jun 30, 2023
@codecov
Copy link

codecov bot commented Jun 30, 2023

Codecov Report

Patch coverage is 100.00% of modified lines.

Files Changed Coverage
augur/data/__init__.py 100.00%
augur/util_support/color_parser.py 100.00%
augur/utils.py 100.00%
augur/validate.py 100.00%

📢 Thoughts on this report? Let us know!.

@tsibley
Copy link
Member

tsibley commented Jul 5, 2023

(from my comment in Slack)

The package resources stuff is a mess currently in Python. There's been a lot of churn.

One downside to the solution here is that the file is completely loaded into memory at least three times (pkgutil, StringIO, our eventual parsing of it). Using the newest importlib.resources API (and importlib_resources backport) is not much code and can avoid the downside above. Nextstrain CLI does that.

@victorlin victorlin force-pushed the victorlin/replace-pkg_resources branch from 05cbec5 to 32af1e8 Compare July 11, 2023 00:23
augur/data/__init__.py Outdated Show resolved Hide resolved
augur/data/__init__.py Outdated Show resolved Hide resolved
augur/validate.py Outdated Show resolved Hide resolved
Copy link
Member

@corneliusroemer corneliusroemer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great to address this, have been noticing the deprecation warnings as well

@victorlin victorlin force-pushed the victorlin/replace-pkg_resources branch from 32af1e8 to 29950aa Compare September 20, 2023 22:45
There are several alternatives¹. Only one (importlib.resources.as_file +
open) avoids reading the entire file into memory by using a temporary
file on disk.

¹ https://stackoverflow.com/a/58941536
Use an approach similar to the previous commit.
@victorlin victorlin force-pushed the victorlin/replace-pkg_resources branch from 29950aa to 2b58409 Compare September 20, 2023 22:53
@victorlin victorlin requested a review from tsibley September 20, 2023 22:58
@victorlin victorlin merged commit a36d3dd into master Sep 21, 2023
24 checks passed
@victorlin victorlin deleted the victorlin/replace-pkg_resources branch September 21, 2023 22:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

3 participants