MCPcopy Create free account
hub / github.com/feast-dev/feast / _populate_response_from_feature_data

Function _populate_response_from_feature_data

sdk/python/feast/utils.py:1582–1683  ·  view source on GitHub ↗

Populate the GetOnlineFeaturesResponse from raw online_read rows. Converts raw rows from the OnlineStore into protobuf FeatureVectors and appends them to the response. This method assumes that ``online_read`` returns data for each unique entity in the same order as ``indexes``. Arg

(
    requested_features: List[str],
    read_rows: List[Tuple[Optional[datetime], Optional[Dict[str, ValueProto]]]],
    indexes: Iterable[List[int]],
    online_features_response: GetOnlineFeaturesResponse,
    full_feature_names: bool,
    table: "FeatureView",
    output_len: int,
    include_feature_view_version_metadata: bool = False,
)

Source from the content-addressed store, hash-verified

1580
1581
1582def _populate_response_from_feature_data(
1583 requested_features: List[str],
1584 read_rows: List[Tuple[Optional[datetime], Optional[Dict[str, ValueProto]]]],
1585 indexes: Iterable[List[int]],
1586 online_features_response: GetOnlineFeaturesResponse,
1587 full_feature_names: bool,
1588 table: "FeatureView",
1589 output_len: int,
1590 include_feature_view_version_metadata: bool = False,
1591):
1592 """Populate the GetOnlineFeaturesResponse from raw online_read rows.
1593
1594 Converts raw rows from the OnlineStore into protobuf FeatureVectors and
1595 appends them to the response. This method assumes that ``online_read``
1596 returns data for each unique entity in the same order as ``indexes``.
1597
1598 Args:
1599 requested_features: The names of the features to extract from
1600 each row. Determines the order of FeatureVectors in the response.
1601 read_rows: Raw output from ``OnlineStore.online_read`` — a list of
1602 ``(event_timestamp, feature_dict)`` tuples, one per unique entity.
1603 ``feature_dict`` may be ``None`` when the entity is not found.
1604 indexes: A tuple of lists that maps each unique entity (by position
1605 in ``read_rows``) to one or more output positions in the response.
1606 Used to fan-out deduplicated reads back to the original request rows.
1607 online_features_response: The protobuf response object to populate.
1608 full_feature_names: If True, feature names are prefixed with the
1609 feature view name (e.g. ``"driver_fv__trips_today"``).
1610 table: The FeatureView that ``read_rows`` was retrieved from.
1611 output_len: Total number of result rows in the response.
1612 include_feature_view_version_metadata: If True, version metadata
1613 for the feature view is added to the response.
1614 """
1615 n_features = len(requested_features)
1616
1617 table_name = table.projection.name_to_use()
1618 clean_table_name = table.projection.name_alias or table.projection.name
1619 feature_refs = [
1620 f"{table_name}__{fn}" if full_feature_names else fn for fn in requested_features
1621 ]
1622 online_features_response.metadata.feature_names.val.extend(feature_refs)
1623
1624 if include_feature_view_version_metadata:
1625 existing_names = [
1626 fvm.name for fvm in online_features_response.metadata.feature_view_metadata
1627 ]
1628 if clean_table_name not in existing_names:
1629 fv_metadata = online_features_response.metadata.feature_view_metadata.add()
1630 fv_metadata.name = clean_table_name
1631 fv_metadata.version = getattr(table, "current_version_number", 0) or 0
1632
1633 null_value = ValueProto()
1634 null_ts = Timestamp()
1635 PRESENT = FieldStatus.PRESENT
1636 NOT_FOUND = FieldStatus.NOT_FOUND
1637
1638 row_ts_protos = []
1639 for row_ts, _ in read_rows:

Calls 3

track_feature_statusesFunction · 0.90
name_to_useMethod · 0.80
getMethod · 0.80