Skip to content

Commit 94bc9db

Browse files
chore: rename MutationBatcher table argument to target (#1169)
1 parent ca71261 commit 94bc9db

File tree

5 files changed

+86
-68
lines changed

5 files changed

+86
-68
lines changed

UPGRADING.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# 3.0.0 Migration Guide
2+
3+
The v3.0.0 release of `google-cloud-bigtable` deprecates the previous `google.cloud.bigtable.Client` class in favor of distinct clients for the two API surfaces, supporting both sync and async calls:
4+
- Data API:
5+
- `google.cloud.bigtable.data.BigtableDataClient`
6+
- `google.cloud.bigtable.data.BigtableDataClientAsync`
7+
- Admin API:
8+
- `google.cloud.bigtable.admin.BigtableInstanceAdminAsyncClient`
9+
- `google.cloud.bigtable.admin.BigtableInstanceAdminClient`
10+
- `google.cloud.bigtable.admin.BigtableTableAdminClient`
11+
- `google.cloud.bigtable.admin.BigtableTableAdminAsyncClient`
12+
13+
The deprecated client will remain available as an alternative API surface, which internally delegates calls to the respective new clients. For most users, existing code will continue to work as before. But there may be some breaking changes associated with this update, which are detailed in this document.
14+
15+
If you experience technical issues or have questions, please file an [issue](https://github.com/googleapis/python-bigtable/issues).
16+
17+
## Breaking Changes
18+
- **[MutationBatcher](https://github.com/googleapis/python-bigtable/blob/main/google/cloud/bigtable/data/_sync_autogen/mutations_batcher.py#L151) and [MutationBatcherAsync](https://github.com/googleapis/python-bigtable/blob/main/google/cloud/bigtable/data/_async/mutations_batcher.py#L182)'s `table` argument was renamed to `target`**, since it also supports [Authorized View](https://github.com/googleapis/python-bigtable/pull/1034) instances. This matches the naming used in other classes (PR: https://github.com/googleapis/python-bigtable/pull/1153)

google/cloud/bigtable/data/_async/mutations_batcher.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ class MutationsBatcherAsync:
193193
- when batcher is closed or destroyed
194194
195195
Args:
196-
table: table or autrhorized_view used to preform rpc calls
196+
target: table or authorized_view used to preform rpc calls
197197
flush_interval: Automatically flush every flush_interval seconds.
198198
If None, no time-based flushing is performed.
199199
flush_limit_mutation_count: Flush immediately after flush_limit_mutation_count
@@ -212,7 +212,7 @@ class MutationsBatcherAsync:
212212

213213
def __init__(
214214
self,
215-
table: TargetType,
215+
target: TargetType,
216216
*,
217217
flush_interval: float | None = 5,
218218
flush_limit_mutation_count: int | None = 1000,
@@ -225,14 +225,14 @@ def __init__(
225225
| TABLE_DEFAULT = TABLE_DEFAULT.MUTATE_ROWS,
226226
):
227227
self._operation_timeout, self._attempt_timeout = _get_timeouts(
228-
batch_operation_timeout, batch_attempt_timeout, table
228+
batch_operation_timeout, batch_attempt_timeout, target
229229
)
230230
self._retryable_errors: list[type[Exception]] = _get_retryable_errors(
231-
batch_retryable_errors, table
231+
batch_retryable_errors, target
232232
)
233233

234234
self._closed = CrossSync.Event()
235-
self._target = table
235+
self._target = target
236236
self._staged_entries: list[RowMutationEntry] = []
237237
self._staged_count, self._staged_bytes = 0, 0
238238
self._flow_control = CrossSync._FlowControl(
@@ -374,7 +374,7 @@ async def _execute_mutate_rows(
374374
Args:
375375
batch: list of RowMutationEntry objects to send to server
376376
timeout: timeout in seconds. Used as operation_timeout and attempt_timeout.
377-
If not given, will use table defaults
377+
If not given, will use target defaults
378378
Returns:
379379
list[FailedMutationEntryError]:
380380
list of FailedMutationEntryError objects for mutations that failed.

google/cloud/bigtable/data/_sync_autogen/mutations_batcher.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ class MutationsBatcher:
162162
- when batcher is closed or destroyed
163163
164164
Args:
165-
table: table or autrhorized_view used to preform rpc calls
165+
target: table or authorized_view used to preform rpc calls
166166
flush_interval: Automatically flush every flush_interval seconds.
167167
If None, no time-based flushing is performed.
168168
flush_limit_mutation_count: Flush immediately after flush_limit_mutation_count
@@ -181,7 +181,7 @@ class MutationsBatcher:
181181

182182
def __init__(
183183
self,
184-
table: TargetType,
184+
target: TargetType,
185185
*,
186186
flush_interval: float | None = 5,
187187
flush_limit_mutation_count: int | None = 1000,
@@ -194,13 +194,13 @@ def __init__(
194194
| TABLE_DEFAULT = TABLE_DEFAULT.MUTATE_ROWS,
195195
):
196196
(self._operation_timeout, self._attempt_timeout) = _get_timeouts(
197-
batch_operation_timeout, batch_attempt_timeout, table
197+
batch_operation_timeout, batch_attempt_timeout, target
198198
)
199199
self._retryable_errors: list[type[Exception]] = _get_retryable_errors(
200-
batch_retryable_errors, table
200+
batch_retryable_errors, target
201201
)
202202
self._closed = CrossSync._Sync_Impl.Event()
203-
self._target = table
203+
self._target = target
204204
self._staged_entries: list[RowMutationEntry] = []
205205
(self._staged_count, self._staged_bytes) = (0, 0)
206206
self._flow_control = CrossSync._Sync_Impl._FlowControl(
@@ -319,7 +319,7 @@ def _execute_mutate_rows(
319319
Args:
320320
batch: list of RowMutationEntry objects to send to server
321321
timeout: timeout in seconds. Used as operation_timeout and attempt_timeout.
322-
If not given, will use table defaults
322+
If not given, will use target defaults
323323
Returns:
324324
list[FailedMutationEntryError]:
325325
list of FailedMutationEntryError objects for mutations that failed.

tests/unit/data/_async/test_mutations_batcher.py

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -304,22 +304,22 @@ class TestMutationsBatcherAsync:
304304
def _get_target_class(self):
305305
return CrossSync.MutationsBatcher
306306

307-
def _make_one(self, table=None, **kwargs):
307+
def _make_one(self, target=None, **kwargs):
308308
from google.api_core.exceptions import DeadlineExceeded
309309
from google.api_core.exceptions import ServiceUnavailable
310310

311-
if table is None:
312-
table = mock.Mock()
313-
table._request_path = {"table_name": "table"}
314-
table.app_profile_id = None
315-
table.default_mutate_rows_operation_timeout = 10
316-
table.default_mutate_rows_attempt_timeout = 10
317-
table.default_mutate_rows_retryable_errors = (
311+
if target is None:
312+
target = mock.Mock()
313+
target._request_path = {"table_name": "table"}
314+
target.app_profile_id = None
315+
target.default_mutate_rows_operation_timeout = 10
316+
target.default_mutate_rows_attempt_timeout = 10
317+
target.default_mutate_rows_retryable_errors = (
318318
DeadlineExceeded,
319319
ServiceUnavailable,
320320
)
321321

322-
return self._get_target_class()(table, **kwargs)
322+
return self._get_target_class()(target, **kwargs)
323323

324324
@staticmethod
325325
def _make_mutation(count=1, size=1):
@@ -333,12 +333,12 @@ async def test_ctor_defaults(self):
333333
with mock.patch.object(
334334
self._get_target_class(), "_timer_routine", return_value=CrossSync.Future()
335335
) as flush_timer_mock:
336-
table = mock.Mock()
337-
table.default_mutate_rows_operation_timeout = 10
338-
table.default_mutate_rows_attempt_timeout = 8
339-
table.default_mutate_rows_retryable_errors = [Exception]
340-
async with self._make_one(table) as instance:
341-
assert instance._target == table
336+
target = mock.Mock()
337+
target.default_mutate_rows_operation_timeout = 10
338+
target.default_mutate_rows_attempt_timeout = 8
339+
target.default_mutate_rows_retryable_errors = [Exception]
340+
async with self._make_one(target) as instance:
341+
assert instance._target == target
342342
assert instance.closed is False
343343
assert instance._flush_jobs == set()
344344
assert len(instance._staged_entries) == 0
@@ -353,15 +353,15 @@ async def test_ctor_defaults(self):
353353
assert instance._entries_processed_since_last_raise == 0
354354
assert (
355355
instance._operation_timeout
356-
== table.default_mutate_rows_operation_timeout
356+
== target.default_mutate_rows_operation_timeout
357357
)
358358
assert (
359359
instance._attempt_timeout
360-
== table.default_mutate_rows_attempt_timeout
360+
== target.default_mutate_rows_attempt_timeout
361361
)
362362
assert (
363363
instance._retryable_errors
364-
== table.default_mutate_rows_retryable_errors
364+
== target.default_mutate_rows_retryable_errors
365365
)
366366
await CrossSync.yield_to_event_loop()
367367
assert flush_timer_mock.call_count == 1
@@ -374,7 +374,7 @@ async def test_ctor_explicit(self):
374374
with mock.patch.object(
375375
self._get_target_class(), "_timer_routine", return_value=CrossSync.Future()
376376
) as flush_timer_mock:
377-
table = mock.Mock()
377+
target = mock.Mock()
378378
flush_interval = 20
379379
flush_limit_count = 17
380380
flush_limit_bytes = 19
@@ -384,7 +384,7 @@ async def test_ctor_explicit(self):
384384
attempt_timeout = 2
385385
retryable_errors = [Exception]
386386
async with self._make_one(
387-
table,
387+
target,
388388
flush_interval=flush_interval,
389389
flush_limit_mutation_count=flush_limit_count,
390390
flush_limit_bytes=flush_limit_bytes,
@@ -394,7 +394,7 @@ async def test_ctor_explicit(self):
394394
batch_attempt_timeout=attempt_timeout,
395395
batch_retryable_errors=retryable_errors,
396396
) as instance:
397-
assert instance._target == table
397+
assert instance._target == target
398398
assert instance.closed is False
399399
assert instance._flush_jobs == set()
400400
assert len(instance._staged_entries) == 0
@@ -426,20 +426,20 @@ async def test_ctor_no_flush_limits(self):
426426
with mock.patch.object(
427427
self._get_target_class(), "_timer_routine", return_value=CrossSync.Future()
428428
) as flush_timer_mock:
429-
table = mock.Mock()
430-
table.default_mutate_rows_operation_timeout = 10
431-
table.default_mutate_rows_attempt_timeout = 8
432-
table.default_mutate_rows_retryable_errors = ()
429+
target = mock.Mock()
430+
target.default_mutate_rows_operation_timeout = 10
431+
target.default_mutate_rows_attempt_timeout = 8
432+
target.default_mutate_rows_retryable_errors = ()
433433
flush_interval = None
434434
flush_limit_count = None
435435
flush_limit_bytes = None
436436
async with self._make_one(
437-
table,
437+
target,
438438
flush_interval=flush_interval,
439439
flush_limit_mutation_count=flush_limit_count,
440440
flush_limit_bytes=flush_limit_bytes,
441441
) as instance:
442-
assert instance._target == table
442+
assert instance._target == target
443443
assert instance.closed is False
444444
assert instance._staged_entries == []
445445
assert len(instance._oldest_exceptions) == 0
@@ -480,7 +480,7 @@ def test_default_argument_consistency(self):
480480
batcher_init_signature = dict(
481481
inspect.signature(self._get_target_class()).parameters
482482
)
483-
batcher_init_signature.pop("table")
483+
batcher_init_signature.pop("target")
484484
# both should have same number of arguments
485485
assert len(get_batcher_signature.keys()) == len(batcher_init_signature.keys())
486486
assert len(get_batcher_signature) == 8 # update if expected params change

tests/unit/data/_sync_autogen/test_mutations_batcher.py

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -254,21 +254,21 @@ class TestMutationsBatcher:
254254
def _get_target_class(self):
255255
return CrossSync._Sync_Impl.MutationsBatcher
256256

257-
def _make_one(self, table=None, **kwargs):
257+
def _make_one(self, target=None, **kwargs):
258258
from google.api_core.exceptions import DeadlineExceeded
259259
from google.api_core.exceptions import ServiceUnavailable
260260

261-
if table is None:
262-
table = mock.Mock()
263-
table._request_path = {"table_name": "table"}
264-
table.app_profile_id = None
265-
table.default_mutate_rows_operation_timeout = 10
266-
table.default_mutate_rows_attempt_timeout = 10
267-
table.default_mutate_rows_retryable_errors = (
261+
if target is None:
262+
target = mock.Mock()
263+
target._request_path = {"table_name": "table"}
264+
target.app_profile_id = None
265+
target.default_mutate_rows_operation_timeout = 10
266+
target.default_mutate_rows_attempt_timeout = 10
267+
target.default_mutate_rows_retryable_errors = (
268268
DeadlineExceeded,
269269
ServiceUnavailable,
270270
)
271-
return self._get_target_class()(table, **kwargs)
271+
return self._get_target_class()(target, **kwargs)
272272

273273
@staticmethod
274274
def _make_mutation(count=1, size=1):
@@ -283,12 +283,12 @@ def test_ctor_defaults(self):
283283
"_timer_routine",
284284
return_value=CrossSync._Sync_Impl.Future(),
285285
) as flush_timer_mock:
286-
table = mock.Mock()
287-
table.default_mutate_rows_operation_timeout = 10
288-
table.default_mutate_rows_attempt_timeout = 8
289-
table.default_mutate_rows_retryable_errors = [Exception]
290-
with self._make_one(table) as instance:
291-
assert instance._target == table
286+
target = mock.Mock()
287+
target.default_mutate_rows_operation_timeout = 10
288+
target.default_mutate_rows_attempt_timeout = 8
289+
target.default_mutate_rows_retryable_errors = [Exception]
290+
with self._make_one(target) as instance:
291+
assert instance._target == target
292292
assert instance.closed is False
293293
assert instance._flush_jobs == set()
294294
assert len(instance._staged_entries) == 0
@@ -303,15 +303,15 @@ def test_ctor_defaults(self):
303303
assert instance._entries_processed_since_last_raise == 0
304304
assert (
305305
instance._operation_timeout
306-
== table.default_mutate_rows_operation_timeout
306+
== target.default_mutate_rows_operation_timeout
307307
)
308308
assert (
309309
instance._attempt_timeout
310-
== table.default_mutate_rows_attempt_timeout
310+
== target.default_mutate_rows_attempt_timeout
311311
)
312312
assert (
313313
instance._retryable_errors
314-
== table.default_mutate_rows_retryable_errors
314+
== target.default_mutate_rows_retryable_errors
315315
)
316316
CrossSync._Sync_Impl.yield_to_event_loop()
317317
assert flush_timer_mock.call_count == 1
@@ -325,7 +325,7 @@ def test_ctor_explicit(self):
325325
"_timer_routine",
326326
return_value=CrossSync._Sync_Impl.Future(),
327327
) as flush_timer_mock:
328-
table = mock.Mock()
328+
target = mock.Mock()
329329
flush_interval = 20
330330
flush_limit_count = 17
331331
flush_limit_bytes = 19
@@ -335,7 +335,7 @@ def test_ctor_explicit(self):
335335
attempt_timeout = 2
336336
retryable_errors = [Exception]
337337
with self._make_one(
338-
table,
338+
target,
339339
flush_interval=flush_interval,
340340
flush_limit_mutation_count=flush_limit_count,
341341
flush_limit_bytes=flush_limit_bytes,
@@ -345,7 +345,7 @@ def test_ctor_explicit(self):
345345
batch_attempt_timeout=attempt_timeout,
346346
batch_retryable_errors=retryable_errors,
347347
) as instance:
348-
assert instance._target == table
348+
assert instance._target == target
349349
assert instance.closed is False
350350
assert instance._flush_jobs == set()
351351
assert len(instance._staged_entries) == 0
@@ -378,20 +378,20 @@ def test_ctor_no_flush_limits(self):
378378
"_timer_routine",
379379
return_value=CrossSync._Sync_Impl.Future(),
380380
) as flush_timer_mock:
381-
table = mock.Mock()
382-
table.default_mutate_rows_operation_timeout = 10
383-
table.default_mutate_rows_attempt_timeout = 8
384-
table.default_mutate_rows_retryable_errors = ()
381+
target = mock.Mock()
382+
target.default_mutate_rows_operation_timeout = 10
383+
target.default_mutate_rows_attempt_timeout = 8
384+
target.default_mutate_rows_retryable_errors = ()
385385
flush_interval = None
386386
flush_limit_count = None
387387
flush_limit_bytes = None
388388
with self._make_one(
389-
table,
389+
target,
390390
flush_interval=flush_interval,
391391
flush_limit_mutation_count=flush_limit_count,
392392
flush_limit_bytes=flush_limit_bytes,
393393
) as instance:
394-
assert instance._target == table
394+
assert instance._target == target
395395
assert instance.closed is False
396396
assert instance._staged_entries == []
397397
assert len(instance._oldest_exceptions) == 0
@@ -428,7 +428,7 @@ def test_default_argument_consistency(self):
428428
batcher_init_signature = dict(
429429
inspect.signature(self._get_target_class()).parameters
430430
)
431-
batcher_init_signature.pop("table")
431+
batcher_init_signature.pop("target")
432432
assert len(get_batcher_signature.keys()) == len(batcher_init_signature.keys())
433433
assert len(get_batcher_signature) == 8
434434
assert set(get_batcher_signature.keys()) == set(batcher_init_signature.keys())

0 commit comments

Comments
 (0)