Uh oh!
There was an error while loading. Please reload this page.
This repository was archived by the owner on Mar 31, 2026. It is now read-only.
- Notifications
You must be signed in to change notification settings - Fork 173
feat(ZonalBuckets): add support for generation=0 to avoid overwriting existing objects and add is_stream_open support #1709
Merged
Uh oh!
There was an error while loading. Please reload this page.
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
f0855c9
feat(ZonalBuckets): add `is_stream_open` property to AsyncAppendableO…
chandra-siri 084c919
feat(ZonalBuckets): add support for generation=0 to prevent overwriti…
chandra-siri bcd7120
Apply suggestion from @gemini-code-assist[bot]
chandra-siri 3b1b676
enhance generation parameter documentation for clarity on object over…
chandra-siri d01df19
feat(asyncio): enhance generation handling in AsyncAppendableObjectWr…
chandra-siri cee0907
rename test functions for clarity on generation handling
chandra-siri File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
34 changes: 26 additions & 8 deletions
34 google/cloud/storage/_experimental/asyncio/async_appendable_object_writer.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -97,15 +97,29 @@ def __init__( | ||
| :param object_name: The name of the GCS Appendable Object to be written. | ||
| :type generation: int | ||
| :param generation: (Optional) If present, selects a specific revision of | ||
| that object. | ||
| If None, a new object is created. | ||
| If None and Object already exists then it'll will be | ||
| overwritten. | ||
| :param generation: (Optional) If present, creates writer for that | ||
| specific revision of that object. Use this to append data to an | ||
| existing Appendable Object. | ||
| Setting to ``0`` makes the `writer.open()` succeed only if | ||
| object doesn't exist in the bucket (useful for not accidentally | ||
| overwriting existing objects). | ||
| Warning: If `None`, a new object is created. If an object with the | ||
| same name already exists, it will be overwritten the moment | ||
| `writer.open()` is called. | ||
| :type write_handle: bytes | ||
| :param write_handle: (Optional) An existing handle for writing the object. | ||
| If provided, opening the bidi-gRPC connection will be faster. | ||
| :param write_handle: (Optional) An handle for writing the object. | ||
| If provided, opening the bidi-gRPC connection will be faster. | ||
| :type writer_options: dict | ||
| :param writer_options: (Optional) A dictionary of writer options. | ||
| Supported options: | ||
| - "FLUSH_INTERVAL_BYTES": int | ||
| The number of bytes to append before "persisting" data in GCS | ||
| servers. Default is `_DEFAULT_FLUSH_INTERVAL_BYTES`. | ||
| Must be a multiple of `_MAX_CHUNK_SIZE_BYTES`. | ||
chandra-siri marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| """ | ||
| raise_if_no_fast_crc32c() | ||
| self.client = client | ||
| @@ -133,7 +147,6 @@ def __init__( | ||
| self.flush_interval = writer_options.get( | ||
| "FLUSH_INTERVAL_BYTES", _DEFAULT_FLUSH_INTERVAL_BYTES | ||
| ) | ||
| # TODO: add test case for this. | ||
| if self.flush_interval < _MAX_CHUNK_SIZE_BYTES: | ||
| raise exceptions.OutOfRange( | ||
| f"flush_interval must be >= {_MAX_CHUNK_SIZE_BYTES} , but provided {self.flush_interval}" | ||
| @@ -346,6 +359,11 @@ async def finalize(self) -> _storage_v2.Object: | ||
| self.offset = None | ||
| return self.object_resource | ||
| @property | ||
| def is_stream_open(self) -> bool: | ||
| return self._is_stream_open | ||
| # helper methods. | ||
| async def append_from_string(self, data: str): | ||
| """ | ||
19 changes: 15 additions & 4 deletions
19 google/cloud/storage/_experimental/asyncio/async_write_object_stream.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.