|
13 | 13 | # limitations under the License. |
14 | 14 | import json |
15 | 15 | import logging |
| 16 | +import uuid as uuid_module |
16 | 17 | from collections import defaultdict |
17 | 18 | from datetime import datetime |
18 | 19 | from typing import Any, Callable, Dict, List, Literal, Optional, Sequence, Tuple |
|
38 | 39 | logger = logging.getLogger(__name__) |
39 | 40 |
|
40 | 41 |
|
| 42 | +def _json_safe(val: Any) -> Any: |
| 43 | + """Convert uuid.UUID objects to strings for JSON serialization.""" |
| 44 | + if isinstance(val, uuid_module.UUID): |
| 45 | + return str(val) |
| 46 | + if isinstance(val, list): |
| 47 | + return [str(v) if isinstance(v, uuid_module.UUID) else v for v in val] |
| 48 | + return val |
| 49 | + |
| 50 | + |
41 | 51 | class RemoteOnlineStoreConfig(FeastConfigBaseModel): |
42 | 52 | """Remote Online store config for remote online store""" |
43 | 53 |
|
@@ -93,15 +103,13 @@ def online_write_batch( |
93 | 103 | for join_key, entity_value_proto in zip( |
94 | 104 | entity_key_proto.join_keys, entity_key_proto.entity_values |
95 | 105 | ): |
96 | | - columnar_data[join_key].append( |
97 | | - feast_value_type_to_python_type(entity_value_proto) |
98 | | - ) |
| 106 | + val = feast_value_type_to_python_type(entity_value_proto) |
| 107 | + columnar_data[join_key].append(_json_safe(val)) |
99 | 108 |
|
100 | 109 | # Populate feature values |
101 | 110 | for feature_name, feature_value_proto in feature_values_proto.items(): |
102 | | - columnar_data[feature_name].append( |
103 | | - feast_value_type_to_python_type(feature_value_proto) |
104 | | - ) |
| 111 | + val = feast_value_type_to_python_type(feature_value_proto) |
| 112 | + columnar_data[feature_name].append(_json_safe(val)) |
105 | 113 |
|
106 | 114 | # Populate timestamps |
107 | 115 | columnar_data["event_timestamp"].append(_to_naive_utc(event_ts).isoformat()) |
|
0 commit comments