-
Notifications
You must be signed in to change notification settings - Fork 1.3k
feat: Event timestamps response #2355
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
Changes from 3 commits
35599b2
44e8054
4f41cd3
6c8e8eb
4f2388f
1370aed
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,7 +23,7 @@ | |
|
|
||
| class OnlineResponse: | ||
| """ | ||
| Defines a online response in feast. | ||
| Defines an online response in feast. | ||
| """ | ||
|
|
||
| def __init__(self, online_response_proto: GetOnlineFeaturesResponse): | ||
|
|
@@ -66,3 +66,28 @@ def to_df(self) -> pd.DataFrame: | |
| """ | ||
|
|
||
| return pd.DataFrame(self.to_dict()) | ||
|
|
||
| def event_timestamps_dict(self) -> Dict[str, List[int]]: | ||
| """ | ||
| Converts GetOnlineFeaturesResponse feature event timestamps into a dictionary form. | ||
| Includes the entity id | ||
| """ | ||
| response: Dict[str, List[int]] = {} | ||
|
|
||
| for result in self.proto.results: | ||
| for idx, feature_ref in enumerate(self.proto.metadata.feature_names.val): | ||
| # obtain the entity id | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems to rely on an implementation detail (that isn't enforced by the proto schema itself) that we have entities first and then the feature values (in https://github.com/feast-dev/feast/blob/master/sdk/python/feast/feature_store.py#L1269-L1269) On top of that, I think this becomes more broken when you have multiple join keys? Seems like ideally you'd actually somehow check the feature_ref and see if it's an entity. Alternatively, I'd just output both timestamp + values for each. That would make this simpler and not make assumptions. |
||
| if idx == 0: | ||
| value = feast_value_type_to_python_type(result.values[idx]) | ||
| # feature timestamps | ||
| else: | ||
| value = result.event_timestamps[idx].seconds | ||
|
|
||
| if feature_ref not in response: | ||
| response[feature_ref] = [value] | ||
| else: | ||
| response[feature_ref].append(value) | ||
| return response | ||
|
|
||
| def event_timestamps_df(self) -> pd.DataFrame: | ||
| return pd.DataFrame(self.event_timestamps_dict()) | ||
Uh oh!
There was an error while loading. Please reload this page.