Skip to content

Commit 531efa8

Browse files
author
Tsotne Tabidze
authored
Fix feature name consistency between online & historical apis (feast-dev#1434)
* Fix feature name consistency between online & historical apis Signed-off-by: Tsotne Tabidze <tsotne@tecton.ai> * Fix integration tests Signed-off-by: Tsotne Tabidze <tsotne@tecton.ai>
1 parent 3e2ebd1 commit 531efa8

File tree

4 files changed

+16
-16
lines changed

4 files changed

+16
-16
lines changed

sdk/python/feast/feature_store.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -468,13 +468,13 @@ def _get_online_features(
468468

469469
if feature_data is None:
470470
for feature_name in requested_features:
471-
feature_ref = f"{table.name}:{feature_name}"
471+
feature_ref = f"{table.name}__{feature_name}"
472472
result_row.statuses[
473473
feature_ref
474474
] = GetOnlineFeaturesResponse.FieldStatus.NOT_FOUND
475475
else:
476476
for feature_name in feature_data:
477-
feature_ref = f"{table.name}:{feature_name}"
477+
feature_ref = f"{table.name}__{feature_name}"
478478
if feature_name in requested_features:
479479
result_row.fields[feature_ref].CopyFrom(
480480
feature_data[feature_name]

sdk/python/tests/test_e2e_local.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,12 @@ def test_e2e_local() -> None:
7474
entity_rows=[{"driver_id": 1001}],
7575
)
7676

77-
assert "driver_hourly_stats:avg_daily_trips" in result.to_dict()
77+
assert "driver_hourly_stats__avg_daily_trips" in result.to_dict()
7878

79-
assert "driver_hourly_stats:conv_rate" in result.to_dict()
79+
assert "driver_hourly_stats__conv_rate" in result.to_dict()
8080
assert (
8181
abs(
82-
result.to_dict()["driver_hourly_stats:conv_rate"][0]
82+
result.to_dict()["driver_hourly_stats__conv_rate"][0]
8383
- _get_last_feature_row(driver_df, 1001)["conv_rate"]
8484
)
8585
< 0.01

sdk/python/tests/test_materialize_from_bigquery_to_datastore.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,13 @@ def test_bigquery_table_to_datastore_correctness(self):
8181
response_dict = fs.get_online_features(
8282
[f"{fv.name}:value"], [{"driver_id": 1}]
8383
).to_dict()
84-
assert abs(response_dict[f"{fv.name}:value"][0] - 0.3) < 1e-6
84+
assert abs(response_dict[f"{fv.name}__value"][0] - 0.3) < 1e-6
8585

8686
# check prior value for materialize_incremental()
8787
response_dict = fs.get_online_features(
8888
[f"{fv.name}:value"], [{"driver_id": 3}]
8989
).to_dict()
90-
assert abs(response_dict[f"{fv.name}:value"][0] - 4) < 1e-6
90+
assert abs(response_dict[f"{fv.name}__value"][0] - 4) < 1e-6
9191

9292
# run materialize_incremental()
9393
fs.materialize_incremental(
@@ -98,7 +98,7 @@ def test_bigquery_table_to_datastore_correctness(self):
9898
response_dict = fs.get_online_features(
9999
[f"{fv.name}:value"], [{"driver_id": 3}]
100100
).to_dict()
101-
assert abs(response_dict[f"{fv.name}:value"][0] - 5) < 1e-6
101+
assert abs(response_dict[f"{fv.name}__value"][0] - 5) < 1e-6
102102

103103
def test_bigquery_query_to_datastore_correctness(self):
104104
# create dataset
@@ -151,4 +151,4 @@ def test_bigquery_query_to_datastore_correctness(self):
151151
response_dict = fs.get_online_features(
152152
[f"{fv.name}:value"], [{"driver_id": 1}]
153153
).to_dict()
154-
assert abs(response_dict[f"{fv.name}:value"][0] - 0.3) < 1e-6
154+
assert abs(response_dict[f"{fv.name}__value"][0] - 0.3) < 1e-6

sdk/python/tests/test_online_retrieval.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,9 @@ def test_online() -> None:
7171
entity_rows=[{"driver": 1}, {"driver": 123}],
7272
)
7373

74-
assert "driver_locations:lon" in result.to_dict()
75-
assert result.to_dict()["driver_locations:lon"] == ["1.0", None]
76-
assert result.to_dict()["driver_locations_2:lon"] == ["2.0", None]
74+
assert "driver_locations__lon" in result.to_dict()
75+
assert result.to_dict()["driver_locations__lon"] == ["1.0", None]
76+
assert result.to_dict()["driver_locations_2__lon"] == ["2.0", None]
7777

7878
# invalid table reference
7979
with pytest.raises(ValueError):
@@ -99,7 +99,7 @@ def test_online() -> None:
9999
feature_refs=["driver_locations:lon", "driver_locations_2:lon"],
100100
entity_rows=[{"driver": 1}, {"driver": 123}],
101101
)
102-
assert result.to_dict()["driver_locations:lon"] == ["1.0", None]
102+
assert result.to_dict()["driver_locations__lon"] == ["1.0", None]
103103

104104
# Rename the registry.db so that it cant be used for refreshes
105105
os.rename(store.config.registry, store.config.registry + "_fake")
@@ -122,7 +122,7 @@ def test_online() -> None:
122122
feature_refs=["driver_locations:lon", "driver_locations_2:lon"],
123123
entity_rows=[{"driver": 1}, {"driver": 123}],
124124
)
125-
assert result.to_dict()["driver_locations:lon"] == ["1.0", None]
125+
assert result.to_dict()["driver_locations__lon"] == ["1.0", None]
126126

127127
# Create a registry with infinite cache (for users that want to manually refresh the registry)
128128
fs_infinite_ttl = FeatureStore(
@@ -141,7 +141,7 @@ def test_online() -> None:
141141
feature_refs=["driver_locations:lon", "driver_locations_2:lon"],
142142
entity_rows=[{"driver": 1}, {"driver": 123}],
143143
)
144-
assert result.to_dict()["driver_locations:lon"] == ["1.0", None]
144+
assert result.to_dict()["driver_locations__lon"] == ["1.0", None]
145145

146146
# Wait a bit so that an arbitrary TTL would take effect
147147
time.sleep(2)
@@ -154,7 +154,7 @@ def test_online() -> None:
154154
feature_refs=["driver_locations:lon", "driver_locations_2:lon"],
155155
entity_rows=[{"driver": 1}, {"driver": 123}],
156156
)
157-
assert result.to_dict()["driver_locations:lon"] == ["1.0", None]
157+
assert result.to_dict()["driver_locations__lon"] == ["1.0", None]
158158

159159
# Force registry reload (should fail because file is missing)
160160
with pytest.raises(FileNotFoundError):

0 commit comments

Comments
 (0)