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 new configuration object #401

merged 11 commits into from Feb 5, 2019
Copy path View file
@@ -1,6 +1,6 @@
from __future__ import absolute_import
# flake8: noqa
from . import config
from .config_init import config
from . import variable_types
from .entityset.api import *
from . import primitives
@@ -1,3 +1,4 @@
import copy
import logging
import os
import sys
@@ -44,3 +45,28 @@ def initialize_logging():


class Config():
def __init__(self):
self._data = {}

def set_to_default(self):
PWD = os.path.dirname(__file__)
primitive_data_folder = os.path.join(PWD, "primitives/data")
self._data = {
"primitive_data_folder": primitive_data_folder,

def get(self, key):
return copy.deepcopy(self._data[key])

def get_all(self):
return copy.deepcopy(self._data)

def set(self, values):

config = Config()
@@ -4,6 +4,8 @@

import numpy as np

from featuretools import config

class PrimitiveBase(object):
"""Base class for all primitives."""
@@ -39,6 +41,4 @@ def get_function(self):
raise NotImplementedError("Subclass must implement")

def get_filepath(self, filename):
PWD = os.path.dirname(__file__)
path = os.path.join(PWD, "../data", filename)
return path
return os.path.join(config.get("primitive_data_folder"), filename)
No changes.
@@ -0,0 +1,30 @@
from featuretools import config

def test_get_default_config_does_not_change():
old_config = config.get_all()

key = "primitive_data_folder"
value = "This is an example string"
config.set({key: value})

assert config.get(key) != value


def test_set_and_get_config():

key = "primitive_data_folder"
old_value = config.get(key)
value = "This is an example string"

config.set({key: value})
assert config.get(key) == value

config.set({key: old_value})

def test_get_all():
assert config.get_all() == config._data
@@ -1,10 +1,13 @@
import os.path

import pytest
from pympler.asizeof import asizeof

from ..testing_utils import make_ecommerce_entityset

import featuretools as ft
from featuretools.feature_base import IdentityFeature
from featuretools import config
from featuretools.feature_base import Feature, IdentityFeature
from featuretools.primitives import Last, Mode, Sum
from featuretools.variable_types import Categorical, Datetime, Id, Numeric

@@ -109,3 +112,33 @@ def test_return_type_inference_id(es):
# also test direct feature of aggregation
mode_direct = ft.Feature(mode, es["sessions"])
assert mode_direct.variable_type == Categorical

def test_set_data_path(es):
This conversation was marked as resolved by kmax12

This comment has been minimized.

Copy link

kmax12 Feb 4, 2019


this test should just init primitives, no need to create features

key = "primitive_data_folder"

# Don't change orig_path
orig_path = config.get(key)
new_path = "/example/new/directory"
filename = "test.csv"

# Test that default path works
feat = Feature(es["log"]["value"])
assert feat.primitive.get_filepath(filename) == os.path.join(orig_path, filename)

# Test that new path works
config.set({key: new_path})
assert feat.primitive.get_filepath(filename) == os.path.join(new_path, filename)

# Test that new path with trailing / works
new_path += "/"
config.set({key: new_path})
assert feat.primitive.get_filepath(filename) == os.path.join(new_path, filename)

# Test that the path is correct on newly defined feature
feat2 = Feature(es["log"]["product_id"])
assert feat2.primitive.get_filepath(filename) == os.path.join(new_path, filename)

# Ensure path was reset
config.set({key: orig_path})
assert config.get(key) == orig_path
@@ -1,7 +1,7 @@
import logging
import os

from featuretools.config import initialize_logging
from featuretools.config_init import initialize_logging

logging_env_vars = {'FEATURETOOLS_LOG_LEVEL': "debug",
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.