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

Fix feature name consistency between online & historical apis #1434

Merged
merged 2 commits into from
Apr 3, 2021
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
4 changes: 2 additions & 2 deletions sdk/python/feast/feature_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,13 +468,13 @@ def _get_online_features(

if feature_data is None:
for feature_name in requested_features:
feature_ref = f"{table.name}:{feature_name}"
feature_ref = f"{table.name}__{feature_name}"
result_row.statuses[
feature_ref
] = GetOnlineFeaturesResponse.FieldStatus.NOT_FOUND
else:
for feature_name in feature_data:
feature_ref = f"{table.name}:{feature_name}"
feature_ref = f"{table.name}__{feature_name}"
if feature_name in requested_features:
result_row.fields[feature_ref].CopyFrom(
feature_data[feature_name]
Expand Down
6 changes: 3 additions & 3 deletions sdk/python/tests/test_e2e_local.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,12 @@ def test_e2e_local() -> None:
entity_rows=[{"driver_id": 1001}],
)

assert "driver_hourly_stats:avg_daily_trips" in result.to_dict()
assert "driver_hourly_stats__avg_daily_trips" in result.to_dict()

assert "driver_hourly_stats:conv_rate" in result.to_dict()
assert "driver_hourly_stats__conv_rate" in result.to_dict()
assert (
abs(
result.to_dict()["driver_hourly_stats:conv_rate"][0]
result.to_dict()["driver_hourly_stats__conv_rate"][0]
- _get_last_feature_row(driver_df, 1001)["conv_rate"]
)
< 0.01
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,13 @@ def test_bigquery_table_to_datastore_correctness(self):
response_dict = fs.get_online_features(
[f"{fv.name}:value"], [{"driver_id": 1}]
).to_dict()
assert abs(response_dict[f"{fv.name}:value"][0] - 0.3) < 1e-6
assert abs(response_dict[f"{fv.name}__value"][0] - 0.3) < 1e-6

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

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

def test_bigquery_query_to_datastore_correctness(self):
# create dataset
Expand Down Expand Up @@ -151,4 +151,4 @@ def test_bigquery_query_to_datastore_correctness(self):
response_dict = fs.get_online_features(
[f"{fv.name}:value"], [{"driver_id": 1}]
).to_dict()
assert abs(response_dict[f"{fv.name}:value"][0] - 0.3) < 1e-6
assert abs(response_dict[f"{fv.name}__value"][0] - 0.3) < 1e-6
14 changes: 7 additions & 7 deletions sdk/python/tests/test_online_retrieval.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ def test_online() -> None:
entity_rows=[{"driver": 1}, {"driver": 123}],
)

assert "driver_locations:lon" in result.to_dict()
assert result.to_dict()["driver_locations:lon"] == ["1.0", None]
assert result.to_dict()["driver_locations_2:lon"] == ["2.0", None]
assert "driver_locations__lon" in result.to_dict()
assert result.to_dict()["driver_locations__lon"] == ["1.0", None]
assert result.to_dict()["driver_locations_2__lon"] == ["2.0", None]

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

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

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

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

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