@@ -13,15 +13,15 @@ class BatchRequestContentCollection:
1313 def __init__ (self ) -> None :
1414 """
1515 Initializes a new instance of the BatchRequestContentCollection class.
16-
17-
16+
17+
1818 """
1919 self .max_requests_per_batch = BatchRequestContent .MAX_REQUESTS
2020 self .batches : List [BatchRequestContent ] = []
2121 self .current_batch : BatchRequestContent = BatchRequestContent ()
2222
2323 def add_batch_request_item (self , request : BatchRequestItem ) -> None :
24- """
24+ """
2525 Adds a request item to the collection.
2626 Args:
2727 request (BatchRequestItem): The request item to add.
@@ -33,17 +33,15 @@ def add_batch_request_item(self, request: BatchRequestItem) -> None:
3333 self .batches .append (self .current_batch )
3434
3535 def remove_batch_request_item (self , request_id : str ) -> None :
36- """
36+ """
3737 Removes a request item from the collection.
3838 Args:
3939 request_id (str): The ID of the request item to remove.
4040 """
4141 for batch in self .batches :
4242 if request_id in batch .requests :
43- del batch .requests [ request_id ]
43+ batch .remove ( request_id )
4444 return
45- if request_id in self .current_batch .requests :
46- del self .current_batch .requests [request_id ]
4745
4846 def new_batch_with_failed_requests (self ) -> Optional [BatchRequestContent ]:
4947 """
@@ -55,9 +53,9 @@ def new_batch_with_failed_requests(self) -> Optional[BatchRequestContent]:
5553 batch_with_failed_responses : Optional [BatchRequestContent ] = BatchRequestContent ()
5654 for batch in self .batches :
5755 for request in batch .requests :
58- if request .status_code not in [200 , 201 , 202 , 203 , 204 , 205 , 206 , 207 , 208 , 226 ]:
56+ if request .status_code not in [200 , 201 , 202 , 203 , 204 , 205 , 206 , 207 , 208 , 226 ]: # type: ignore # Method should be deprecated
5957 if batch_with_failed_responses is not None :
60- batch_with_failed_responses .add_request (request .id , request )
58+ batch_with_failed_responses .add_request (request .id , request ) # type: ignore # Bug. Method should be deprecated
6159 else :
6260 raise ValueError ("batch_with_failed_responses is None" )
6361 return batch_with_failed_responses
@@ -68,9 +66,6 @@ def get_batch_requests_for_execution(self) -> List[BatchRequestContent]:
6866 Returns:
6967 List[BatchRequestContent]: The batch requests for execution.
7068 """
71- # if not self.current_batch.is_finalized:
72- # self.current_batch.finalize()
73- # self.batches.append(self.current_batch)
7469 return self .batches
7570
7671 def serialize (self , writer : SerializationWriter ) -> None :
@@ -80,5 +75,3 @@ def serialize(self, writer: SerializationWriter) -> None:
8075 writer: Serialization writer to use to serialize this model
8176 """
8277 pass
83- # print(f"serializing {self.batches}")
84- # writer.write_collection_of_object_values("requests", self.batches)
0 commit comments