Skip to content

Commit 1378fca

Browse files
committed
reformat
1 parent 431b83e commit 1378fca

File tree

1 file changed

+22
-8
lines changed

1 file changed

+22
-8
lines changed

python/hsfs/core/online_store_rest_client_engine.py

+22-8
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,12 @@ def __init__(
8888
f"Mapping fg_id to feature names: {self._feature_names_per_fg_id}."
8989
)
9090

91-
def get_feature_to_decode(self, features: List[td_feature_mod.TrainingDatasetFeature]) -> Dict[int, str]:
91+
def get_feature_to_decode(
92+
self, features: List[td_feature_mod.TrainingDatasetFeature]
93+
) -> Dict[int, str]:
9294
"""Get a mapping of feature indices to their types for features that need decoding.
9395
94-
This method identifies features that have types requiring special decoding from the RonDB Rest Server
96+
This method identifies features that have types requiring special decoding from the RonDB Rest Server
9597
response and maps their position in the ordered feature list to their type.
9698
9799
# Arguments
@@ -104,7 +106,9 @@ def get_feature_to_decode(self, features: List[td_feature_mod.TrainingDatasetFea
104106
feature_to_decode = {}
105107
for feat in features:
106108
if feat.type in self.FEATURE_TYPE_TO_DECODE:
107-
feature_to_decode[self._ordered_feature_names.index(feat.name)] = feat.type
109+
feature_to_decode[self._ordered_feature_names.index(feat.name)] = (
110+
feat.type
111+
)
108112
return feature_to_decode
109113

110114
def build_base_payload(
@@ -160,14 +164,24 @@ def decode_rdrs_feature_values(self, feature_values: List[Any]) -> List[Any]:
160164
feature_values: List of feature values from the RonDB Rest Server
161165
162166
# Returns:
163-
List of decoded feature values with binary values base64 decoded and date strings
167+
List of decoded feature values with binary values base64 decoded and date strings
164168
converted to datetime.date objects
165169
"""
166170
for feature_index, data_type in self._feature_to_decode.items():
167-
if data_type == self.BINARY_TYPE and feature_values[feature_index] is not None:
168-
feature_values[feature_index] = base64.b64decode(feature_values[feature_index])
169-
elif data_type == self.DATE_TYPE and feature_values[feature_index] is not None:
170-
feature_values[feature_index] = datetime.strptime(feature_values[feature_index], "%Y-%m-%d").date()
171+
if (
172+
data_type == self.BINARY_TYPE
173+
and feature_values[feature_index] is not None
174+
):
175+
feature_values[feature_index] = base64.b64decode(
176+
feature_values[feature_index]
177+
)
178+
elif (
179+
data_type == self.DATE_TYPE
180+
and feature_values[feature_index] is not None
181+
):
182+
feature_values[feature_index] = datetime.strptime(
183+
feature_values[feature_index], "%Y-%m-%d"
184+
).date()
171185
return feature_values
172186

173187
def get_single_feature_vector(

0 commit comments

Comments
 (0)