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

Remove deprecated pkg_resources #1119

Merged
merged 2 commits into from
Nov 17, 2023
Merged
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
20 changes: 17 additions & 3 deletions src/orion/core/utils/__init__.py
Original file line number Diff line number Diff line change
@@ -9,14 +9,19 @@
import logging
import os
import signal
import sys
from abc import ABCMeta
from collections import defaultdict
from contextlib import contextmanager
from glob import glob
from importlib import import_module
from tempfile import NamedTemporaryFile

import pkg_resources
if sys.version_info >= (3, 10):
from importlib.metadata import entry_points

Check warning on line 21 in src/orion/core/utils/__init__.py

Codecov / codecov/patch

src/orion/core/utils/__init__.py#L21

Added line #L21 was not covered by tests
else:
from pkg_resources import iter_entry_points


log = logging.getLogger(__name__)

@@ -72,14 +77,23 @@
# base = import_module(cls.__base__.__module__)

# Get types advertised through entry points!
for entry_point in pkg_resources.iter_entry_points(cls.__name__):
entry_point_iterable = (
entry_points(group=cls.__name__) # pylint: disable=unexpected-keyword-arg
if sys.version_info >= (3, 10)
else iter_entry_points(cls.__name__)
)
for entry_point in entry_point_iterable:
entry_point.load()
assert entry_point.dist is not None
log.debug(
"Found a %s %s from distribution: %s=%s",
entry_point.name,
cls.__name__,
entry_point.dist.project_name,
(
entry_point.dist.name
if sys.version_info >= (3, 10)
else entry_point.dist.project_name
),
entry_point.dist.version,
)