Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add entry points #452

Merged
merged 27 commits into from
Mar 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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'):
gsheni marked this conversation as resolved.
Show resolved Hide resolved
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'):
gsheni marked this conversation as resolved.
Show resolved Hide resolved
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'):
gsheni marked this conversation as resolved.
Show resolved Hide resolved
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'):
gsheni marked this conversation as resolved.
Show resolved Hide resolved
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