Skip to content

Commit

Permalink
[Feature Store] Fix alias handling in OnlineVectorService (#2073)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gal Topper committed Jun 25, 2022
1 parent 49a79be commit 1741729
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
3 changes: 0 additions & 3 deletions mlrun/feature_store/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,9 +265,6 @@ def get_online_feature_service(

# todo: support remote service (using remote nuclio/mlrun function if run_config)

for old_name in service.vector.get_feature_aliases().keys():
if old_name in service.vector.status.features.keys():
del service.vector.status.features[old_name]
return service


Expand Down
11 changes: 6 additions & 5 deletions mlrun/feature_store/feature_vector.py
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,11 @@ def get(self, entity_rows: List[Union[dict, list]], as_list=False):
for row in entity_rows:
futures.append(self._controller.emit(row, return_awaitable_result=True))

requested_columns = list(self.vector.status.features.keys())
aliases = self.vector.get_feature_aliases()
for i, column in enumerate(requested_columns):
requested_columns[i] = aliases.get(column, column)

for future in futures:
result = future.await_result()
data = result.body
Expand All @@ -497,7 +502,6 @@ def get(self, entity_rows: List[Union[dict, list]], as_list=False):
if not data:
data = None
else:
requested_columns = self.vector.status.features.keys()
actual_columns = data.keys()
for column in requested_columns:
if (
Expand All @@ -513,12 +517,9 @@ def get(self, entity_rows: List[Union[dict, list]], as_list=False):
data[name] = self._impute_values.get(name, v)

if as_list and data:
keys = set(self.vector.status.features.keys()).union(
set(self.vector.get_feature_aliases().values())
)
data = [
data.get(key, None)
for key in keys
for key in requested_columns
if key != self.vector.status.label_column
]
results.append(data)
Expand Down
4 changes: 3 additions & 1 deletion tests/system/feature_store/test_feature_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -2735,13 +2735,15 @@ def test_alias_change(self):
resp = service.get([{"ticker": "AAPL"}])
assert resp == [
{
"new_alias_for_total_ask": 0.0,
"bids_min_1h": math.inf,
"bids_max_1h": -math.inf,
"new_alias_for_total_ask": 0.0,
"name": "Apple Inc",
"exchange": "NASDAQ",
}
]
resp = service.get([{"ticker": "AAPL"}], as_list=True)
assert resp == [[0.0, math.inf, -math.inf, "Apple Inc", "NASDAQ"]]
finally:
service.close()

Expand Down

0 comments on commit 1741729

Please sign in to comment.