@@ -372,14 +372,11 @@ def _convert_redis_values_to_protobuf(
372372 redis_values : List [List [ByteString ]],
373373 feature_view : str ,
374374 requested_features : List [str ],
375- ):
376- result : List [Tuple [Optional [datetime ], Optional [Dict [str , ValueProto ]]]] = []
377- for values in redis_values :
378- features = self ._get_features_for_entity (
379- values , feature_view , requested_features
380- )
381- result .append (features )
382- return result
375+ ) -> List [Tuple [Optional [datetime ], Optional [Dict [str , ValueProto ]]]]:
376+ return [
377+ self ._get_features_for_entity (values , feature_view , requested_features )
378+ for values in redis_values
379+ ]
383380
384381 def online_read (
385382 self ,
@@ -445,21 +442,25 @@ def _get_features_for_entity(
445442 res_val = dict (zip (requested_features , values ))
446443
447444 res_ts = Timestamp ()
448- ts_val = res_val .pop (f"_ts:{ feature_view } " )
445+ ts_key = f"_ts:{ feature_view } "
446+ ts_val = res_val .pop (ts_key )
449447 if ts_val :
450- res_ts .ParseFromString (bytes (ts_val ))
448+ res_ts .ParseFromString (
449+ ts_val if isinstance (ts_val , bytes ) else bytes (ts_val )
450+ )
451451
452- res = {}
452+ res : Dict [ str , ValueProto ] = {}
453453 for feature_name , val_bin in res_val .items ():
454454 val = ValueProto ()
455455 if val_bin :
456- val .ParseFromString (bytes (val_bin ))
456+ val .ParseFromString (
457+ val_bin if isinstance (val_bin , bytes ) else bytes (val_bin )
458+ )
457459 res [feature_name ] = val
458460
459461 if not res :
460462 return None , None
461- else :
462- # reconstruct full timestamp including nanos
463- total_seconds = res_ts .seconds + res_ts .nanos / 1_000_000_000.0
464- timestamp = datetime .fromtimestamp (total_seconds , tz = timezone .utc )
465- return timestamp , res
463+
464+ total_seconds = res_ts .seconds + res_ts .nanos / 1_000_000_000.0
465+ timestamp = datetime .fromtimestamp (total_seconds , tz = timezone .utc )
466+ return timestamp , res
0 commit comments