arbiter-server 0.9.1.dev1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,36 @@
1
+ from __future__ import annotations
2
+
3
+ from importlib.metadata import entry_points
4
+ import logging
5
+ from typing import cast
6
+
7
+ from ..services import (
8
+ SERVICE_PLUGIN_ENTRY_POINT_GROUP,
9
+ ServicePlugin,
10
+ ServicePluginFactory,
11
+ validate_service_plugin_compatibility,
12
+ )
13
+
14
+
15
+ LOGGER = logging.getLogger(__name__)
16
+
17
+
18
+ def discover_service_plugins(
19
+ group: str = SERVICE_PLUGIN_ENTRY_POINT_GROUP,
20
+ ) -> list[ServicePlugin]:
21
+ discovered: list[ServicePlugin] = []
22
+ for entry_point in entry_points().select(group=group):
23
+ try:
24
+ plugin_factory = cast(ServicePluginFactory, entry_point.load())
25
+ except ModuleNotFoundError as exc:
26
+ LOGGER.warning(
27
+ "Skipping unavailable service plugin entry point %s=%s: %s",
28
+ entry_point.name,
29
+ entry_point.value,
30
+ exc,
31
+ )
32
+ continue
33
+ service_plugin = plugin_factory()
34
+ validate_service_plugin_compatibility(service_plugin)
35
+ discovered.append(service_plugin)
36
+ return sorted(discovered, key=lambda plugin: plugin.name)
@@ -0,0 +1 @@
1
+