Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: reduce public api surface #820

Merged
merged 228 commits into from Aug 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
228 commits
Select commit Hold shift + click to select a range
748310b
chore(deps): Update nox in .kokoro/requirements.in [autoapprove] (#750)
gcf-owl-bot[bot] Mar 16, 2023
45d3e43
docs: Fix formatting of request arg in docstring (#756)
gcf-owl-bot[bot] Mar 23, 2023
505273b
fix: Pass the "retry" when calling read_rows. (#759)
Mariatta Mar 30, 2023
efe332c
chore(samples): Fixed a typo in the readme (#760)
shweta345 Apr 5, 2023
18b8f18
chore(deps): update all dependencies (#746)
renovate-bot Apr 6, 2023
128b4e1
docs: fix delete from column family example (#764)
billyjacobson Apr 14, 2023
b5d10d6
chore(deps): update all dependencies (#763)
renovate-bot Apr 18, 2023
1d02154
added initial implementation of mutate_rows
daniel-sanche Apr 24, 2023
ab63cba
implemented mutation models
daniel-sanche Apr 24, 2023
cf9daa5
added retries to mutate_row
daniel-sanche Apr 24, 2023
1247da4
return exception group if possible
daniel-sanche Apr 24, 2023
3b3ed8c
check for idempotence
daniel-sanche Apr 24, 2023
5d20037
initial implementation for bulk_mutations
daniel-sanche Apr 24, 2023
3d322a1
include successes in bulk mutation error message
daniel-sanche Apr 24, 2023
a31232b
fixed style checks
daniel-sanche Apr 24, 2023
8da2d65
added basic system tests
daniel-sanche Apr 24, 2023
2b89d9c
added unit tests for mutate_row
daniel-sanche Apr 25, 2023
47c5985
ran blacken
daniel-sanche Apr 25, 2023
38fdcd7
improved exceptions
daniel-sanche Apr 25, 2023
504d2d8
added bulk_mutate_rows unit tests
daniel-sanche Apr 25, 2023
b16067f
ran blacken
daniel-sanche Apr 25, 2023
3ab1405
support __new___ for exceptions for python3.11+
daniel-sanche Apr 25, 2023
0a6c0c6
added exception unit tests
daniel-sanche Apr 25, 2023
ec043cf
makde exceptions tuple
daniel-sanche Apr 26, 2023
518530e
got exceptions to print consistently across versions
daniel-sanche Apr 26, 2023
9624729
added test for 311 rich traceback
daniel-sanche Apr 27, 2023
3087081
moved retryable row mutations to new file
daniel-sanche Apr 27, 2023
9df588f
use index map
daniel-sanche Apr 27, 2023
7ed8be3
added docstring
daniel-sanche Apr 27, 2023
2536cc4
added predicate check to failed mutations
daniel-sanche Apr 27, 2023
1f6875c
added _mutate_rows tests
daniel-sanche Apr 27, 2023
1ea24e6
improved client tests
daniel-sanche Apr 27, 2023
25ca2d2
refactored to loop by raising exception
daniel-sanche Apr 28, 2023
c0787db
refactored retry deadline logic into shared wrapper
daniel-sanche Apr 28, 2023
3ed5c3d
ran black
daniel-sanche Apr 28, 2023
a91fbcb
pulled in table default timeouts
daniel-sanche Apr 28, 2023
df8a058
added tests for shared deadline parsing function
daniel-sanche Apr 28, 2023
b866b57
added tests for mutation models
daniel-sanche Apr 28, 2023
54a4d43
fixed linter errors
daniel-sanche Apr 28, 2023
bd51dc4
added tests for BulkMutationsEntry
daniel-sanche Apr 28, 2023
921b05a
improved mutations documentation
daniel-sanche Apr 28, 2023
53f7ad2
added basic implementation for batcher
daniel-sanche May 1, 2023
f65b2e5
added flush timer
daniel-sanche May 1, 2023
7051cd2
added flush on size and count
daniel-sanche May 1, 2023
9731f4c
improved queue
daniel-sanche May 1, 2023
34bf655
raise exceptions on close
daniel-sanche May 1, 2023
582457a
added args for flush
daniel-sanche May 1, 2023
eeb24a5
improved closing logic
daniel-sanche May 1, 2023
110cd96
use custom queue type to track size and count
daniel-sanche May 1, 2023
375a77d
added flow control
daniel-sanche May 1, 2023
5f9fa3f
added comments and todos
daniel-sanche May 1, 2023
e63cfc2
allow None for batcher limits
daniel-sanche May 2, 2023
d5e15aa
strip indices from exceptions
daniel-sanche May 2, 2023
82ea61f
refactored mutate_rows logic into helper function
daniel-sanche May 2, 2023
fa42b86
implemented callbacks for mutate_rows
daniel-sanche May 2, 2023
a47aeda
Merge branch 'mutate_rows' into mutate_rows_batch
daniel-sanche May 2, 2023
ee23721
release locks as mutations are completed, instead of waiting until end
daniel-sanche May 2, 2023
b69cc96
refacotr row processing
daniel-sanche May 2, 2023
9e1850c
FlowControl returns exceptions rather than raises them
daniel-sanche May 2, 2023
9e4d013
raise previous exceptions on flush with flag set
daniel-sanche May 2, 2023
2c7ec9c
disallow empty bulk mutation entries
daniel-sanche May 3, 2023
5c4f739
simplified staged mutation store
daniel-sanche May 3, 2023
fa4947f
ran blacken
daniel-sanche May 3, 2023
914b24b
replaced semaphores with condition
daniel-sanche May 3, 2023
8bda651
fixed mypy issues
daniel-sanche May 3, 2023
742194b
added raise_exceptions fn
daniel-sanche May 3, 2023
45fe1f5
fixed failing tests
daniel-sanche May 3, 2023
d8f3a4d
added skeleton for tests
daniel-sanche May 3, 2023
171fea6
feat: publish RateLimitInfo and FeatureFlag protos (#768)
gcf-owl-bot[bot] May 4, 2023
7faebc0
improved and tested flow control
daniel-sanche May 4, 2023
10da89a
refactored flushes to run sequentially
daniel-sanche May 5, 2023
0eca65e
added batcher tests
daniel-sanche May 5, 2023
2532b63
ran blacken
daniel-sanche May 5, 2023
8313b57
added additional tests
daniel-sanche May 5, 2023
01a16f3
made exceptions into a tuple
daniel-sanche May 5, 2023
da9b6cf
Merge branch 'mutate_rows' into mutate_rows_batch
daniel-sanche May 5, 2023
b7d3fcf
added warning for unflushed mutation entries
daniel-sanche May 5, 2023
7521a61
Feat: Threaded MutationsBatcher (#722)
Mariatta May 10, 2023
8f9de8d
chore(main): release 2.18.0 (#757)
release-please[bot] May 10, 2023
a767cff
fix: Revert "Feat: Threaded MutationsBatcher" (#773)
mutianf May 11, 2023
a4e7325
Revert "fix: Revert "Feat: Threaded MutationsBatcher" (#773)" (#775)
mutianf May 11, 2023
9e35ad2
chore(main): release 2.18.1 (#774)
release-please[bot] May 16, 2023
6140acb
remove aborted from retryable errors
daniel-sanche May 22, 2023
36ba2b6
improved SetCell mutation
daniel-sanche May 22, 2023
b3c9017
fixed mutations tests
daniel-sanche May 22, 2023
cac9e2d
SetCell timestamps use millisecond precision
daniel-sanche May 22, 2023
34b051f
renamed BulkMutationsEntry to RowMutationEntry
daniel-sanche May 22, 2023
63ac35c
Merge branch 'v3' into mutate_rows
daniel-sanche May 24, 2023
bb72ea8
Merge branch 'mutate_rows' into mutate_rows_batch
daniel-sanche May 24, 2023
cef70f2
feat: add ChangeStreamConfig to CreateTable and UpdateTable (#786)
gcf-owl-bot[bot] May 25, 2023
ae477b5
build(deps): bump requests from 2.28.1 to 2.31.0 in /synthtool/gcp/te…
gcf-owl-bot[bot] May 25, 2023
ecf539c
docs(samples): add region tags (#788)
Sita04 May 25, 2023
a51201c
added metadata to mutate rows and bulk mutate rows
daniel-sanche May 25, 2023
a21bebf
moved _convert_retry_deadline wrapper from exceptions into _helpers
daniel-sanche May 25, 2023
4ca89d9
fixed system tests
daniel-sanche May 25, 2023
b240ee1
only handle precision adjustment when creating timestamp
daniel-sanche May 26, 2023
cb0e951
added _from_dict for mutation models
daniel-sanche May 26, 2023
a9cf385
rpc timeouts adjust when approaching operation_timeout
daniel-sanche May 26, 2023
eddc1c9
pass table instead of request dict
daniel-sanche May 26, 2023
f8b26aa
refactoring mutate rows
daniel-sanche May 27, 2023
5b80dc5
made on_terminal_state into coroutine
daniel-sanche May 27, 2023
9e5b80a
fixed style issues
daniel-sanche May 27, 2023
f7539f6
moved callback rewriting into retryable attempt
daniel-sanche May 27, 2023
e77a4fa
fixed tests
daniel-sanche May 27, 2023
4e19ed0
pop successful mutations from error dict
daniel-sanche May 30, 2023
920e4b7
removed unneeded check
daniel-sanche May 30, 2023
725f5ff
refactoring
daniel-sanche May 30, 2023
1054bc4
pass list of exceptions in callback
daniel-sanche May 30, 2023
f39a891
raise error in unexpected state
daniel-sanche May 30, 2023
e5f65f2
Merge branch 'mutate_rows' into mutate_rows_batch
daniel-sanche May 31, 2023
8038662
added timeout to user facing flush
daniel-sanche May 31, 2023
c2ec26d
added comments
daniel-sanche May 31, 2023
1d97135
removed callback
daniel-sanche May 31, 2023
88e2bf5
refactoring mutation attempt into class
daniel-sanche May 31, 2023
a3c0166
use partial function
daniel-sanche May 31, 2023
70c35ef
renamed class
daniel-sanche May 31, 2023
e00f592
added comments
daniel-sanche Jun 1, 2023
18af78a
added tests
daniel-sanche Jun 1, 2023
23e84f5
improved helpers
daniel-sanche Jun 1, 2023
c4fd78f
build(deps): bump cryptography from 39.0.1 to 41.0.0 in /synthtool/gc…
gcf-owl-bot[bot] Jun 3, 2023
56fdf7c
refactored operation into class only
daniel-sanche Jun 5, 2023
aca31f0
restructured how remaining indices are tracked
daniel-sanche Jun 5, 2023
5a5d541
fixed tests
daniel-sanche Jun 5, 2023
afed731
added docstrings
daniel-sanche Jun 5, 2023
2396ec8
moved index deletion to end of block
daniel-sanche Jun 6, 2023
3d441a2
added comment to exception types
daniel-sanche Jun 6, 2023
0013c4d
Merge branch 'mutate_rows' into mutate_rows_batch
daniel-sanche Jun 6, 2023
8b41518
update flow control after batch, instead of after each entry
daniel-sanche Jun 6, 2023
5a8b9e9
Merge branch 'v3' into mutate_rows_batch
daniel-sanche Jun 6, 2023
bdd7f45
fixed test
daniel-sanche Jun 6, 2023
553bc4a
add kwargs docstring
daniel-sanche Jun 7, 2023
20156c6
allow mutations over flow limits
daniel-sanche Jun 7, 2023
b9c4467
added limits for mutate_rows mutation and entry counts
daniel-sanche Jun 7, 2023
8b8d8ab
refactored mutation system tests
daniel-sanche Jun 7, 2023
a1de714
added batcher system tests
daniel-sanche Jun 7, 2023
2382a04
allow batcher to append multiple entries
daniel-sanche Jun 7, 2023
1db0377
improved timeout handling
daniel-sanche Jun 7, 2023
589aa5d
fix: add a callback function on flush_rows (#796)
mutianf Jun 8, 2023
fbe6ace
chore(main): release 2.19.0 (#789)
release-please[bot] Jun 8, 2023
6a66c48
made batch rpcs concurrent
daniel-sanche Jun 14, 2023
e1718f0
allow single mutations in flow control public methods
daniel-sanche Jun 14, 2023
eeda2e9
mutation batcher only accepts single entries
daniel-sanche Jun 15, 2023
eeb483f
ensure that proper exceptions are raised for each flush
daniel-sanche Jun 15, 2023
853b5f2
surface unexpected exceptions in MutationsExceptionGroup
daniel-sanche Jun 15, 2023
2865acd
prefixed flow control attributes with underscore
daniel-sanche Jun 15, 2023
e568d92
batcher signature improvements
daniel-sanche Jun 15, 2023
bc7b850
use request mutation limit instead of entry limit
daniel-sanche Jun 15, 2023
ff0aed6
reduce repeated flush tasks when entries appended in a loop
daniel-sanche Jun 15, 2023
f71eebc
renamed variables
daniel-sanche Jun 15, 2023
c0dc760
added test; renamed variables
daniel-sanche Jun 15, 2023
a6b12dc
removed outdated comment
daniel-sanche Jun 16, 2023
d5128eb
added comments
daniel-sanche Jun 16, 2023
335391c
renamed variable
daniel-sanche Jun 16, 2023
836171b
made append async; removed _pending_entries
daniel-sanche Jun 20, 2023
06f16bc
use futures instead of tasks for type hints
daniel-sanche Jun 20, 2023
09a5d51
refactored asyncio calls out to make sync implementation easier
daniel-sanche Jun 20, 2023
0b0f30e
renamed flow_control_max_count
daniel-sanche Jun 21, 2023
283a949
removed None as a flow_control_max_* option
daniel-sanche Jun 21, 2023
834db1a
fixed type annotation
daniel-sanche Jun 21, 2023
524f2d8
fixed tests
daniel-sanche Jun 21, 2023
df8d2d5
improved docstrings
daniel-sanche Jun 21, 2023
eaed9ab
added timeouts to batcher init
daniel-sanche Jun 21, 2023
e0b5e27
fixed 3.11 test issue
daniel-sanche Jun 22, 2023
d50d89b
fixed 3.7 unit test issues
daniel-sanche Jun 22, 2023
32d39fd
fixed lint issue
daniel-sanche Jun 22, 2023
1343b34
fixed lint
daniel-sanche Jun 22, 2023
4f3aa3a
fixed up unit tests
daniel-sanche Jun 22, 2023
0b99b89
added ping and warm to system test
daniel-sanche Jun 22, 2023
6a35be4
fixed broken ping and warm
daniel-sanche Jun 22, 2023
aa35901
added table and app profile to warming params
daniel-sanche Jun 22, 2023
4e1ec6f
fixed _remove_instance_registration
daniel-sanche Jun 22, 2023
8f4b34f
improved tests
daniel-sanche Jun 22, 2023
9c8df9f
allow warming for single instance
daniel-sanche Jun 22, 2023
584f94d
updated tests
daniel-sanche Jun 22, 2023
3c605ba
fixed metadata format
daniel-sanche Jun 22, 2023
12099f5
remove index from exceptions
daniel-sanche Jun 23, 2023
6833707
added test for memory leaks
daniel-sanche Jun 23, 2023
4c40299
clear task after completion
daniel-sanche Jun 23, 2023
2931aa8
added exception list truncation
daniel-sanche Jun 23, 2023
1dc760e
removed index information
daniel-sanche Jun 23, 2023
18fd309
Merge branch 'v3' into warm_improvements
daniel-sanche Jun 23, 2023
badbb83
fixed existing tests
daniel-sanche Jun 23, 2023
97e6680
Merge branch 'v3' into mutate_rows_batch
daniel-sanche Jun 23, 2023
6da9a64
removed manual flushing
daniel-sanche Jun 23, 2023
0ecbbcd
added tests
daniel-sanche Jun 23, 2023
61b367a
pr comment improvements
daniel-sanche Jun 23, 2023
0ce16c6
fixed metadata
daniel-sanche Jun 23, 2023
697cefd
Merge branch 'mutate_rows_batch' into restructure_paths
daniel-sanche Jun 23, 2023
9a407f0
moved v3 client into /data folder
daniel-sanche Jun 23, 2023
c1587e5
moved legacy client back into root
daniel-sanche Jun 23, 2023
a6a6b7b
moved async classes into own sub-folder
daniel-sanche Jun 23, 2023
7e7a667
moved ReadRowsIterator into _read_rows
daniel-sanche Jun 23, 2023
66afd15
moved unit tests into data folder
daniel-sanche Jun 23, 2023
fe4e280
fixed v2 unit tests
daniel-sanche Jun 23, 2023
badaf65
rewrote some test paths
daniel-sanche Jun 24, 2023
48b2d2c
renamed async subpath to _async
daniel-sanche Jun 24, 2023
c00b395
fixed imports
daniel-sanche Jun 24, 2023
e4a6546
split up test files for state machine class
daniel-sanche Jun 24, 2023
1191444
got unit tests running
daniel-sanche Jun 24, 2023
2ca05d8
fixed batcher tests
daniel-sanche Jun 24, 2023
6f12cda
got unit tests passing
daniel-sanche Jun 24, 2023
67f5a3d
fixed system tests
daniel-sanche Jun 24, 2023
d7b6dca
fixed v2 system tests
daniel-sanche Jun 24, 2023
14a3d3d
pin to api_core with streaming retries
daniel-sanche Jun 24, 2023
563a133
fixed type errors
daniel-sanche Jun 24, 2023
b030fb5
updated submodule
daniel-sanche Jun 24, 2023
ac0ef64
fixed batcher comments
daniel-sanche Jun 26, 2023
0b8a651
Merge branch 'main' into restructure_paths
daniel-sanche Jun 26, 2023
d90430a
Merge branch 'v3' into restructure_paths
daniel-sanche Jun 26, 2023
4122a16
updated docs folder
daniel-sanche Jun 26, 2023
ff325ef
changed mypy to only check data client
daniel-sanche Jun 26, 2023
e996946
fixed some test issues
daniel-sanche Jun 26, 2023
d63d68c
reverted gapic tests
daniel-sanche Jun 26, 2023
5b7db3e
added verbose logging for unit tests
daniel-sanche Jun 26, 2023
9947afd
fixed atexit test that was breaking coverage reports
daniel-sanche Jun 26, 2023
9e8a0b3
removed external api-core installation for prerelease-deps
daniel-sanche Jun 26, 2023
e1bc6c7
made start_background_channel_refresh private
daniel-sanche Jun 27, 2023
7b40120
removed dict inputs from function signatures
daniel-sanche Jun 27, 2023
a91db4e
made more functions private
daniel-sanche Jun 27, 2023
58e92f1
made constants private
daniel-sanche Jun 27, 2023
eb55460
chore: remove pinned Sphinx version [autoapprove] (#818)
gcf-owl-bot[bot] Jun 28, 2023
02641a1
Merge branch 'v3' into polish_public_api
daniel-sanche Jun 28, 2023
18b0c41
fixed lint issues
daniel-sanche Jun 28, 2023
0e66a7c
Merge branch 'main' into polish_public_api
daniel-sanche Jun 28, 2023
fc2e8e3
improved RowRange class to hide internals
daniel-sanche Jun 29, 2023
e059877
improved range comparison
daniel-sanche Jun 29, 2023
6713a4d
convert empty strings to None in RowRange
daniel-sanche Jun 29, 2023
e26431c
empty ranges count as inclusive
daniel-sanche Jun 29, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/.OwlBot.lock.yaml
Expand Up @@ -13,5 +13,5 @@
# limitations under the License.
docker:
image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest
digest: sha256:240b5bcc2bafd450912d2da2be15e62bc6de2cf839823ae4bf94d4f392b451dc
# created: 2023-06-03T21:25:37.968717478Z
digest: sha256:ddf4551385d566771dc713090feb7b4c1164fb8a698fe52bbe7670b24236565b
# created: 2023-06-27T13:04:21.96690344Z
6 changes: 3 additions & 3 deletions google/cloud/bigtable/data/_async/_mutate_rows.py
Expand Up @@ -25,7 +25,7 @@
from google.cloud.bigtable.data._helpers import _attempt_timeout_generator

# mutate_rows requests are limited to this number of mutations
from google.cloud.bigtable.data.mutations import MUTATE_ROWS_REQUEST_MUTATION_LIMIT
from google.cloud.bigtable.data.mutations import _MUTATE_ROWS_REQUEST_MUTATION_LIMIT

if TYPE_CHECKING:
from google.cloud.bigtable_v2.services.bigtable.async_client import (
Expand Down Expand Up @@ -65,10 +65,10 @@ def __init__(
"""
# check that mutations are within limits
total_mutations = sum(len(entry.mutations) for entry in mutation_entries)
if total_mutations > MUTATE_ROWS_REQUEST_MUTATION_LIMIT:
if total_mutations > _MUTATE_ROWS_REQUEST_MUTATION_LIMIT:
raise ValueError(
"mutate_rows requests can contain at most "
f"{MUTATE_ROWS_REQUEST_MUTATION_LIMIT} mutations across "
f"{_MUTATE_ROWS_REQUEST_MUTATION_LIMIT} mutations across "
f"all entries. Found {total_mutations}."
)
# create partial function to pass to trigger rpc call
Expand Down
28 changes: 14 additions & 14 deletions google/cloud/bigtable/data/_async/client.py
Expand Up @@ -73,7 +73,7 @@
from google.cloud.bigtable.data import ShardedQuery

# used by read_rows_sharded to limit how many requests are attempted in parallel
CONCURRENCY_LIMIT = 10
_CONCURRENCY_LIMIT = 10

# used to register instance data with the client for channel warming
_WarmedInstanceKey = namedtuple(
Expand Down Expand Up @@ -153,7 +153,7 @@ def __init__(
self._channel_init_time = time.monotonic()
self._channel_refresh_tasks: list[asyncio.Task[None]] = []
try:
self.start_background_channel_refresh()
self._start_background_channel_refresh()
except RuntimeError:
warnings.warn(
f"{self.__class__.__name__} should be started in an "
Expand All @@ -162,7 +162,7 @@ def __init__(
stacklevel=2,
)

def start_background_channel_refresh(self) -> None:
def _start_background_channel_refresh(self) -> None:
"""
Starts a background task to ping and warm each channel in the pool
Raises:
Expand Down Expand Up @@ -308,7 +308,7 @@ async def _register_instance(self, instance_id: str, owner: TableAsync) -> None:
await self._ping_and_warm_instances(channel, instance_key)
else:
# refresh tasks aren't active. start them as background tasks
self.start_background_channel_refresh()
self._start_background_channel_refresh()

async def _remove_instance_registration(
self, instance_id: str, owner: TableAsync
Expand Down Expand Up @@ -370,7 +370,7 @@ def get_table(
)

async def __aenter__(self):
self.start_background_channel_refresh()
self._start_background_channel_refresh()
return self

async def __aexit__(self, exc_type, exc_val, exc_tb):
Expand Down Expand Up @@ -453,7 +453,7 @@ def __init__(

async def read_rows_stream(
self,
query: ReadRowsQuery | dict[str, Any],
query: ReadRowsQuery,
*,
operation_timeout: float | None = None,
per_request_timeout: float | None = None,
Expand Down Expand Up @@ -521,7 +521,7 @@ async def read_rows_stream(

async def read_rows(
self,
query: ReadRowsQuery | dict[str, Any],
query: ReadRowsQuery,
*,
operation_timeout: float | None = None,
per_request_timeout: float | None = None,
Expand Down Expand Up @@ -608,10 +608,10 @@ async def read_rows_sharded(
timeout_generator = _attempt_timeout_generator(
operation_timeout, operation_timeout
)
# submit shards in batches if the number of shards goes over CONCURRENCY_LIMIT
# submit shards in batches if the number of shards goes over _CONCURRENCY_LIMIT
batched_queries = [
sharded_query[i : i + CONCURRENCY_LIMIT]
for i in range(0, len(sharded_query), CONCURRENCY_LIMIT)
sharded_query[i : i + _CONCURRENCY_LIMIT]
for i in range(0, len(sharded_query), _CONCURRENCY_LIMIT)
]
# run batches and collect results
results_list = []
Expand Down Expand Up @@ -942,7 +942,7 @@ async def bulk_mutate_rows(
async def check_and_mutate_row(
self,
row_key: str | bytes,
predicate: RowFilter | dict[str, Any] | None,
predicate: RowFilter | None,
*,
true_case_mutations: Mutation | list[Mutation] | None = None,
false_case_mutations: Mutation | list[Mutation] | None = None,
Expand Down Expand Up @@ -994,12 +994,12 @@ async def check_and_mutate_row(
):
false_case_mutations = [false_case_mutations]
false_case_dict = [m._to_dict() for m in false_case_mutations or []]
if predicate is not None and not isinstance(predicate, dict):
predicate = predicate.to_dict()
metadata = _make_metadata(self.table_name, self.app_profile_id)
result = await self.client._gapic_client.check_and_mutate_row(
request={
"predicate_filter": predicate,
"predicate_filter": predicate._to_dict()
if predicate is not None
else None,
"true_mutations": true_case_dict,
"false_mutations": false_case_dict,
"table_name": self.table_name,
Expand Down
4 changes: 2 additions & 2 deletions google/cloud/bigtable/data/_async/mutations_batcher.py
Expand Up @@ -26,7 +26,7 @@

from google.cloud.bigtable.data._async._mutate_rows import _MutateRowsOperationAsync
from google.cloud.bigtable.data._async._mutate_rows import (
MUTATE_ROWS_REQUEST_MUTATION_LIMIT,
_MUTATE_ROWS_REQUEST_MUTATION_LIMIT,
)
from google.cloud.bigtable.data.mutations import Mutation

Expand Down Expand Up @@ -143,7 +143,7 @@ async def add_to_flow(self, mutations: RowMutationEntry | list[RowMutationEntry]
self._has_capacity(next_count, next_size)
# make sure not to exceed per-request mutation count limits
and (batch_mutation_count + next_count)
<= MUTATE_ROWS_REQUEST_MUTATION_LIMIT
<= _MUTATE_ROWS_REQUEST_MUTATION_LIMIT
):
# room for new mutation; add to batch
end_idx += 1
Expand Down
20 changes: 10 additions & 10 deletions google/cloud/bigtable/data/mutations.py
Expand Up @@ -19,14 +19,14 @@
from abc import ABC, abstractmethod
from sys import getsizeof

from google.cloud.bigtable.data.read_modify_write_rules import MAX_INCREMENT_VALUE

# special value for SetCell mutation timestamps. If set, server will assign a timestamp
SERVER_SIDE_TIMESTAMP = -1
from google.cloud.bigtable.data.read_modify_write_rules import _MAX_INCREMENT_VALUE

# special value for SetCell mutation timestamps. If set, server will assign a timestamp
_SERVER_SIDE_TIMESTAMP = -1

# mutation entries above this should be rejected
MUTATE_ROWS_REQUEST_MUTATION_LIMIT = 100_000
_MUTATE_ROWS_REQUEST_MUTATION_LIMIT = 100_000


class Mutation(ABC):
Expand Down Expand Up @@ -112,7 +112,7 @@ def __init__(
if isinstance(new_value, str):
new_value = new_value.encode()
elif isinstance(new_value, int):
if abs(new_value) > MAX_INCREMENT_VALUE:
if abs(new_value) > _MAX_INCREMENT_VALUE:
raise ValueError(
"int values must be between -2**63 and 2**63 (64-bit signed int)"
)
Expand All @@ -123,9 +123,9 @@ def __init__(
# use current timestamp, with milisecond precision
timestamp_micros = time.time_ns() // 1000
timestamp_micros = timestamp_micros - (timestamp_micros % 1000)
if timestamp_micros < SERVER_SIDE_TIMESTAMP:
if timestamp_micros < _SERVER_SIDE_TIMESTAMP:
raise ValueError(
"timestamp_micros must be positive (or -1 for server-side timestamp)"
f"timestamp_micros must be positive (or {_SERVER_SIDE_TIMESTAMP} for server-side timestamp)"
)
self.family = family
self.qualifier = qualifier
Expand All @@ -145,7 +145,7 @@ def _to_dict(self) -> dict[str, Any]:

def is_idempotent(self) -> bool:
"""Check if the mutation is idempotent"""
return self.timestamp_micros != SERVER_SIDE_TIMESTAMP
return self.timestamp_micros != _SERVER_SIDE_TIMESTAMP


@dataclass
Expand Down Expand Up @@ -208,9 +208,9 @@ def __init__(self, row_key: bytes | str, mutations: Mutation | list[Mutation]):
mutations = [mutations]
if len(mutations) == 0:
raise ValueError("mutations must not be empty")
elif len(mutations) > MUTATE_ROWS_REQUEST_MUTATION_LIMIT:
elif len(mutations) > _MUTATE_ROWS_REQUEST_MUTATION_LIMIT:
raise ValueError(
f"entries must have <= {MUTATE_ROWS_REQUEST_MUTATION_LIMIT} mutations"
f"entries must have <= {_MUTATE_ROWS_REQUEST_MUTATION_LIMIT} mutations"
)
self.row_key = row_key
self.mutations = tuple(mutations)
Expand Down
4 changes: 2 additions & 2 deletions google/cloud/bigtable/data/read_modify_write_rules.py
Expand Up @@ -17,7 +17,7 @@
import abc

# value must fit in 64-bit signed integer
MAX_INCREMENT_VALUE = (1 << 63) - 1
_MAX_INCREMENT_VALUE = (1 << 63) - 1


class ReadModifyWriteRule(abc.ABC):
Expand All @@ -37,7 +37,7 @@ class IncrementRule(ReadModifyWriteRule):
def __init__(self, family: str, qualifier: bytes | str, increment_amount: int = 1):
if not isinstance(increment_amount, int):
raise TypeError("increment_amount must be an integer")
if abs(increment_amount) > MAX_INCREMENT_VALUE:
if abs(increment_amount) > _MAX_INCREMENT_VALUE:
raise ValueError(
"increment_amount must be between -2**63 and 2**63 (64-bit signed int)"
)
Expand Down