Skip to content

Replacing pkg_resource with importlib.resources#474

Open
ayushjariyal wants to merge 18 commits into
aiidalab:mainfrom
ayushjariyal:issue_432
Open

Replacing pkg_resource with importlib.resources#474
ayushjariyal wants to merge 18 commits into
aiidalab:mainfrom
ayushjariyal:issue_432

Conversation

@ayushjariyal

@ayushjariyal ayushjariyal commented Apr 26, 2025

Copy link
Copy Markdown
Contributor

Closes #432

@codecov

codecov Bot commented Apr 26, 2025

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 72.66%. Comparing base (40ad37c) to head (0961ce9).
⚠️ Report is 5 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #474      +/-   ##
==========================================
- Coverage   72.72%   72.66%   -0.06%     
==========================================
  Files          18       18              
  Lines        1672     1672              
==========================================
- Hits         1216     1215       -1     
- Misses        456      457       +1     
Flag Coverage Δ
py-3.12 72.66% <100.00%> (-0.06%) ⬇️
py-3.9 72.66% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

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

@ayushjariyal

Copy link
Copy Markdown
Contributor Author

@danielhollas, can you please review these changes. I am not able to understand that why these tests are failing.

Comment thread aiidalab/registry/core.py Outdated
@danielhollas danielhollas changed the title Replacing pkg_resource with importlib Replacing pkg_resource with importlib.resources Apr 27, 2025

@danielhollas danielhollas left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@ayushjariyal great, tests are passing now!

Let's remove the last vestiges of pkg_resources in aiidalab/registry/web.py as part of this PR.

@ayushjariyal ayushjariyal force-pushed the issue_432 branch 2 times, most recently from b1e24e9 to ba42a15 Compare April 28, 2025 11:20
@ayushjariyal

Copy link
Copy Markdown
Contributor Author

@danielhollas , Done!

@danielhollas danielhollas left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nice, thanks you!

I'll try to add a new test before merging this since the aiidalab.registry package is tested rather sparsely.

Comment thread aiidalab/registry/web.py

def _walk_pkg_resources(package, root):
paths = pkg_resources.resource_listdir(package, root)
for path in paths:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Huh, it looks like you actually fixed a bug here where we would iterate over some directories twice before?
I'll verify a bit more, but the new implementation looks correct. I'll try to add a regression test for this.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

When writing a unit test for this, I would recommend printing paths here and comparing the old and new versions, they are not the same! (although the new one seems more correct as it doesn't duplicate the paths).

@danielhollas danielhollas left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hi @ayushjariyal,

apologies I did not get to this due to other work. If you'd like to push this forward, we'd need a bit more testing to ensure correctness of these changes, since the current testing of this code is very crude.

At the very least, we need unit tests for copy_static_tree_from_package and _walk_pkg_resources.

This was referenced Feb 12, 2026
@danielhollas danielhollas self-requested a review May 29, 2026 06:13
@edan-bainglass

Copy link
Copy Markdown
Member

Hi @ayushjariyal. Do you still plan to finalize this one? Great if we can merge it soon 🙂

@ayushjariyal

Copy link
Copy Markdown
Contributor Author

Hi @edan-bainglass, thanks for checking in! I'm still interested in getting this merged.

I haven't been actively following the project recently, so I'm not very familiar with the latest changes in the codebase. If the PR looks good from your side and can be merged as is, that would be great. Otherwise, let me know what's needed and I'll take a look.

Thanks!

@edan-bainglass

Copy link
Copy Markdown
Member

Hi @edan-bainglass, thanks for checking in! I'm still interested in getting this merged.

I haven't been actively following the project recently, so I'm not very familiar with the latest changes in the codebase. If the PR looks good from your side and can be merged as is, that would be great. Otherwise, let me know what's needed and I'll take a look.

Thanks!

Thanks @ayushjariyal. You can refer to the last few comments in this PR for the remaining requirements. @danielhollas can provide further info if needed 🙂

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.

Replace pkg_resource with importlib

3 participants