4242enable_features ("contrib" )
4343
4444
45- def  parse_if_OK (res : requests .Response ) ->  IOResultE [str ]:
45+ def  parse_if_ok (res : requests .Response ) ->  IOResultE [str ]:
46+     """Only continues if Response is OK (200).""" 
4647    if  res .status_code  ==  status .HTTP_200_OK :
4748        return  IOSuccess (res .content .decode ("utf8" ))
4849    return  IOFailure (ValueError (f"Unexpected response code: { res .status_code } { res .content }  ))
@@ -97,7 +98,7 @@ def get_dataset_metadata(self) -> IOResultE[LomasRequestModel]:
9798            # post to the validated body to the corresponding endpoint 
9899            lambda  body : self .http_client .post ("get_dataset_metadata" , body ),
99100            # parse reply if HTTP 200 
100-             bind (parse_if_OK ),
101+             bind (parse_if_ok ),
101102            # load successful response as json 
102103            map_ (json .loads ),
103104        )
@@ -134,11 +135,13 @@ def get_dummy_dataset(
134135            # post to the validated body to the corresponding endpoint 
135136            lambda  body : self .http_client .post ("get_dummy_dataset" , body ),
136137            # parse reply if HTTP 200 
137-             bind (parse_if_OK ),
138+             bind (parse_if_ok ),
138139            # load successful response as json 
139140            map_ (DummyDsResponse .model_validate_json ),
140141            map_ (
141-                 lambda  dummyDsRes : pl .from_pandas (dummyDsRes .dummy_df ).lazy () if  lazy  else  dummyDsRes .dummy_df 
142+                 lambda  dummy_ds_res : (
143+                     pl .from_pandas (dummy_ds_res .dummy_df ).lazy () if  lazy  else  dummy_ds_res .dummy_df 
144+                 )
142145            ),
143146        )
144147
@@ -178,7 +181,7 @@ def get_initial_budget(self) -> IOResultE[InitialBudgetResponse]:
178181            # post to the validated body to the corresponding endpoint 
179182            lambda  body : self .http_client .post ("get_initial_budget" , body ),
180183            # parse reply if HTTP 200 
181-             bind (parse_if_OK ),
184+             bind (parse_if_ok ),
182185            # build Budget Response from successful json payload 
183186            map_ (InitialBudgetResponse .model_validate_json ),
184187        )
@@ -198,7 +201,7 @@ def get_total_spent_budget(self) -> IOResultE[SpentBudgetResponse]:
198201            # post to the validated body to the corresponding endpoint 
199202            lambda  body : self .http_client .post ("get_total_spent_budget" , body ),
200203            # parse reply if HTTP 200 
201-             bind (parse_if_OK ),
204+             bind (parse_if_ok ),
202205            # build Budget Response from successful json payload 
203206            map_ (SpentBudgetResponse .model_validate_json ),
204207        )
@@ -218,7 +221,7 @@ def get_remaining_budget(self) -> IOResultE[RemainingBudgetResponse]:
218221            # post to the validated body to the corresponding endpoint 
219222            lambda  body : self .http_client .post ("get_remaining_budget" , body ),
220223            # parse reply if HTTP 200 
221-             bind (parse_if_OK ),
224+             bind (parse_if_ok ),
222225            # build Budget Response from successful json payload 
223226            map_ (RemainingBudgetResponse .model_validate_json ),
224227        )
@@ -269,7 +272,7 @@ def post_processes_queries(queries: list[dict]) -> list[dict]:
269272            # post to the validated body to the corresponding endpoint 
270273            lambda  body : self .http_client .post ("get_previous_queries" , body ),
271274            # parse reply if HTTP 200 
272-             bind (parse_if_OK ),
275+             bind (parse_if_ok ),
273276            bind (lambda  content : json .loads (content )["previous_queries" ]),
274277            post_processes_queries ,
275278        )
0 commit comments