@@ -576,10 +576,13 @@ def _await_elements(
576576 response_number ,
577577 )
578578 successful_responses .append (res )
579- if self .cache_tmp_data_feature :
580- elements .append (load_elements_from_response (res ))
581- else :
582- elements .append (res .json ())
579+ if res .headers ["Content-Type" ] == "application/json" :
580+ if self .cache_tmp_data_feature :
581+ elements .append (load_elements_from_response (res ))
582+ else :
583+ elements .append (res .json ())
584+ else : # -- Response contains csv data
585+ elements .append (res .content )
583586 else :
584587 error_message = f"Failed to partition set { response_number } ."
585588
@@ -591,7 +594,12 @@ def _await_elements(
591594
592595 self .api_successful_responses [operation_id ] = successful_responses
593596 self .api_failed_responses [operation_id ] = failed_responses
594- flattened_elements = [element for sublist in elements for element in sublist ]
597+ flattened_elements = []
598+ for sublist in elements :
599+ if isinstance (sublist , list ):
600+ flattened_elements .extend (sublist )
601+ else :
602+ flattened_elements .append (sublist )
595603 return flattened_elements
596604
597605 def after_success (
@@ -613,7 +621,7 @@ def after_success(
613621 """
614622 # Grab the correct id out of the dummy request
615623 operation_id = response .request .headers .get ("operation_id" )
616-
624+ # breakpoint();
617625 elements = self ._await_elements (operation_id )
618626
619627 # if fails are disallowed, return the first failed response
0 commit comments