From 7f7b1ab4f9ba280651600bea05ab4865e2433a4d Mon Sep 17 00:00:00 2001 From: Yuqing Wei Date: Thu, 1 Dec 2022 18:47:35 +0800 Subject: [PATCH 1/2] update registry test, modify log Signed-off-by: Yuqing Wei --- feathr_project/feathr/client.py | 1 + feathr_project/test/test_feature_registry.py | 11 +++++- feathr_project/test/test_fixture.py | 35 +++++++++++++------- 3 files changed, 34 insertions(+), 13 deletions(-) diff --git a/feathr_project/feathr/client.py b/feathr_project/feathr/client.py index 52c7f1a8f..720d4ad35 100644 --- a/feathr_project/feathr/client.py +++ b/feathr_project/feathr/client.py @@ -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 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.") diff --git a/feathr_project/test/test_feature_registry.py b/feathr_project/test/test_feature_registry.py index 86db93440..48b3d0f85 100644 --- a/feathr_project/test/test_feature_registry.py +++ b/feathr_project/test/test_feature_registry.py @@ -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_update from test_utils.constants import Constants class FeatureRegistryTests(unittest.TestCase): @@ -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_update(os.path.join(test_workspace_dir, config_path), client.project_name) + + with pytest.raises(RuntimeError) as exc_info: + client.register_features() + + # 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() From 69f4876dcc956f63632ccebc370dff8bf169cf18 Mon Sep 17 00:00:00 2001 From: Yuqing Wei Date: Fri, 2 Dec 2022 10:08:44 +0800 Subject: [PATCH 2/2] fix comment Signed-off-by: Yuqing Wei --- feathr_project/feathr/client.py | 2 +- feathr_project/test/test_feature_registry.py | 4 ++-- feathr_project/test/test_fixture.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/feathr_project/feathr/client.py b/feathr_project/feathr/client.py index f7322e57c..23e7e6691 100644 --- a/feathr_project/feathr/client.py +++ b/feathr_project/feathr/client.py @@ -188,7 +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 deprecated soon. Please use FEATURE_REGISTRY__API_ENDPOINT instead.") + 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.") diff --git a/feathr_project/test/test_feature_registry.py b/feathr_project/test/test_feature_registry.py index 48b3d0f85..9fe66322a 100644 --- a/feathr_project/test/test_feature_registry.py +++ b/feathr_project/test/test_feature_registry.py @@ -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, registry_test_setup_update +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): @@ -60,7 +60,7 @@ def test_feathr_register_features_e2e(self): client.get_features_from_registry(client.project_name) # Register the same feature with different definition and expect an error. - client: FeathrClient = registry_test_setup_update(os.path.join(test_workspace_dir, config_path), client.project_name) + 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() diff --git a/feathr_project/test/test_fixture.py b/feathr_project/test/test_fixture.py index fdaf75660..d6d8941c9 100644 --- a/feathr_project/test/test_fixture.py +++ b/feathr_project/test/test_fixture.py @@ -363,7 +363,7 @@ 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_update(config_path: str, project_name: str): +def registry_test_setup_for_409(config_path: str, project_name: str): now = datetime.now() os.environ["project_config__project_name"] = project_name