amoghrajesh commented on code in PR #59971:
URL: https://github.com/apache/airflow/pull/59971#discussion_r2657894672


##########
airflow-core/src/airflow/utils/entry_points.py:
##########
@@ -14,48 +14,13 @@
 # KIND, either express or implied.  See the License for the
 # specific language governing permissions and limitations
 # under the License.
-from __future__ import annotations
-
-import functools
-import logging
-import sys
-from collections import defaultdict
-from collections.abc import Iterator
-
-if sys.version_info >= (3, 12):
-    from importlib import metadata
-else:
-    import importlib_metadata as metadata
-
-log = logging.getLogger(__name__)
-
-EPnD = tuple[metadata.EntryPoint, metadata.Distribution]
-
+"""Re-export entry_points utilities from shared library for backward 
compatibility."""
 
[email protected]
-def _get_grouped_entry_points() -> dict[str, list[EPnD]]:
-    mapping: dict[str, list[EPnD]] = defaultdict(list)
-    for dist in metadata.distributions():
-        try:
-            for e in dist.entry_points:
-                mapping[e.group].append((e, dist))
-        except Exception as e:
-            log.warning("Error when retrieving package metadata (skipping it): 
%s, %s", dist, e)
-    return mapping
-
-
-def entry_points_with_dist(group: str) -> Iterator[EPnD]:
-    """
-    Retrieve entry points of the given group.
-
-    This is like the ``entry_points()`` function from ``importlib.metadata``,
-    except it also returns the distribution the entry point was loaded from.
-
-    Note that this may return multiple distributions to the same package if 
they
-    are loaded from different ``sys.path`` entries. The caller site should
-    implement appropriate deduplication logic if needed.
+from __future__ import annotations
 
-    :param group: Filter results to only this entrypoint group
-    :return: Generator of (EntryPoint, Distribution) objects for the specified 
groups
-    """
-    return iter(_get_grouped_entry_points()[group])
+from airflow._shared.module_loading.entry_points import (
+    EPnD as EPnD,
+    _get_grouped_entry_points as _get_grouped_entry_points,
+    entry_points_with_dist as entry_points_with_dist,
+    metadata as metadata,
+)

Review Comment:
   Let me just send that one in a follow up



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to