@@ -88,10 +88,12 @@ def __init__(
88
88
f"Mapping fg_id to feature names: { self ._feature_names_per_fg_id } ."
89
89
)
90
90
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 ]:
92
94
"""Get a mapping of feature indices to their types for features that need decoding.
93
95
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
95
97
response and maps their position in the ordered feature list to their type.
96
98
97
99
# Arguments
@@ -104,7 +106,9 @@ def get_feature_to_decode(self, features: List[td_feature_mod.TrainingDatasetFea
104
106
feature_to_decode = {}
105
107
for feat in features :
106
108
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
+ )
108
112
return feature_to_decode
109
113
110
114
def build_base_payload (
@@ -160,14 +164,24 @@ def decode_rdrs_feature_values(self, feature_values: List[Any]) -> List[Any]:
160
164
feature_values: List of feature values from the RonDB Rest Server
161
165
162
166
# 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
164
168
converted to datetime.date objects
165
169
"""
166
170
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 ()
171
185
return feature_values
172
186
173
187
def get_single_feature_vector (
0 commit comments