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

Fix pkg resource deprecation waring #1558

Merged
merged 3 commits into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions datacube/drivers/driver_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,9 @@ def load_drivers(group: str) -> Dict[str, Any]:
"""

def safe_load(ep):
from pkg_resources import DistributionNotFound
# pylint: disable=broad-except,bare-except
try:
driver_init = ep.load()
except DistributionNotFound:
# This happens when entry points were marked with extra features,
# but extra feature were not requested for installation
return None
except Exception as e:
_LOG.warning('Failed to resolve driver %s::%s', group, ep.name)
_LOG.warning('Error was: %s', repr(e))
Expand All @@ -51,8 +46,8 @@ def safe_load(ep):
return driver

def resolve_all(group: str) -> Iterable[Tuple[str, Any]]:
from pkg_resources import iter_entry_points
for ep in iter_entry_points(group=group, name=None):
from importlib_metadata import entry_points
for ep in entry_points(group=group):
driver = safe_load(ep)
if driver is not None:
yield (ep.name, driver)
Expand Down
1 change: 1 addition & 0 deletions docs/about/whats_new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ v1.9.next
- Index driver API type hint cleanup. (:pull:`1541`)
- Deprecate multiple locations. (:pull:`1546`)
- Deprecate search_eager and search_summaries and add `archived` arg to all dataset search/count methods. (:pull:`1550`)
- Migrate away from deprecated Python pkg_resources module (:pull:`1558`)


v1.8.next
Expand Down
Loading