Skip to content

feat(storage): support storage_class via Blob in AsyncAppendableObjectWriter - #18318

Open
chandra-siri wants to merge 14 commits into
googleapis:mainfrom
chandra-siri:feat/storage-class-via-blob
Open

feat(storage): support storage_class via Blob in AsyncAppendableObjectWriter#18318
chandra-siri wants to merge 14 commits into
googleapis:mainfrom
chandra-siri:feat/storage-class-via-blob

Conversation

@chandra-siri

Copy link
Copy Markdown
Contributor

Description

Adds support for propagating storage_class when creating an AsyncAppendableObjectWriter via AsyncAppendableObjectWriter.from_blob(client, blob), mapping storage_class in _grpc_conversions.blob_to_proto, and updating system and unit tests accordingly.

Changes

  • Conversions & Writer:
    • Added "storage_class": "storage_class" to _BLOB_ATTR_TO_PROTO_FIELD in _grpc_conversions.py.
    • Added storage_class=blob.storage_class in AsyncAppendableObjectWriter.from_blob.
  • Unit Tests:
    • Added unit tests for storage_class mapping in test__grpc_conversions.py.
    • Added unit tests for storage_class handling in AsyncAppendableObjectWriter.from_blob in test_async_appendable_object_writer.py.
  • System Tests:
    • Enabled test_write_from_blob and test_write_blob_with_contexts under RCU by setting blob.storage_class = "RAPID" when RCU_SYSTEM_TESTS is active.

Add support for specifying storage_class when writing objects via AsyncAppendableObjectWriter.

- Add storage_class parameter to AsyncAppendableObjectWriter.__init__ and
  propagate it to _AsyncWriteObjectStream on open().
- Add storage_class parameter to _AsyncWriteObjectStream.__init__ and pass it
  to _storage_v2.Object creation.
- Add unit tests covering initialization and open stream requests.
@chandra-siri
chandra-siri requested a review from a team as a code owner September 9, 2026 11:01

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces support for specifying the storage_class (such as RAPID for RCU system tests) in asynchronous object writers and streams, along with corresponding unit and system test updates. The review feedback highlights two key improvements: first, ensuring that storage_class is respected in _AsyncWriteObjectStream even when a blob is present, and second, replacing the XOR operator with or in the system test skipif condition to prevent tests from being incorrectly skipped when both Zonal and RCU tests are enabled.

Comment thread packages/google-cloud-storage/tests/system/test_zonal.py
generation: Optional[int] = None,
write_handle: Optional[_storage_v2.BidiWriteHandle] = None,
writer_options: Optional[dict] = None,
storage_class: Optional[str] = None,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of adding parameter everytime there's a new configuration, wouldn't it be better to accept something like Blob which would have an option to set these fields?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, we do have that option as well. see method from_blob in this file.

But we also need to support this method as well.

write_handle: Optional[_storage_v2.BidiWriteHandle] = None,
routing_token: Optional[str] = None,
blob: Optional[Blob] = None,
storage_class: Optional[str] = None,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case is it possible that we would ignore the storage class specified in blob?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if blob is present blob's storage class will override the storage_class provided. See line no. 123/128 in this file. Also _AsyncWriteObjectStream is private. Users are not expected to interact with this.

mock_appendable_writer["mock_client"],
storage_class=storage_class,
)
assert writer.storage_class == storage_class

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you also assert that when _do_open() (or open()) is called asynchronously, the storage_class property correctly propagates into the _AsyncWriteObjectStream initialization.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done! - see commit - 00c4954

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants