From 0739b88a26f23de29971ddeae193ff3eed06c848 Mon Sep 17 00:00:00 2001 From: Roy Wedge Date: Fri, 3 May 2019 16:18:45 -0400 Subject: [PATCH] featuretools_primitives entry point expects list of primitive classes (#529) * the featuretools_primitives entry point expects a list of primitive classes * add example use of entry point * only import trans or agg primitives from entrypoint --- featuretools/primitives/__init__.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/featuretools/primitives/__init__.py b/featuretools/primitives/__init__.py index 769cb596e2..ff4bd57de1 100644 --- a/featuretools/primitives/__init__.py +++ b/featuretools/primitives/__init__.py @@ -2,12 +2,18 @@ from .api import * import pkg_resources -# Load in primitives registered by other libraries into Featuretools namespace +# Load in a list of primitives registered by other libraries into Featuretools +# Example entry_points definition for a library using this entry point: +# entry_points={ +# "featuretools_primitives": [ +# other_library = other_library:LIST_OF_PRIMITIVES +# ] +# } for entry_point in pkg_resources.iter_entry_points('featuretools_primitives'): try: loaded = entry_point.load() - if hasattr(loaded, 'primitives'): - for name, obj in loaded.primitives.items(): - globals()[name] = obj + for primitive in loaded: + if issubclass(primitive, (AggregationPrimitive, TransformPrimitive)): + globals()[primitive.__name__] = primitive except Exception: pass