-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Expand file tree
/
Copy pathtest_feature_validation.py
More file actions
52 lines (45 loc) · 2.21 KB
/
test_feature_validation.py
File metadata and controls
52 lines (45 loc) · 2.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import pytest
from feast.errors import FeatureNameCollisionError
from feast.utils import _validate_feature_refs
def test_feature_name_collision_on_historical_retrieval():
# _validate_feature_refs is the function that checks for colliding feature names
# check when feature names collide and 'full_feature_names=False'
with pytest.raises(FeatureNameCollisionError) as error:
_validate_feature_refs(
feature_refs=[
"driver_stats:conv_rate",
"driver_stats:avg_daily_trips",
"customer_profile:current_balance",
"customer_profile:avg_passenger_count",
"customer_profile:lifetime_trip_count",
"customer_profile:avg_daily_trips",
],
full_feature_names=False,
)
expected_error_message = (
"Duplicate features named avg_daily_trips found.\n"
"To resolve this collision, either use the full feature name by setting "
"'full_feature_names=True', or ensure that the features in question have different names."
)
assert str(error.value) == expected_error_message
# check when feature names collide and 'full_feature_names=True'
with pytest.raises(FeatureNameCollisionError) as error:
_validate_feature_refs(
feature_refs=[
"driver_stats:conv_rate",
"driver_stats:avg_daily_trips",
"driver_stats:avg_daily_trips",
"customer_profile:current_balance",
"customer_profile:avg_passenger_count",
"customer_profile:lifetime_trip_count",
"customer_profile:avg_daily_trips",
],
full_feature_names=True,
)
expected_error_message = (
"Duplicate features named driver_stats__avg_daily_trips found.\n"
"To resolve this collision, please ensure that the feature views or their own features "
"have different names. If you're intentionally joining the same feature view twice on "
"different sets of entities, please rename one of the feature views with '.with_name'."
)
assert str(error.value) == expected_error_message