Skip to content

Commit

Permalink
Replace pkg_resource with importlib.metadata
Browse files Browse the repository at this point in the history
Fixes #256
  • Loading branch information
ndevenish committed Aug 28, 2024
1 parent 7d0ce05 commit 2469a67
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 12 deletions.
6 changes: 2 additions & 4 deletions src/zocalo/cli/wrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
import logging
import signal
import sys
from importlib.metadata import entry_points

import pkg_resources
import workflows.recipe.wrapper
import workflows.services.common_service
import workflows.transport
Expand Down Expand Up @@ -40,9 +40,7 @@ def run():
zc = zocalo.configuration.from_file()
zc.activate()

known_wrappers = {
e.name: e.load for e in pkg_resources.iter_entry_points("zocalo.wrappers")
}
known_wrappers = {e.name: e.load for e in entry_points(group="zocalo.wrappers")}

# Set up parser
parser = argparse.ArgumentParser(usage="zocalo.wrap [options]")
Expand Down
4 changes: 2 additions & 2 deletions src/zocalo/configuration/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
import os
import pathlib
import typing
from importlib.metadata import entry_points

import marshmallow as mm
import pkg_resources
import yaml

import zocalo.configuration.argparse
Expand Down Expand Up @@ -56,7 +56,7 @@ def _check_valid_plugin_name(name: str) -> bool:

_configuration_plugins = {
e.name: e
for e in pkg_resources.iter_entry_points("zocalo.configuration.plugins")
for e in entry_points(group="zocalo.configuration.plugins")
if _check_valid_plugin_name(e.name)
}

Expand Down
10 changes: 4 additions & 6 deletions src/zocalo/service/dispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import time
import timeit
import uuid
from importlib.metadata import entry_points

import pkg_resources
import workflows.recipe
from workflows.services.common_service import CommonService

Expand Down Expand Up @@ -110,9 +110,7 @@ def initializing(self):
self.message_filters = {
**{
f.name: f.load()
for f in pkg_resources.iter_entry_points(
"zocalo.services.dispatcher.filters"
)
for f in entry_points(group="zocalo.services.dispatcher.filters")
},
"load_custom_recipe": self.filter_load_custom_recipe,
"load_recipes_from_files": self.filter_load_recipes_from_files,
Expand All @@ -121,8 +119,8 @@ def initializing(self):

self.ready_for_processing = {
f.name: f.load()
for f in pkg_resources.iter_entry_points(
"zocalo.services.dispatcher.ready_for_processing"
for f in entry_points(
group="zocalo.services.dispatcher.ready_for_processing"
)
}

Expand Down

0 comments on commit 2469a67

Please sign in to comment.