1616# This file is automatically generated by CrossSync. Do not edit manually.
1717
1818from __future__ import annotations
19- from typing import Sequence , TYPE_CHECKING , cast
19+ from typing import Callable , Optional , Sequence , TYPE_CHECKING , cast
2020import atexit
2121import warnings
2222from collections import deque
2525from google .cloud .bigtable .data .exceptions import FailedMutationEntryError
2626from google .cloud .bigtable .data ._helpers import _get_retryable_errors
2727from google .cloud .bigtable .data ._helpers import _get_timeouts
28+ from google .cloud .bigtable .data ._helpers import (
29+ _populate_statuses_from_mutations_exception_group ,
30+ )
2831from google .cloud .bigtable .data ._helpers import TABLE_DEFAULT
2932from google .cloud .bigtable .data .mutations import _MUTATE_ROWS_REQUEST_MUTATION_LIMIT
3033from google .cloud .bigtable .data .mutations import Mutation
3134from google .cloud .bigtable .data ._cross_sync import CrossSync
35+ from google .rpc import code_pb2
36+ from google .rpc import status_pb2
3237
3338if TYPE_CHECKING :
3439 from google .cloud .bigtable .data .mutations import RowMutationEntry
@@ -192,6 +197,7 @@ def __init__(
192197 batch_attempt_timeout : float | None | TABLE_DEFAULT = TABLE_DEFAULT .MUTATE_ROWS ,
193198 batch_retryable_errors : Sequence [type [Exception ]]
194199 | TABLE_DEFAULT = TABLE_DEFAULT .MUTATE_ROWS ,
200+ _batch_completed_callback : Optional [Callable [list [status_pb2 .Status ]]] = None ,
195201 ):
196202 (self ._operation_timeout , self ._attempt_timeout ) = _get_timeouts (
197203 batch_operation_timeout , batch_attempt_timeout , target
@@ -233,6 +239,7 @@ def __init__(
233239 self ._newest_exceptions : deque [Exception ] = deque (
234240 maxlen = self ._exception_list_limit
235241 )
242+ self ._user_batch_completed_callback = _batch_completed_callback
236243 atexit .register (self ._on_exit )
237244
238245 def _timer_routine (self , interval : float | None ) -> None :
@@ -324,6 +331,7 @@ def _execute_mutate_rows(
324331 list[FailedMutationEntryError]:
325332 list of FailedMutationEntryError objects for mutations that failed.
326333 FailedMutationEntryError objects will not contain index information"""
334+ statuses = [status_pb2 .Status (code = code_pb2 .Code .OK )] * len (batch )
327335 try :
328336 operation = CrossSync ._Sync_Impl ._MutateRowsOperation (
329337 self ._target .client ._gapic_client ,
@@ -335,11 +343,14 @@ def _execute_mutate_rows(
335343 )
336344 operation .start ()
337345 except MutationsExceptionGroup as e :
346+ _populate_statuses_from_mutations_exception_group (statuses , e )
338347 for subexc in e .exceptions :
339348 subexc .index = None
340349 return list (e .exceptions )
341350 finally :
342351 self ._flow_control .remove_from_flow (batch )
352+ if self ._user_batch_completed_callback :
353+ self ._user_batch_completed_callback (statuses )
343354 return []
344355
345356 def _add_exceptions (self , excs : list [Exception ]):
0 commit comments