Skip to content

Conversation

@s-t-e-v-e-n-k
Copy link

Since the minimum Python version supported now directly supports querying entry points using the standard library, write a wrapper around to support both upstream APIs, and make use of it, rather than the external entrypoints package.

@codecov
Copy link

codecov bot commented Aug 20, 2024

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.01%. Comparing base (cb2eb37) to head (79733a3).
⚠️ Report is 22 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #792      +/-   ##
==========================================
- Coverage   91.54%   91.01%   -0.54%     
==========================================
  Files          17       17              
  Lines        1621     1636      +15     
==========================================
+ Hits         1484     1489       +5     
- Misses        137      147      +10     
Files with missing lines Coverage Δ
papermill/engines.py 95.78% <100.00%> (-2.59%) ⬇️
papermill/iorw.py 79.30% <100.00%> (-0.07%) ⬇️
papermill/utils.py 95.65% <100.00%> (+0.41%) ⬆️

... and 3 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cff4f8e...79733a3. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Member

@MSeal MSeal left a comment

Choose a reason for hiding this comment

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

The one build failure looks unrelated result of merging master in. I'll take a look later at it to resolve if you don't get it before me. Thanks for posting the improvement!

@s-t-e-v-e-n-k s-t-e-v-e-n-k force-pushed the drop-use-of-entrypoints branch from d100d5f to b41914f Compare August 27, 2024 07:16
@s-t-e-v-e-n-k s-t-e-v-e-n-k force-pushed the drop-use-of-entrypoints branch from b41914f to 30394a4 Compare November 1, 2024 08:15
@s-t-e-v-e-n-k
Copy link
Author

@Borda I've corrected the docstring you've pointed out (sorry it took me so long!)


include .bumpversion.cfg

include papermill/tests/fixtures/foo-0.0.1.dist-info/METADATA
Copy link
Member

Choose a reason for hiding this comment

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

This looks strange to be included, is it testing artifact?

Copy link
Author

Choose a reason for hiding this comment

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

Yes, it's a testing file -- we provide just enough wheel metadata in that path to give us one entry point.

Copy link
Author

Choose a reason for hiding this comment

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

@Borda any opinion on this?

Copy link
Member

Choose a reason for hiding this comment

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

I think that test shall not be distributed, so for testing you can install it with -e so if shall see all local files too

Copy link
Author

Choose a reason for hiding this comment

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

@Borda It literally caused a GitHub Actions failure when I didn't include it, I'll note.

@frenzymadness
Copy link

I'm looking forward to it as it allows me to drop the entrypoints package from Fedora Linux. Is there any plan to merge and release this?

@frenzymadness
Copy link

You might want to remove entrypoints also from the requirements/docs.txt file:

entrypoints

Since the minimum Python version supported now directly supports
querying entry points using the standard library, write a wrapper around
to support both upstream APIs, and make use of it, rather than the
external entrypoints package.
@s-t-e-v-e-n-k s-t-e-v-e-n-k force-pushed the drop-use-of-entrypoints branch from 30394a4 to 762313b Compare December 3, 2024 07:10
@frenzymadness
Copy link

Is there any plan to move this forward please?

@Borda Borda self-requested a review November 13, 2025 21:04
Copilot finished reviewing on behalf of Borda November 13, 2025 21:05
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR migrates from the external entrypoints package to the standard library's importlib.metadata module for querying entry points, as Python 3.8+ (the minimum supported version) includes this functionality natively.

Key changes:

  • Added a compatibility wrapper get_entrypoints_group() to support both Python 3.8/3.9 (dictionary-based API) and Python 3.10+ (select-based API)
  • Removed entrypoints dependency from requirements files
  • Updated all usages of entrypoints.get_group_all() to use the new wrapper function

Reviewed Changes

Copilot reviewed 10 out of 11 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
papermill/utils.py Adds the get_entrypoints_group() wrapper function and imports entry_points from importlib.metadata
papermill/iorw.py Updates to use the new wrapper function and removes entrypoints import
papermill/engines.py Updates to use the new wrapper function and removes entrypoints import
papermill/tests/test_utils.py Adds test coverage for the new wrapper function using test fixtures
papermill/tests/test_iorw.py Updates test mocks to patch entry_points instead of entrypoints.get_group_all
papermill/tests/test_engines.py Updates test mocks to patch entry_points instead of entrypoints.get_group_all
papermill/tests/fixtures/foo-0.0.1.dist-info/entry_points.txt Creates fixture entry points metadata for testing
papermill/tests/fixtures/foo-0.0.1.dist-info/METADATA Creates fixture package metadata for testing
requirements.txt Removes entrypoints dependency
requirements/docs.txt Removes entrypoints dependency
MANIFEST.in Includes the new test fixtures in the distribution

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +69 to +73
# We need to cast to a list here, 3.8/3.9 and 3.10+ return different
# types.
eps = list(get_entrypoints_group("papermill.tests.fake"))
sys.path.pop()
assert eps[0].name == "foo"
Copy link

Copilot AI Nov 13, 2025

Choose a reason for hiding this comment

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

The test modifies sys.path but doesn't properly restore it in case of test failure. If an assertion fails before sys.path.pop(), the modified path will persist. Consider using a try-finally block or a context manager to ensure cleanup:

sys.path.insert(0, Path(__file__).parent / "fixtures")
try:
    eps = list(get_entrypoints_group("papermill.tests.fake"))
    assert eps[0].name == "foo"
finally:
    sys.path.pop(0)
Suggested change
# We need to cast to a list here, 3.8/3.9 and 3.10+ return different
# types.
eps = list(get_entrypoints_group("papermill.tests.fake"))
sys.path.pop()
assert eps[0].name == "foo"
try:
# We need to cast to a list here, 3.8/3.9 and 3.10+ return different
# types.
eps = list(get_entrypoints_group("papermill.tests.fake"))
assert eps[0].name == "foo"
finally:
sys.path.pop(0)

Copilot uses AI. Check for mistakes.
# We need to cast to a list here, 3.8/3.9 and 3.10+ return different
# types.
eps = list(get_entrypoints_group("papermill.tests.fake"))
sys.path.pop()
Copy link

Copilot AI Nov 13, 2025

Choose a reason for hiding this comment

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

The sys.path.pop() call will remove the last element instead of the first element that was inserted. This should be sys.path.pop(0) to properly clean up the modification made by sys.path.insert(0, ...) on line 68.

Suggested change
sys.path.pop()
sys.path.pop(0)

Copilot uses AI. Check for mistakes.
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.

4 participants