Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request refactors the Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
The pull request successfully refactors the MutationsBatcher to leverage the new data client's batching capabilities. This significantly simplifies the batcher.py file by removing a substantial amount of custom queueing, flow control, and asynchronous flushing logic. The updated unit and system tests adequately cover the new implementation, including exception handling and manual flushing behavior. The changes align with the goal of migrating to the new data client.
| self.flow_control = _FlowControl( | ||
| max_mutations=MAX_OUTSTANDING_ELEMENTS, | ||
| max_mutation_bytes=MAX_OUTSTANDING_BYTES, | ||
| ) |
There was a problem hiding this comment.
It looks like you're discarding the flow control? You should be able to pass these through to the data client batcher
| ) | ||
| self._batcher._user_batch_completed_callback = ( | ||
| self._user_batch_completed_callback | ||
| ) |
There was a problem hiding this comment.
It looks like you're only storing self._flush_interval, self._flush_count, and self._max_row_bytes so you have the context to re-build a new batcher later?
This pattern is fine, but I think functool.partial can make this kind of thing cleaner, letting you condensing all the state into single nullable function
self._batcher_build_fn = partial(self._build_batcher, callback, interval=flush_interval, ...)
def _build_batcher(self, callback, **kwargs):
batcher = self.table._table_impl.mutations_batcher(**kwargs)
batcher._user_batch_completed_callback = callback
return batcher
And then every time you need a new batcher, you just call self._batcher = self._batcher_build_fn()
(It could be simplified more to get rid of the extra _build_batcher function if we make _user_batch_completed_callback into an unadvertised kwarg in the data client, but I'm not sure if that's worth it)
| maxlen=self._exception_list_limit | ||
| ) | ||
| self._user_batch_completed_callback = None | ||
| self._user_batch_completed_callback: Optional[ |
There was a problem hiding this comment.
we should probably add a comment here describing that this is currently just used by the shim
| @@ -406,9 +194,8 @@ def close(self): | |||
| :raises: | |||
| * :exc:`.batcherMutationsBatchError` if there's any error in the mutations. | |||
There was a problem hiding this comment.
I think the exc name in the docstrings might be broken?
| for error in exc_group.exceptions: | ||
| # Return the cause of the FailedMutationEntryError to the user, | ||
| # as this might be more what they're expecting. | ||
| self._exceptions.put(error.__cause__) |
There was a problem hiding this comment.
This might be a good time to address this TODO?
The code seems to assume it will be FailedMutationEntryError, so we should make the types agree
| except MutationsExceptionGroup as exc_group: | ||
| for error in exc_group.exceptions: | ||
| # Return the cause of the FailedMutationEntryError to the user, | ||
| # as this might be more what they're expecting. |
There was a problem hiding this comment.
Can this comment be improved, to be more definitive? Maybe something like # Unpack the root cause from FailedMutationEntryError wrapper
Changes Made: