1717import warnings
1818from typing import Set
1919
20+ < << << << ours
2021from google .api_core .exceptions import (
2122 Aborted ,
2223 DeadlineExceeded ,
2526 NotFound ,
2627 ServiceUnavailable ,
2728)
29+ == == == =
30+ from google .api_core .exceptions import Aborted
31+ from google .api_core .exceptions import DeadlineExceeded
32+ from google .api_core .exceptions import NotFound
33+ from google .api_core .exceptions import ServiceUnavailable
34+ from google .api_core .exceptions import InternalServerError
35+ > >> >> >> theirs
2836from google .api_core .gapic_v1 .method import DEFAULT
2937from google .api_core .retry import Retry , if_exception_type
3038from google .cloud ._helpers import _to_bytes # type: ignore
3947)
4048from google .cloud .bigtable .column_family import ColumnFamily , _gc_rule_from_pb
4149from google .cloud .bigtable .data ._helpers import TABLE_DEFAULT
50+ < << << << ours
4251from google .cloud .bigtable .data .exceptions import (
4352 MutationsExceptionGroup ,
4453 RetryExceptionGroup ,
4554)
4655from google .cloud .bigtable .data .mutations import RowMutationEntry
4756from google .cloud .bigtable .data .read_rows_query import ReadRowsQuery
57+ == == == =
58+ from google .cloud .bigtable .data ._helpers import (
59+ _get_statuses_from_mutations_exception_group ,
60+ )
61+ from google .cloud .bigtable .data .exceptions import MutationsExceptionGroup
62+ from google .cloud .bigtable .data .mutations import RowMutationEntry
63+ from google .cloud .bigtable .data .read_rows_query import ReadRowsQuery
64+ from google .cloud .bigtable .batcher import MutationsBatcher
65+ from google .cloud .bigtable .batcher import FLUSH_COUNT , MAX_MUTATION_SIZE
66+ > >> >> >> theirs
4867from google .cloud .bigtable .encryption_info import EncryptionInfo
4968from google .cloud .bigtable .policy import Policy
5069from google .cloud .bigtable .row import (
@@ -796,9 +815,6 @@ def mutate_rows(self, rows, retry=DEFAULT_RETRY, timeout=DEFAULT):
796815 % (row .row_key , row .table .name , self .name )
797816 )
798817 mutation_entries .append (RowMutationEntry (row .row_key , row ._get_mutations ()))
799- return_statuses = [
800- status_pb2 .Status (code = code_pb2 .OK ) for _ in range (len (mutation_entries ))
801- ] # By default, return status OKs for everything
802818
803819 try :
804820 self ._table_impl .bulk_mutate_rows (
@@ -808,41 +824,15 @@ def mutate_rows(self, rows, retry=DEFAULT_RETRY, timeout=DEFAULT):
808824 retryable_errors = retryable_errors ,
809825 )
810826 except MutationsExceptionGroup as mut_exc_group :
811- # We exception handle as follows:
812- #
813- # 1. Each exception in the error group is a FailedMutationEntryError, and its
814- # cause is either a singular exception or a RetryExceptionGroup consisting of
815- # multiple exceptions.
816- #
817- # 2. In the case of a singular exception, if the error does not have a gRPC status
818- # code, we return a status code of UNKNOWN.
819- #
820- # 3. In the case of a RetryExceptionGroup, we use terminal exception in the exception
821- # group and process that.
822- for error in mut_exc_group .exceptions :
823- cause = error .__cause__
824- if isinstance (cause , RetryExceptionGroup ):
825- return_statuses [error .index ] = self ._get_status (
826- cause .exceptions [- 1 ]
827- )
828- else :
829- return_statuses [error .index ] = self ._get_status (cause )
830-
831- return return_statuses
832-
833- @staticmethod
834- def _get_status (error ):
835- if isinstance (error , GoogleAPICallError ) and error .grpc_status_code is not None :
836- return status_pb2 .Status (
837- code = error .grpc_status_code .value [0 ],
838- message = error .message ,
839- details = error .details ,
827+ return_statuses = _get_statuses_from_mutations_exception_group (
828+ mut_exc_group , len (mutation_entries )
829+ )
830+ else :
831+ return_statuses = [status_pb2 .Status (code = code_pb2 .Code .OK )] * len (
832+ mutation_entries
840833 )
841834
842- return status_pb2 .Status (
843- code = code_pb2 .UNKNOWN ,
844- message = str (error ),
845- )
835+ return return_statuses
846836
847837 def sample_row_keys (self ):
848838 """Read a sample of row keys in the table.
0 commit comments