Skip to content

Commit

Permalink
Add entry points (#452)
Browse files Browse the repository at this point in the history
* working

* lint fix

* renamed and added init

* Rename

* fix attrbute

* Updated featuretools

* fix conflict

* WIP on test

* test todo

* fix test

* lint

* working test

* WIP

* WIP

* Added try except to entry points

* dfs added

* working

* move init

* reorder init

* added plugin

* use locals

* comment fixes
  • Loading branch information
gsheni committed Mar 20, 2019
1 parent f6b16bf commit 2b6a947
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 13 deletions.
20 changes: 19 additions & 1 deletion featuretools/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from __future__ import absolute_import
# flake8: noqa
from __future__ import absolute_import
from .config_init import config
from . import variable_types
from .entityset.api import *
Expand All @@ -16,3 +16,21 @@
from .feature_base import AggregationFeature, DirectFeature, Feature, FeatureBase, IdentityFeature, TransformFeature

__version__ = '0.6.1'

import pkg_resources
import sys
# Call functions registered by other libraries when featuretools is imported
for entry_point in pkg_resources.iter_entry_points('featuretools_initialize'):
try:
module = entry_point.load()
if hasattr(module, 'initialize'):
module.initialize()
except Exception:
pass

# Load in submodules registered by other libraries into Featuretools namespace
for entry_point in pkg_resources.iter_entry_points('featuretools_plugin'):
try:
sys.modules["featuretools." + entry_point.name] = entry_point.load()
except Exception:
pass
11 changes: 11 additions & 0 deletions featuretools/primitives/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,13 @@
# flake8: noqa
from .api import *

import pkg_resources
# Load in primitives registered by other libraries into Featuretools namespace
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
except Exception:
pass
2 changes: 1 addition & 1 deletion featuretools/synthesis/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from __future__ import absolute_import
# flake8: noqa
from .api import *
from .api import *
10 changes: 10 additions & 0 deletions featuretools/synthesis/dfs.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import pandas as pd
import pkg_resources

from .deep_feature_synthesis import DeepFeatureSynthesis

Expand Down Expand Up @@ -174,6 +175,15 @@ def dfs(entities=None,
if not isinstance(entityset, EntitySet):
entityset = EntitySet("dfs", entities, relationships)

# Call functions registered by other libraries with DFS arguments
for entry_point in pkg_resources.iter_entry_points('featuretools_dfs'):
try:
loaded = entry_point.load()
if hasattr(loaded, 'dfs'):
loaded.dfs(locals())
except Exception:
pass

dfs_object = DeepFeatureSynthesis(target_entity, entityset,
agg_primitives=agg_primitives,
trans_primitives=trans_primitives,
Expand Down
13 changes: 7 additions & 6 deletions featuretools/tests/primitive_tests/test_install_primitives.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,12 +237,6 @@ def test_extract_non_archive_errors(bad_primitives_files_dir):


def test_install_packages_from_requirements(primitives_to_install_dir):
def pip_freeze():
output = subprocess.check_output(['pip', 'freeze'])
if not isinstance(output, str):
output = output.decode()
return output

# make sure dummy module isn't installed
if "featuretools-pip-tester" in pip_freeze():
subprocess.check_call(["pip", "uninstall", "-y", "featuretools-pip-tester"])
Expand Down Expand Up @@ -305,3 +299,10 @@ def pip_freeze():

assert "featuretools-pip-tester" in pip_freeze()
subprocess.check_call(["pip", "uninstall", "-y", "featuretools-pip-tester"])


def pip_freeze():
output = subprocess.check_output(['pip', 'freeze'])
if not isinstance(output, str):
output = output.decode()
return output
8 changes: 4 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ def finalize_options(self):
keywords='feature engineering data science machine learning',
include_package_data=True,
entry_points={
'console_scripts': [
'featuretools = featuretools.__main__:cli'
]
},
'console_scripts': [
'featuretools = featuretools.__main__:cli'
]
},
long_description=long_description,
long_description_content_type='text/markdown'
)
2 changes: 1 addition & 1 deletion test-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ pytest-xdist==1.26.1
pytest-cov==2.6.1
fastparquet>=0.1.6
graphviz>=0.8.4
s3fs>=0.1.5
s3fs>=0.1.5

0 comments on commit 2b6a947

Please sign in to comment.