Skip to content

Commit

Permalink
featuretools_primitives entry point expects list of primitive classes (
Browse files Browse the repository at this point in the history
…#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
  • Loading branch information
rwedge authored and kmax12 committed May 3, 2019
1 parent 7e1e47a commit 0739b88
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions featuretools/primitives/__init__.py
Expand Up @@ -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

0 comments on commit 0739b88

Please sign in to comment.