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

update registry test, modify log #892

Merged
merged 3 commits into from
Dec 2, 2022
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
1 change: 1 addition & 0 deletions feathr_project/feathr/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ def __init__(self, config_path:str = "./feathr_config.yaml", local_workspace_dir
registry_delimiter = self.envutils.get_environment_variable_with_default('feature_registry', 'purview', 'delimiter')
# initialize the registry no matter whether we set purview name or not, given some of the methods are used there.
self.registry = _PurviewRegistry(self.project_name, azure_purview_name, registry_delimiter, project_registry_tag, config_path = config_path, credential=credential)
logger.warning("FEATURE_REGISTRY__PURVIEW__PURVIEW_NAME will be deprecated soon. Please use FEATURE_REGISTRY__API_ENDPOINT instead.")
else:
# no registry configured
logger.info("Feathr registry is not configured. Consider setting the Feathr registry component for richer feature store experience.")
Expand Down
11 changes: 10 additions & 1 deletion feathr_project/test/test_feature_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from feathr.registry._feathr_registry_client import _FeatureRegistry
from feathrcli.cli import init
from test_fixture import registry_test_setup
from test_fixture import registry_test_setup_append, registry_test_setup_partially
from test_fixture import registry_test_setup_append, registry_test_setup_partially, registry_test_setup_for_409
from test_utils.constants import Constants

class FeatureRegistryTests(unittest.TestCase):
Expand Down Expand Up @@ -58,6 +58,15 @@ def test_feathr_register_features_e2e(self):

# Sync workspace from registry, will get all conf files back
client.get_features_from_registry(client.project_name)

# Register the same feature with different definition and expect an error.
client: FeathrClient = registry_test_setup_for_409(os.path.join(test_workspace_dir, config_path), client.project_name)

with pytest.raises(RuntimeError) as exc_info:
client.register_features()

# <ExceptionInfo RuntimeError('Failed to call registry API, status is 409, error is {"message":"Entity feathr_ci_registry_53_3_476999__request_features__f_is_long_trip_distance already exists"}')
assert "status is 409" in str(exc_info.value)

def test_feathr_register_features_partially(self):
"""
Expand Down
35 changes: 23 additions & 12 deletions feathr_project/test/test_fixture.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,18 +184,6 @@ def registry_test_setup_partially(config_path: str):
client.build_features(anchor_list=[agg_anchor, request_anchor], derived_feature_list=derived_feature_list)
return client

def registry_test_setup_append(config_path: str):
"""Append features to a project. Will call `generate_entities()` and register from the 2nd anchor feature
"""

client = FeathrClient(config_path=config_path, project_registry_tag={"for_test_purpose":"true"})

request_anchor, agg_anchor, derived_feature_list = generate_entities()
agg_anchor.features = agg_anchor.features[1:]
client.build_features(anchor_list=[agg_anchor, request_anchor], derived_feature_list=derived_feature_list)
return client


def generate_entities():
def add_new_dropoff_and_fare_amount_column(df: DataFrame):
from pyspark.sql.functions import col
Expand Down Expand Up @@ -375,6 +363,29 @@ def add_new_dropoff_and_fare_amount_column(df: DataFrame):
client.build_features(anchor_list=[agg_anchor, request_anchor], derived_feature_list=derived_feature_list)
return client

def registry_test_setup_for_409(config_path: str, project_name: str):
now = datetime.now()
os.environ["project_config__project_name"] = project_name

client = FeathrClient(config_path=config_path, project_registry_tag={"for_test_purpose":"true"})

# tranform in other sample is cast_float(trip_distance)>30
# update this to trigger 409 conflict with the existing one
features = [
Feature(name="f_is_long_trip_distance",
feature_type=BOOLEAN,
transform="cast_float(trip_distance)>10"),
]

request_anchor = FeatureAnchor(name="request_features",
source=INPUT_CONTEXT,
features=features,
registry_tags={"for_test_purpose":"true"}
)

client.build_features(anchor_list=[request_anchor])
return client

def get_online_test_table_name(table_name: str):
# use different time for testing to avoid write conflicts
now = datetime.now()
Expand Down