Skip to content

chore(storage): rename zonal bucket samples to bidi and rapid bucket - #14698

Open
chandra-siri wants to merge 1 commit into
mainfrom
chore/rename-zonal-samples-to-bidi
Open

chandra-siri wants to merge 1 commit into
mainfrom
chore/rename-zonal-samples-to-bidi

Conversation

@chandra-siri

Copy link
Copy Markdown
Contributor

Description

Towards b/571318929: Rename GCS Python documentation samples from zonal_buckets to bidi to align with Bidi Standard GA.

Changes:

  • Directory & Test Renames:
    • storage/samples/snippets/zonal_buckets/ -> storage/samples/snippets/bidi/ (matching Go's SDK convention storage/bidi/).
    • zonal_snippets_test.py -> bidi_snippets_test.py.
    • storage/cloudbuild/run_zonal_tests.sh -> storage/cloudbuild/run_rapid_tests.sh.
  • Wording & Docstring Cleanups:
    • bidi/README.md: Drop "Zonal Buckets" title/prose; clarify prerequisites (appendable snippets require a rapid bucket / bucket with the Rapid storage class, ranged-read snippets work on any bucket); update all snippet invocation paths to samples/snippets/bidi/.
    • storage_create_and_write_appendable_object.py: Docstring "to zonal bucket" -> "to rapid bucket".
    • storage_optimize_write_latency_pool.py: Docstrings, comments, and --bucket_name argparse help updated to reference rapid bucket.
    • storage_open_multiple_objects_ranged_read.py: Module docstring example path updated to samples/snippets/bidi/.
    • All # [START storage_...] and # [END storage_...] region tags remain 100% byte-for-byte unchanged.
  • Test & Environment Variable Backward Compatibility:
    • bidi_snippets_test.py: Defines _RAPID_BUCKET = os.getenv("RAPID_BUCKET") or os.getenv("ZONAL_BUCKET"); accepts RUN_RAPID_SYSTEM_TESTS, RUN_BIDI_SYSTEM_TESTS, or RUN_ZONAL_SYSTEM_TESTS; updates test object prefix to bidi-snippets-test-.
    • zb-system-tests-cloudbuild.yaml: scp/ssh run_rapid_tests.sh and pass _RAPID_BUCKET=${_ZONAL_BUCKET} while retaining existing trigger substitutions (_ZONAL_BUCKET, _ZONAL_VM_SERVICE_ACCOUNT) so existing Cloud Build triggers continue functioning seamlessly without modifications.

@chandra-siri
chandra-siri requested review from a team as code owners October 27, 2026 04:31
@product-auto-label product-auto-label Bot added api: storage Issues related to the Cloud Storage API. samples Issues that are directly related to samples. labels Oct 27, 2026
@snippet-bot

snippet-bot Bot commented Oct 27, 2026

Copy link
Copy Markdown

Here is the summary of changes.

You are about to add 9 region tags.
You are about to delete 9 region tags.

This comment is generated by snippet-bot.
If you find problems with this result, please file an issue at:
https://github.com/googleapis/repo-automation-bots/issues.
To update this comment, add snippet-bot:force-run label or use the checkbox below:

  • Refresh this comment

@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 transitions the zonal system tests to rapid and bidirectional streaming (bidi) tests, updating the test scripts, Cloud Build configuration, and sample snippets to use rapid buckets. The feedback recommends defining _RAPID_BUCKET in the Cloud Build substitutions block and passing it dynamically in the SSH command rather than hardcoding it to _ZONAL_BUCKET, ensuring a smoother transition for future triggers.

Comment on lines +22 to +25
# Name of the rapid bucket used by the bidi samples tests. Set by the trigger.
_ZONAL_BUCKET: ""
# Service account attached to the test VM. Set by the trigger.
_ZONAL_VM_SERVICE_ACCOUNT: ""

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.

medium

To allow future Cloud Build triggers to transition to using _RAPID_BUCKET directly without breaking, define _RAPID_BUCKET in the substitutions block. This ensures that when the trigger is updated to pass _RAPID_BUCKET, Cloud Build won't fail due to an undefined substitution variable.

  # Name of the rapid bucket used by the bidi samples tests. Set by the trigger.
  _RAPID_BUCKET: ""
  _ZONAL_BUCKET: ""
  # Service account attached to the test VM. Set by the trigger.
  _ZONAL_VM_SERVICE_ACCOUNT: ""

# Capture the exit code to ensure cleanup happens before the build fails.
set +e
gcloud compute ssh ${_VM_NAME} --zone=${_ZONE} --internal-ip --ssh-key-file=/workspace/.ssh/google_compute_engine --command="ulimit -n ${_ULIMIT}; COMMIT_SHA=${COMMIT_SHA} _ZONAL_BUCKET=${_ZONAL_BUCKET} CROSS_REGION_BUCKET=${_CROSS_REGION_BUCKET} _PR_NUMBER=${_PR_NUMBER} bash run_zonal_tests.sh"
gcloud compute ssh ${_VM_NAME} --zone=${_ZONE} --internal-ip --ssh-key-file=/workspace/.ssh/google_compute_engine --command="ulimit -n ${_ULIMIT}; COMMIT_SHA=${COMMIT_SHA} _RAPID_BUCKET=${_ZONAL_BUCKET} _ZONAL_BUCKET=${_ZONAL_BUCKET} CROSS_REGION_BUCKET=${_CROSS_REGION_BUCKET} _PR_NUMBER=${_PR_NUMBER} bash run_rapid_tests.sh"

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.

medium

Pass _RAPID_BUCKET=${_RAPID_BUCKET} instead of hardcoding it to ${_ZONAL_BUCKET}. Since run_rapid_tests.sh already has fallback logic (RAPID_BUCKET="${_RAPID_BUCKET:-${_ZONAL_BUCKET:-}}"), this change allows the script to correctly receive either variable depending on which one is configured in the trigger.

        gcloud compute ssh ${_VM_NAME} --zone=${_ZONE} --internal-ip --ssh-key-file=/workspace/.ssh/google_compute_engine --command="ulimit -n ${_ULIMIT}; COMMIT_SHA=${COMMIT_SHA} _RAPID_BUCKET=${_RAPID_BUCKET} _ZONAL_BUCKET=${_ZONAL_BUCKET} CROSS_REGION_BUCKET=${_CROSS_REGION_BUCKET} _PR_NUMBER=${_PR_NUMBER} bash run_rapid_tests.sh"

@shradhakatyal shradhakatyal left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Left a few comments across the samples, README, and Cloud Build config:

  1. Blocking Lint CI fix (storage/samples/snippets/bidi/storage_read_appendable_object_tail.py, lines 17–21): flake8-import-order (I100) fails because from datetime import datetime and from io import BytesIO appear after import time (left a file-level comment since this file is a pure rename). Please also run black on the modified Python files.
  2. Terminology alignment: Use "a bucket with the Rapid storage class" for bucket requirements (matching Cloud Storage docs and GoogleCloudPlatform/golang-samples#5684 / #5815).
  3. README & Cloud Build: Use repo-root python storage/samples/snippets/bidi/... paths, document pip install "google-cloud-storage[grpc]", declare _CROSS_REGION_BUCKET: "" alongside _RAPID_BUCKET: "", and fail fast if RAPID_BUCKET is empty.

(Note: The Kokoro CI check failures are unrelated repo-wide failures from the .kokoro/ removal; the python-sdk-rapid-bucket-samples-test Cloud Build check passed.)

bucket_name, object_name, grpc_client=None
):
"""Uploads an appendable object to zonal bucket.
"""Uploads an appendable object to rapid bucket.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Per official Cloud Storage terminology (and Go's storage/bidi/ samples), "Rapid Bucket" is the product name while the bucket requirement is "a bucket with the Rapid storage class". This also fixes the missing article ("to rapid bucket"). Please also run black on this file to remove the extra blank lines around lines 27–28 and 36.

Suggested change
"""Uploads an appendable object to rapid bucket.
"""Uploads an appendable object to a bucket with the Rapid storage class.

Comment on lines +35 to 40
"""Uses a pre-warmed pool of writers for appendable objects in a rapid bucket.

grpc_client: an existing grpc_client to use, this is only for testing.
"""
# The ID of your GCS zonal bucket
# The ID of your GCS rapid bucket
# bucket_name = "your-unique-bucket-name"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Use "a bucket with the Rapid storage class" instead of "a rapid bucket" to match Cloud Storage terminology and Go's optimize_write_latency_pool.go. Note that line 39 is inside the region tag and renders in public docs.

Suggested change
"""Uses a pre-warmed pool of writers for appendable objects in a rapid bucket.
grpc_client: an existing grpc_client to use, this is only for testing.
"""
# The ID of your GCS zonal bucket
# The ID of your GCS rapid bucket
# bucket_name = "your-unique-bucket-name"
"""Uses a pre-warmed pool of writers for appendable objects in a bucket with the Rapid storage class.
grpc_client: an existing grpc_client to use, this is only for testing.
"""
# The ID of your GCS bucket (must use the Rapid storage class)
# bucket_name = "your-unique-bucket-name"

Comment on lines 119 to 121
parser.add_argument(
"--bucket_name", help="Your Cloud Storage zonal bucket name."
"--bucket_name", help="Your Cloud Storage rapid bucket name."
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Update the --bucket_name help text to use "Rapid storage class" wording. Please also run black on this file so CI does not reformat lines 64–70 and 122–124.

Suggested change
parser.add_argument(
"--bucket_name", help="Your Cloud Storage zonal bucket name."
"--bucket_name", help="Your Cloud Storage rapid bucket name."
)
parser.add_argument(
"--bucket_name",
help="Your Cloud Storage bucket name (must use the Rapid storage class).",
)

Comment on lines +7 to +23
## Prerequisites

- A Google Cloud Platform project with the Cloud Storage API enabled.
- For the appendable object snippets (create, finalize, pause and resume, tail,
and the pre-warmed writer pool), a rapid bucket (a bucket with the Rapid
storage class).
- The ranged read snippets work with any Google Cloud Storage bucket.

## Running the snippets

### Create and write to an appendable object

This snippet uploads an appendable object to a rapid bucket.

```bash
python samples/snippets/bidi/storage_create_and_write_appendable_object.py --bucket_name <bucket_name> --object_name <object_name>
```

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Three usability fixes for this README:

  1. Invocation paths: python samples/snippets/bidi/... only works if the user cds into storage/ first. Please use python storage/samples/snippets/bidi/... (from repo root, matching googleapis/google-cloud-python#18859) across all 9 commands, or add a cd storage step under Setup.
  2. Missing [grpc] dependency prerequisite: storage/samples/snippets/requirements.txt installs google-cloud-storage without the grpc extra. Please document pip install "google-cloud-storage[grpc]" under Prerequisites.
  3. Terminology & formatting: Replace "a rapid bucket" (lines 11, 19, 87) with "a bucket with the Rapid storage class", replace "Google Cloud Platform" with "Google Cloud", remove extra blank lines (lines 48–49, 57–58, 74–76), and add a trailing newline at EOF.
Suggested change
## Prerequisites
- A Google Cloud Platform project with the Cloud Storage API enabled.
- For the appendable object snippets (create, finalize, pause and resume, tail,
and the pre-warmed writer pool), a rapid bucket (a bucket with the Rapid
storage class).
- The ranged read snippets work with any Google Cloud Storage bucket.
## Running the snippets
### Create and write to an appendable object
This snippet uploads an appendable object to a rapid bucket.
```bash
python samples/snippets/bidi/storage_create_and_write_appendable_object.py --bucket_name <bucket_name> --object_name <object_name>
```
## Prerequisites
- A Google Cloud project with the Cloud Storage API enabled.
- The Cloud Storage library installed with gRPC support:
```bash
pip install "google-cloud-storage[grpc]"
```
- For the appendable object snippets (create, finalize, pause and resume, tail,
and the pre-warmed writer pool), a bucket with the Rapid storage class.
- The ranged read snippets work with any Google Cloud Storage bucket.
## Running the snippets
Run the commands below from the repository root:
### Create and write to an appendable object
This snippet uploads an appendable object to a bucket with the Rapid storage class.
```bash
python storage/samples/snippets/bidi/storage_create_and_write_appendable_object.py --bucket_name <bucket_name> --object_name <object_name>
```

Comment on lines 17 to 22
"""Downloads a range of bytes from multiple objects concurrently.
Example usage:
```python samples/snippets/zonal_buckets/storage_open_multiple_objects_ranged_read.py \
```python samples/snippets/bidi/storage_open_multiple_objects_ranged_read.py \
--bucket_name <BUCKET_NAME> \
--object_names <OBJECT_1> <OBJECT_2> <OBJECT_3>```
"""

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Update the example path to work from the repository root, remove the markdown backticks (which print literally in --help), and add a blank line after the module docstring to satisfy black.

Suggested change
"""Downloads a range of bytes from multiple objects concurrently.
Example usage:
```python samples/snippets/zonal_buckets/storage_open_multiple_objects_ranged_read.py \
```python samples/snippets/bidi/storage_open_multiple_objects_ranged_read.py \
--bucket_name <BUCKET_NAME> \
--object_names <OBJECT_1> <OBJECT_2> <OBJECT_3>```
"""
"""Downloads a range of bytes from multiple objects concurrently.
Example usage:
python storage/samples/snippets/bidi/storage_open_multiple_objects_ranged_read.py \
--bucket_name <BUCKET_NAME> \
--object_names <OBJECT_1> <OBJECT_2> <OBJECT_3>
"""

Comment on lines +22 to +25
# Name of the rapid bucket used by the bidi samples tests. Set by the trigger.
_ZONAL_BUCKET: ""
# Service account attached to the test VM. Set by the trigger.
_ZONAL_VM_SERVICE_ACCOUNT: ""

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

+1 to adding _RAPID_BUCKET: "" here and passing _RAPID_BUCKET=${_RAPID_BUCKET} on line 125 so Cloud Build's strict substitution check allows updating the trigger later.

Please also declare _CROSS_REGION_BUCKET: "" here (since line 125 references ${_CROSS_REGION_BUCKET} and existing triggers may still pass it), or consider adding _RAPID_VM_SERVICE_ACCOUNT: "" if the trigger's service account substitution will also be renamed.

  # Name of the bucket (Rapid storage class) used by the bidi samples tests.
  _RAPID_BUCKET: ""
  _ZONAL_BUCKET: ""
  _CROSS_REGION_BUCKET: ""
  # Service account attached to the test VM. Set by the trigger.
  _ZONAL_VM_SERVICE_ACCOUNT: ""

Comment on lines +43 to +44
export RAPID_BUCKET="${_RAPID_BUCKET:-${_ZONAL_BUCKET:-}}"
export ZONAL_BUCKET="${RAPID_BUCKET}"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Since zb-system-tests-cloudbuild.yaml now defaults _ZONAL_BUCKET to "", RAPID_BUCKET can silently evaluate to an empty string without triggering set -u. Failing fast here avoids running all 9 pytest tests against an empty bucket name if trigger substitutions are misconfigured.

Suggested change
export RAPID_BUCKET="${_RAPID_BUCKET:-${_ZONAL_BUCKET:-}}"
export ZONAL_BUCKET="${RAPID_BUCKET}"
export RAPID_BUCKET="${_RAPID_BUCKET:-${_ZONAL_BUCKET:-}}"
: "${RAPID_BUCKET:?Either _RAPID_BUCKET or _ZONAL_BUCKET must be set and non-empty}"
export ZONAL_BUCKET="${RAPID_BUCKET}"

Comment on lines +47 to +53
reason="Rapid bucket (bidi) system tests need to be explicitly enabled. This helps scheduling tests in Kokoro and Cloud Build.",
)


# TODO: replace this with a fixture once zonal bucket creation / deletion
# TODO: replace this with a fixture once rapid bucket creation / deletion
# is supported in grpc client or json client client.
_ZONAL_BUCKET = os.getenv("ZONAL_BUCKET")
_RAPID_BUCKET = os.getenv("RAPID_BUCKET") or os.getenv("ZONAL_BUCKET")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Minor cleanups here:

  1. Mention RUN_BIDI_SYSTEM_TESTS=True in the skipif reason (Kokoro is no longer active on this repo) and fix the "json client client" typo on line 52.
  2. Optionally assert or fail clearly if tests are enabled while _RAPID_BUCKET is unset, so local runs get an actionable error message.
Suggested change
reason="Rapid bucket (bidi) system tests need to be explicitly enabled. This helps scheduling tests in Kokoro and Cloud Build.",
)
# TODO: replace this with a fixture once zonal bucket creation / deletion
# TODO: replace this with a fixture once rapid bucket creation / deletion
# is supported in grpc client or json client client.
_ZONAL_BUCKET = os.getenv("ZONAL_BUCKET")
_RAPID_BUCKET = os.getenv("RAPID_BUCKET") or os.getenv("ZONAL_BUCKET")
reason="Bidi system tests must be explicitly enabled (e.g., RUN_BIDI_SYSTEM_TESTS=True).",
)
# TODO: replace this with a fixture once creating a bucket with the Rapid
# storage class is supported in the test setup.
_RAPID_BUCKET = os.getenv("RAPID_BUCKET") or os.getenv("ZONAL_BUCKET")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[Blocking — Fixes Lint CI] (lines 17–21): flake8-import-order (--import-order-style=google) requires standard library imports to be sorted alphabetically by module name. Both datetime and io must appear before time.

import argparse
import asyncio
from datetime import datetime
from io import BytesIO
import time

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

Labels

api: storage Issues related to the Cloud Storage API. samples Issues that are directly related to samples.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants