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
Changes from 25 commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

@@ -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 *
@@ -16,3 +16,20 @@
from .feature_base import AggregationFeature, DirectFeature, Feature, FeatureBase, IdentityFeature, TransformFeature

__version__ = '0.6.1'

import pkg_resources
import sys
for entry_point in pkg_resources.iter_entry_points('featuretools_initialize'):
This conversation was marked as resolved by gsheni

This comment has been minimized.

Copy link
@kmax12

kmax12 Mar 18, 2019

Member

add a comment to this block? something like

"Call functions registered by other libraries when featuretools is imported"

This comment has been minimized.

Copy link
@gsheni

gsheni Mar 19, 2019

Author Contributor

Added

try:
module = entry_point.load()
if hasattr(module, 'initialize'):
module.initialize()
except Exception:
pass


for entry_point in pkg_resources.iter_entry_points('featuretools_plugin'):
This conversation was marked as resolved by gsheni

This comment has been minimized.

Copy link
@kmax12

kmax12 Mar 18, 2019

Member

add a comment to this block? something like

"Load in submodules registered by other libraries into Featuretools namespace"

This comment has been minimized.

Copy link
@gsheni

gsheni Mar 19, 2019

Author Contributor

Added

try:
sys.modules["featuretools." + entry_point.name] = entry_point.load()
except Exception:
pass
@@ -1,3 +1,4 @@

This conversation was marked as resolved by gsheni

This comment has been minimized.

Copy link
@kmax12

kmax12 Mar 18, 2019

Member

remove this line?

This comment has been minimized.

Copy link
@gsheni

gsheni Mar 19, 2019

Author Contributor

Fixed

import json
import os
import shutil
@@ -1,2 +1,12 @@
# flake8: noqa
from .api import *

import pkg_resources
for entry_point in pkg_resources.iter_entry_points('featuretools_primitives'):
This conversation was marked as resolved by gsheni

This comment has been minimized.

Copy link
@kmax12

kmax12 Mar 18, 2019

Member

add a comment to this block? something like

"Load in primitives registered by other libraries into Featuretools namespace"

This comment has been minimized.

Copy link
@gsheni

gsheni Mar 19, 2019

Author Contributor

Added

try:
loaded = entry_point.load()
if hasattr(loaded, 'primitives'):
for name, obj in loaded.primitives.items():
globals()[name] = obj
except Exception:
pass
@@ -1,3 +1,4 @@
from __future__ import absolute_import
# flake8: noqa
from .api import *

This conversation was marked as resolved by gsheni

This comment has been minimized.

Copy link
@kmax12

kmax12 Mar 18, 2019

Member

remove this line?

This comment has been minimized.

Copy link
@gsheni

gsheni Mar 19, 2019

Author Contributor

Fixed.

@@ -1,4 +1,5 @@
import pandas as pd
import pkg_resources

from .deep_feature_synthesis import DeepFeatureSynthesis

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

for entry_point in pkg_resources.iter_entry_points('featuretools_dfs'):
This conversation was marked as resolved by gsheni

This comment has been minimized.

Copy link
@kmax12

kmax12 Mar 18, 2019

Member

add a comment to this block? something like

"Call functions registered by other libraries with DFS arguments"

This comment has been minimized.

Copy link
@gsheni

gsheni Mar 19, 2019

Author Contributor

Added

try:
loaded = entry_point.load()
# TODO: change name of module function
This conversation was marked as resolved by gsheni

This comment has been minimized.

Copy link
@kmax12

kmax12 Mar 18, 2019

Member

this module function works for now

This comment has been minimized.

Copy link
@gsheni

gsheni Mar 19, 2019

Author Contributor

Removed

if hasattr(loaded, 'dfs'):
loaded.dfs(locals())
except Exception:
pass

dfs_object = DeepFeatureSynthesis(target_entity, entityset,
agg_primitives=agg_primitives,
trans_primitives=trans_primitives,
No changes.
@@ -0,0 +1,81 @@
# import pandas as pd
This conversation was marked as resolved by gsheni

This comment has been minimized.

Copy link
@kmax12

kmax12 Mar 18, 2019

Member

delete this file?

This comment has been minimized.

Copy link
@gsheni

gsheni Mar 19, 2019

Author Contributor

Removed

# import os
# import site
# import pandas as pd
# import pytest
# import json
# from distributed.utils_test import cluster

# from featuretools.tests.testing_utils import make_ecommerce_entityset

# from featuretools.primitives import Max, Mean, Min, Sum
# from featuretools.synthesis import dfs
# from ..primitive_tests.test_install_primitives import pip_freeze


# @pytest.fixture(scope='module')
# def es():
# return make_ecommerce_entityset()


# @pytest.fixture(scope='module')
# def entities():
# cards_df = pd.DataFrame({"id": [1, 2, 3, 4, 5]})
# transactions_df = pd.DataFrame({"id": [1, 2, 3, 4, 5, 6],
# "card_id": [1, 2, 1, 3, 4, 5],
# "transaction_time": [10, 12, 13, 20, 21, 20],
# "fraud": [True, False, False, False, True, True]})
# entities = {
# "cards": (cards_df, "id"),
# "transactions": (transactions_df, "id", "transaction_time")
# }
# return entities


# @pytest.fixture(scope='module')
# def relationships():
# return [("cards", "id", "transactions", "card_id")]


# @pytest.fixture(scope='module')
# def check_plugin():
# assert "featuretools-plugin-tester" in pip_freeze()
# return


# def test_entry_point_primitive(check_plugin):
# from featuretools.primitives import CustomMinPlusOne
# input_array = pd.Series([0, 1, 2, 3, 4])
# primitive_func = CustomMinPlusOne().get_function()
# # CustomMinPlusOne is actually min + plus 1
# assert primitive_func(input_array) == 1
# assert CustomMinPlusOne.name == 'custom_min_plus_one'


# def test_entry_point_initialize(check_plugin):
# file_path = os.path.join(site.getsitepackages()[0],
# 'featuretools_plugin_tester',
# 'initialize',
# 'initialize_plugin_called.txt')
# import featuretools
# assert os.path.isfile(file_path)


# def test_dfs_plugin(entities, relationships):
# cutoff_times_df = pd.DataFrame({"instance_id": [1, 2, 3],
# "time": [10, 12, 15]})
# feature_matrix, features = dfs(entities=entities,
# relationships=relationships,
# target_entity="transactions",
# cutoff_time=cutoff_times_df)
# assert len(feature_matrix.index) == 3
# assert len(feature_matrix.columns) == len(features)

# file_path = os.path.join(site.getsitepackages()[0],
# 'featuretools_plugin_tester',
# 'dfs',
# 'dfs_plugin_tester.json')
# assert os.path.isfile(file_path)
# with open(file_path) as f:
# data = json.load(f)
# assert 'entityset_name' in data
@@ -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"])
@@ -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
@@ -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'
)
@@ -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
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.