chore(migration): Migrate code from googleapis/python-pubsub into packages/google-cloud-pubsub#16004
chore(migration): Migrate code from googleapis/python-pubsub into packages/google-cloud-pubsub#16004
Conversation
Source-Link: googleapis/synthtool@909573c Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:ddf4551385d566771dc713090feb7b4c1164fb8a698fe52bbe7670b24236565b Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Source-Link: googleapis/synthtool@cb96037 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:2d816f26f728ac8b24248741e7d4c461c09764ef9f7be3684d557c9632e46dbd Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
…uffixes (#938) - [ ] Regenerate this pull request now. PiperOrigin-RevId: 543503563 Source-Link: https://togithub.com/googleapis/googleapis/commit/212ecef96e3ea7c67465ff3f52680301ad0ea1f9 Source-Link: https://togithub.com/googleapis/googleapis-gen/commit/532d27eea6ff128fdcbb3332176e894e76dcc685 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNTMyZDI3ZWVhNmZmMTI4ZmRjYmIzMzMyMTc2ZTg5NGU3NmRjYzY4NSJ9
* fix: Add async context manager return types chore: Mock return_value should not populate oneof message fields chore: Support snippet generation for services that only support REST transport chore: Update gapic-generator-python to v1.11.0 PiperOrigin-RevId: 545430278 Source-Link: googleapis/googleapis@601b532 Source-Link: googleapis/googleapis-gen@b3f18d0 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiYjNmMThkMGY2NTYwYTg1NTAyMmZkMDU4ODY1ZTc2MjA0NzlkN2FmOSJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Co-authored-by: Anthonios Partheniou <partheniou@google.com>
* Update README.rst * Update README.rst Co-authored-by: Anthonios Partheniou <partheniou@google.com> --------- Co-authored-by: Anthonios Partheniou <partheniou@google.com>
* chore: Update gapic-generator-python to v1.11.2 PiperOrigin-RevId: 546510849 Source-Link: googleapis/googleapis@736073a Source-Link: googleapis/googleapis-gen@deb64e8 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiZGViNjRlOGVjMTlkMTQxZTMxMDg5ZmU5MzJiM2E5OTdhZDU0MWM0ZCJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
* Fix resource not found error for flaky test --------- Co-authored-by: Anthonios Partheniou <partheniou@google.com>
) Source-Link: googleapis/synthtool@d6103f4 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:39f0f3f2be02ef036e297e376fe3b6256775576da8a6ccb1d5eeb80f4c8bf8fb Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: Anthonios Partheniou <partheniou@google.com>
* samples: Payload Unwrapping (NoWrapper) * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * Update subscriber.py --------- Co-authored-by: Anna Cocuzzo <63511057+acocuzzo@users.noreply.github.com> Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Source-Link: googleapis/synthtool@eaef28e Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:f8ca7655fa8a449cadcabcbce4054f593dcbae7aeeab34aa3fcc8b5cf7a93c9e Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Co-authored-by: Anthonios Partheniou <partheniou@google.com>
Format string issue Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly: - [ ] Make sure to open an issue as a [bug/issue](https://togithub.com/googleapis/python-pubsub/issues/new/choose) before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea - [ ] Ensure the tests and linter pass - [ ] Code coverage does not decrease (if any source code was changed) - [ ] Appropriate docs were updated (if necessary) Fixes #<issue_number_goes_here> 🦕
* chore: add flakyboy.yaml * chore: add flakybot.yaml
…964) Source-Link: googleapis/synthtool@395d53a Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:6c1cbc75c74b8bdd71dada2fa1677e9d6d78a889e9a70ee75b93d1d0543f96e1 Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
…is set (#965) * docs: clarified where ordering_key will be written if write_metadata is set PiperOrigin-RevId: 551210991 Source-Link: googleapis/googleapis@7c762d7 Source-Link: googleapis/googleapis-gen@15fe4c5 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMTVmZTRjNWZmNWViZDUyOTExYjQyOWIwNWI5OTJlMjMyZjUzMzUxZSJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
* add cloudstorage samples * fix lint * add protobuf * Create unused topic
Source-Link: googleapis/synthtool@0ddbff8 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:bced5ca77c4dda0fd2f5d845d4035fc3c5d3d6b81f245246a36aee114970082b Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Source-Link: googleapis/synthtool@352b9d4 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:3e3800bb100af5d7f9e810d48212b37812c1856d20ffeafb99ebe66461b61fc7 Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
…esour… (#971) * fix: Change retry multiplier from 1.3 to 4, for requests that retry ResourceExhausted.
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
… RESOURCE_EXHAUSTD (#979) * fix: Make retry policy back off more aggressively for RPCs that retry RESOURCE_EXHAUSTD PiperOrigin-RevId: 557935020 Source-Link: googleapis/googleapis@38e1f31 Source-Link: googleapis/googleapis-gen@5bbe39d Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNWJiZTM5ZDM3MjE4YTQyMGIyMzY4YzM3NTQxZGU1ODg3ZGI3ZDZhZiJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
PR created by the Librarian CLI to initialize a release. Merging this PR will auto trigger a release. Librarian Version: v0.8.0 Language Image: us-central1-docker.pkg.dev/cloud-sdk-librarian-prod/images-prod/python-librarian-generator@sha256:b8058df4c45e9a6e07f6b4d65b458d0d059241dd34c814f151c8bf6b89211209 <details><summary>google-cloud-pubsub: 2.35.0</summary> ## [2.35.0](googleapis/python-pubsub@v2.34.0...v2.35.0) (2026-02-05) ### Features * Add AIInference MessageTransform type (PiperOrigin-RevId: 853856321) ([07011139](googleapis/python-pubsub@07011139)) ### Documentation * A comment for field `analytics_hub_subscription_info` in message `.google.pubsub.v1.Subscription` is updated (PiperOrigin-RevId: 853856321) ([07011139](googleapis/python-pubsub@07011139)) * Add the IDENTIFIER field behavior annotation to fields of Cloud Pub/Sub methods that represent a specific identity and need to be sourced with additional care (PiperOrigin-RevId: 840763233) ([07011139](googleapis/python-pubsub@07011139)) * A comment for field `topic` in message `.google.pubsub.v1.Subscription` is updated (PiperOrigin-RevId: 853856321) ([07011139](googleapis/python-pubsub@07011139)) * A comment for field `subscription` in message `.google.pubsub.v1.CreateSnapshotRequest` is updated (PiperOrigin-RevId: 853856321) ([07011139](googleapis/python-pubsub@07011139)) * add tags documentation links to Pub/Sub resource tags fields (PiperOrigin-RevId: 845891076) ([07011139](googleapis/python-pubsub@07011139)) </details>
…1582) This PR replaces the old yoshi-python team with cloud-sdk-python-team and api-pubsub with pubsub-team. b/478003109
…nto migration.python-pubsub.migration.2026-03-02_16-59-45.migrate
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 completes a significant migration of the Google Cloud Pub/Sub Python client library's codebase into a dedicated 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
This pull request is a large migration that moves the google-cloud-pubsub package into this repository, adding a significant number of new configuration and source files. My review focused on these new files. I've identified a critical issue in the setup.py file concerning a non-existent dependency version which will break installation. Additionally, there are a few medium-severity issues related to outdated information in documentation (which is now linked to a rule about environment breaking changes), dead code, and a fragile implementation that relies on internal details of a standard library module. Addressing these points will improve the quality and robustness of the migrated package.
Note: Security Review is unavailable for this PR.
|
|
||
| dependencies = [ | ||
| "grpcio >= 1.51.3, < 2.0.0; python_version < '3.14'", # https://github.com/googleapis/python-pubsub/issues/609 | ||
| "grpcio >= 1.75.1, < 2.0.0; python_version >= '3.14'", |
|
|
||
| > **WARNING**: Breaking change | ||
|
|
||
| The 2.0.0 release requires Python 3.6+. |
There was a problem hiding this comment.
This document, which is part of the current version of the library, states that the 2.0.0 release requires Python 3.6+. However, this library version requires Python 3.9+. This could be confusing for users. Please consider updating this to reflect the current minimum version requirement.
| The 2.0.0 release requires Python 3.6+. | |
| The 2.0.0 release requires Python 3.9+. | |
References
- When a release introduces breaking changes in environment requirements, such as dropping support for specific Python versions or major dependency versions (e.g., protobuf), prefer a minor version bump over a patch version bump. This maintains the ability to provide patches for the previous minor version for users still requiring the older environment.
| if ( | ||
| self.publisher_options.enable_open_telemetry_tracing | ||
| and sys.version_info.major == 3 | ||
| and sys.version_info.minor < 8 | ||
| ): | ||
| warnings.warn( | ||
| message="Open Telemetry for Python version 3.7 or lower is not supported. Disabling Open Telemetry tracing.", | ||
| category=RuntimeWarning, | ||
| ) | ||
| self._open_telemetry_enabled = False |
| if ( | ||
| self.subscriber_options.enable_open_telemetry_tracing | ||
| and sys.version_info.major == 3 | ||
| and sys.version_info.minor < 8 | ||
| ): | ||
| warnings.warn( | ||
| message="Open Telemetry for Python version 3.7 or lower is not supported. Disabling Open Telemetry tracing.", | ||
| category=RuntimeWarning, | ||
| ) | ||
| self._open_telemetry_enabled = False |
| # Drop all pending item from the executor. Without this, the executor will also | ||
| # try to process any pending work items before termination, which is undesirable. | ||
| # | ||
| # TODO: Replace the logic below by passing `cancel_futures=True` to shutdown() | ||
| # once we only need to support Python 3.9+. | ||
| try: | ||
| while True: | ||
| work_item = self._executor._work_queue.get(block=False) | ||
| if work_item is None: # Exceutor in shutdown mode. | ||
| continue | ||
|
|
||
| dropped_message = None | ||
| if sys.version_info < (3, 14): | ||
| # For Python < 3.14, work_item.args is a tuple of positional arguments. | ||
| # The message is expected to be the first argument. | ||
| if hasattr(work_item, "args") and work_item.args: | ||
| dropped_message = work_item.args[0] # type: ignore[index] | ||
| else: | ||
| # For Python >= 3.14, work_item.task is (fn, args, kwargs). | ||
| # The message is expected to be the first item in the args tuple (task[1]). | ||
| if ( | ||
| hasattr(work_item, "task") | ||
| and len(work_item.task) == 3 | ||
| and work_item.task[1] | ||
| ): | ||
| dropped_message = work_item.task[1][0] | ||
|
|
||
| if dropped_message is not None: | ||
| dropped_messages.append(dropped_message) | ||
| except queue.Empty: | ||
| pass |
There was a problem hiding this comment.
This implementation relies on accessing the private _work_queue of ThreadPoolExecutor, which is fragile and could break in future Python versions. Since this library requires Python 3.9+, you could consider using the cancel_futures=True argument in executor.shutdown(), which was introduced in Python 3.9. To maintain the contract of returning dropped messages, you might need to maintain a separate collection of pending futures within the ThreadScheduler and, upon shutdown, cancel them and extract the message arguments from the futures that were not started.
efe1b30 to
5d47628
Compare
4bb7b53 to
3ee28a6
Compare
2bea99b to
6466a67
Compare
6466a67 to
c0f90fd
Compare
See #10930.
This PR should be merged with a merge-commit, not a squash-commit, in order to preserve the git history.