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

DM-38812: Prefer using importlib.metadata rather than __version__ #156

Merged
merged 2 commits into from May 2, 2023

Conversation

timj
Copy link
Member

@timj timj commented Apr 21, 2023

For example jsonschema has decided to no longer support __version__ and wants to use importlib.metadata.

The downside of this is that importlib.metadata is much slower than asking for the __version__ of a module that's already imported. Hundreds of milliseconds vs microseconds to get the package versions and importlib.metadata does not seem to cache the result.

Checklist

  • ran Jenkins
  • added a release note for user-visible changes to doc/changes

@codecov
Copy link

codecov bot commented Apr 21, 2023

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (a6d09d5) 93.79% compared to head (ca39a01) 93.80%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #156   +/-   ##
=======================================
  Coverage   93.79%   93.80%           
=======================================
  Files          43       43           
  Lines        2772     2775    +3     
=======================================
+ Hits         2600     2603    +3     
  Misses        172      172           
Impacted Files Coverage Δ
python/lsst/utils/packages.py 88.26% <100.00%> (+0.19%) ⬆️

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Contributor

@ktlim ktlim left a comment

Choose a reason for hiding this comment

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

The code itself looks fine, but I do worry a bit about performance (see ticket).

timj added 2 commits May 1, 2023 15:17
For example jsonschema has decided to no longer support __version__
and wants to use importlib.metadata.

The downside of this is that importlib.metadata is much slower
than asking for the __version__ of a module that's already
imported. Hundreds of milliseconds vs microseconds to get the
package versions and importlib.metadata does not seem to
cache the result.
@timj timj merged commit a34f01d into main May 2, 2023
13 checks passed
@timj timj deleted the tickets/DM-38812 branch May 2, 2023 04:46
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.

None yet

2 participants