Skip to content

Commit adab8d8

Browse files
authored
update registry test, modify log (#892)
* update registry test, modify log Signed-off-by: Yuqing Wei <weiyuqing021@outlook.com> * fix comment Signed-off-by: Yuqing Wei <weiyuqing021@outlook.com> Signed-off-by: Yuqing Wei <weiyuqing021@outlook.com>
1 parent f8a7e76 commit adab8d8

File tree

3 files changed

+34
-13
lines changed

3 files changed

+34
-13
lines changed

feathr_project/feathr/client.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ def __init__(self, config_path:str = "./feathr_config.yaml", local_workspace_dir
188188
registry_delimiter = self.envutils.get_environment_variable_with_default('feature_registry', 'purview', 'delimiter')
189189
# initialize the registry no matter whether we set purview name or not, given some of the methods are used there.
190190
self.registry = _PurviewRegistry(self.project_name, azure_purview_name, registry_delimiter, project_registry_tag, config_path = config_path, credential=credential)
191+
logger.warning("FEATURE_REGISTRY__PURVIEW__PURVIEW_NAME will be deprecated soon. Please use FEATURE_REGISTRY__API_ENDPOINT instead.")
191192
else:
192193
# no registry configured
193194
logger.info("Feathr registry is not configured. Consider setting the Feathr registry component for richer feature store experience.")

feathr_project/test/test_feature_registry.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from feathr.registry._feathr_registry_client import _FeatureRegistry
1515
from feathrcli.cli import init
1616
from test_fixture import registry_test_setup
17-
from test_fixture import registry_test_setup_append, registry_test_setup_partially
17+
from test_fixture import registry_test_setup_append, registry_test_setup_partially, registry_test_setup_for_409
1818
from test_utils.constants import Constants
1919

2020
class FeatureRegistryTests(unittest.TestCase):
@@ -58,6 +58,15 @@ def test_feathr_register_features_e2e(self):
5858

5959
# Sync workspace from registry, will get all conf files back
6060
client.get_features_from_registry(client.project_name)
61+
62+
# Register the same feature with different definition and expect an error.
63+
client: FeathrClient = registry_test_setup_for_409(os.path.join(test_workspace_dir, config_path), client.project_name)
64+
65+
with pytest.raises(RuntimeError) as exc_info:
66+
client.register_features()
67+
68+
# <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"}')
69+
assert "status is 409" in str(exc_info.value)
6170

6271
def test_feathr_register_features_partially(self):
6372
"""

feathr_project/test/test_fixture.py

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -184,18 +184,6 @@ def registry_test_setup_partially(config_path: str):
184184
client.build_features(anchor_list=[agg_anchor, request_anchor], derived_feature_list=derived_feature_list)
185185
return client
186186

187-
def registry_test_setup_append(config_path: str):
188-
"""Append features to a project. Will call `generate_entities()` and register from the 2nd anchor feature
189-
"""
190-
191-
client = FeathrClient(config_path=config_path, project_registry_tag={"for_test_purpose":"true"})
192-
193-
request_anchor, agg_anchor, derived_feature_list = generate_entities()
194-
agg_anchor.features = agg_anchor.features[1:]
195-
client.build_features(anchor_list=[agg_anchor, request_anchor], derived_feature_list=derived_feature_list)
196-
return client
197-
198-
199187
def generate_entities():
200188
def add_new_dropoff_and_fare_amount_column(df: DataFrame):
201189
from pyspark.sql.functions import col
@@ -375,6 +363,29 @@ def add_new_dropoff_and_fare_amount_column(df: DataFrame):
375363
client.build_features(anchor_list=[agg_anchor, request_anchor], derived_feature_list=derived_feature_list)
376364
return client
377365

366+
def registry_test_setup_for_409(config_path: str, project_name: str):
367+
now = datetime.now()
368+
os.environ["project_config__project_name"] = project_name
369+
370+
client = FeathrClient(config_path=config_path, project_registry_tag={"for_test_purpose":"true"})
371+
372+
# tranform in other sample is cast_float(trip_distance)>30
373+
# update this to trigger 409 conflict with the existing one
374+
features = [
375+
Feature(name="f_is_long_trip_distance",
376+
feature_type=BOOLEAN,
377+
transform="cast_float(trip_distance)>10"),
378+
]
379+
380+
request_anchor = FeatureAnchor(name="request_features",
381+
source=INPUT_CONTEXT,
382+
features=features,
383+
registry_tags={"for_test_purpose":"true"}
384+
)
385+
386+
client.build_features(anchor_list=[request_anchor])
387+
return client
388+
378389
def get_online_test_table_name(table_name: str):
379390
# use different time for testing to avoid write conflicts
380391
now = datetime.now()

0 commit comments

Comments
 (0)