From 87dc1b1e49334b5a4bf3139925b93459907133ce Mon Sep 17 00:00:00 2001 From: seanbollin Date: Tue, 15 Sep 2026 15:41:45 -0700 Subject: [PATCH 1/2] Rename CloudRunIDPlugin to CloudRunIdPlugin Uses lowercase Id (CloudRunId) per repo naming convention, matching the .NET review feedback and applied across all SDKs. Co-Authored-By: Claude Opus 4.8 --- temporalio/contrib/gcp/cloud_run/id/README.md | 12 ++++++------ temporalio/contrib/gcp/cloud_run/id/__init__.py | 10 +++++----- .../contrib/gcp/cloud_run/id/_cloud_run_id_plugin.py | 4 ++-- .../gcp/cloud_run/id/test_cloud_run_id_plugin.py | 12 ++++++------ 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/temporalio/contrib/gcp/cloud_run/id/README.md b/temporalio/contrib/gcp/cloud_run/id/README.md index 87e0b0ff4..cb56b0045 100644 --- a/temporalio/contrib/gcp/cloud_run/id/README.md +++ b/temporalio/contrib/gcp/cloud_run/id/README.md @@ -2,7 +2,7 @@ > ⚠️ **This package is currently at an experimental release stage.** ⚠️ -A plugin for running [Temporal](https://temporal.io) workers on Google Cloud Run. `CloudRunIDPlugin` +A plugin for running [Temporal](https://temporal.io) workers on Google Cloud Run. `CloudRunIdPlugin` reads Cloud Run instance metadata and sets the client identity. Both Cloud Run **worker pools** and **services** are supported. @@ -15,7 +15,7 @@ derived from the Cloud Run instance (unless you already passed an `identity`). import asyncio from temporalio.client import Client -from temporalio.contrib.gcp.cloud_run.id import CloudRunIDPlugin +from temporalio.contrib.gcp.cloud_run.id import CloudRunIdPlugin from temporalio.worker import Worker from my_workflows import MyWorkflow @@ -26,7 +26,7 @@ async def main() -> None: # Install the plugin on the client; it propagates to workers automatically. client = await Client.connect( "localhost:7233", - plugins=[CloudRunIDPlugin()], + plugins=[CloudRunIdPlugin()], ) worker = Worker( @@ -55,7 +55,7 @@ the at `http://metadata.google.internal/computeMetadata/v1/instance/id`, which requires the `Metadata-Flavor: Google` request header. -When the client connects, `CloudRunIDPlugin` resolves the worker pool name from +When the client connects, `CloudRunIdPlugin` resolves the worker pool name from `CLOUD_RUN_WORKER_POOL` (falling back to the service name `K_SERVICE`) and the revision from `CLOUD_RUN_REVISION` (falling back to `K_REVISION`), then performs a single synchronous HTTP GET to the metadata server for the instance @@ -74,10 +74,10 @@ For advanced scenarios or unit tests you can bypass the metadata server by passi metadata object, or steer the fetch with `getenv` / `metadata_url` / `timeout`: ```python -from temporalio.contrib.gcp.cloud_run.id import CloudRunIDPlugin, get_google_cloud_run_metadata +from temporalio.contrib.gcp.cloud_run.id import CloudRunIdPlugin, get_google_cloud_run_metadata metadata = get_google_cloud_run_metadata() -plugin = CloudRunIDPlugin(metadata=metadata) +plugin = CloudRunIdPlugin(metadata=metadata) # metadata.identity exposes the same value the plugin applies, for use # without the plugin if needed. diff --git a/temporalio/contrib/gcp/cloud_run/id/__init__.py b/temporalio/contrib/gcp/cloud_run/id/__init__.py index d5f52b9e1..40f349797 100644 --- a/temporalio/contrib/gcp/cloud_run/id/__init__.py +++ b/temporalio/contrib/gcp/cloud_run/id/__init__.py @@ -1,6 +1,6 @@ """Run Temporal workers on Google Cloud Run. -:py:class:`CloudRunIDPlugin` reads Cloud Run instance metadata (from a worker pool or a service) and +:py:class:`CloudRunIdPlugin` reads Cloud Run instance metadata (from a worker pool or a service) and sets the client identity from the Cloud Run instance. Quick start:: @@ -8,14 +8,14 @@ import asyncio from temporalio.client import Client - from temporalio.contrib.gcp.cloud_run.id import CloudRunIDPlugin + from temporalio.contrib.gcp.cloud_run.id import CloudRunIdPlugin from temporalio.worker import Worker async def main() -> None: # Install the plugin on the client; it propagates to workers automatically. client = await Client.connect( "localhost:7233", - plugins=[CloudRunIDPlugin()], + plugins=[CloudRunIdPlugin()], ) worker = Worker( @@ -29,7 +29,7 @@ async def main() -> None: asyncio.run(main()) """ -from temporalio.contrib.gcp.cloud_run.id._cloud_run_id_plugin import CloudRunIDPlugin +from temporalio.contrib.gcp.cloud_run.id._cloud_run_id_plugin import CloudRunIdPlugin from temporalio.contrib.gcp.cloud_run.id._metadata import ( CLOUD_RUN_METADATA_URL, GoogleCloudRunMetadata, @@ -39,6 +39,6 @@ async def main() -> None: __all__ = [ "CLOUD_RUN_METADATA_URL", "GoogleCloudRunMetadata", - "CloudRunIDPlugin", + "CloudRunIdPlugin", "get_google_cloud_run_metadata", ] diff --git a/temporalio/contrib/gcp/cloud_run/id/_cloud_run_id_plugin.py b/temporalio/contrib/gcp/cloud_run/id/_cloud_run_id_plugin.py index e4216fa37..ba11f43fe 100644 --- a/temporalio/contrib/gcp/cloud_run/id/_cloud_run_id_plugin.py +++ b/temporalio/contrib/gcp/cloud_run/id/_cloud_run_id_plugin.py @@ -15,7 +15,7 @@ from temporalio.service import ConnectConfig, ServiceClient -class CloudRunIDPlugin(temporalio.plugin.SimplePlugin): +class CloudRunIdPlugin(temporalio.plugin.SimplePlugin): """Set a Temporal client's identity from Google Cloud Run instance metadata. Install this plugin once when connecting the client; the identity it sets @@ -58,7 +58,7 @@ def __init__( ``os.environ.get`` and exists primarily for testing. Ignored when ``metadata`` is supplied. """ - super().__init__("CloudRunIDPlugin") + super().__init__("CloudRunIdPlugin") self._metadata = metadata self._timeout = timeout self._metadata_url = metadata_url diff --git a/tests/contrib/gcp/cloud_run/id/test_cloud_run_id_plugin.py b/tests/contrib/gcp/cloud_run/id/test_cloud_run_id_plugin.py index 083ed05ad..52055ad58 100644 --- a/tests/contrib/gcp/cloud_run/id/test_cloud_run_id_plugin.py +++ b/tests/contrib/gcp/cloud_run/id/test_cloud_run_id_plugin.py @@ -10,7 +10,7 @@ import pytest from temporalio.contrib.gcp.cloud_run.id import ( - CloudRunIDPlugin, + CloudRunIdPlugin, GoogleCloudRunMetadata, ) from temporalio.service import ConnectConfig, ServiceClient @@ -48,7 +48,7 @@ def _service_client() -> ServiceClient: class TestClientIdentity: @pytest.mark.asyncio async def test_sets_identity_when_unset(self) -> None: - plugin = CloudRunIDPlugin( + plugin = CloudRunIdPlugin( metadata=_metadata(instance_id="abc", revision="rev-1") ) # ConnectConfig auto-fills identity with @ when none is given. @@ -65,7 +65,7 @@ async def connect(input: ConnectConfig) -> ServiceClient: @pytest.mark.asyncio async def test_preserves_caller_identity(self) -> None: - plugin = CloudRunIDPlugin( + plugin = CloudRunIdPlugin( metadata=_metadata(instance_id="abc", revision="rev-1") ) config = ConnectConfig(target_host="localhost:7233", identity="my-identity") @@ -85,14 +85,14 @@ async def connect(input: ConnectConfig) -> ServiceClient: class TestMetadataFetch: def test_construction_does_not_fetch(self) -> None: # A bad metadata URL must not raise at construction -- the fetch is lazy. - CloudRunIDPlugin( + CloudRunIdPlugin( metadata_url=f"http://127.0.0.1:{_closed_port()}/instance/id", getenv={}.get, # type: ignore[arg-type] ) @pytest.mark.asyncio async def test_connect_fails_fast_off_platform(self) -> None: - plugin = CloudRunIDPlugin( + plugin = CloudRunIdPlugin( timeout=1.0, metadata_url=f"http://127.0.0.1:{_closed_port()}/instance/id", getenv={}.get, # type: ignore[arg-type] @@ -114,7 +114,7 @@ async def test_metadata_fetched_from_server_at_connect( "temporalio.contrib.gcp.cloud_run.id._cloud_run_id_plugin.get_google_cloud_run_metadata", fetch, ) - plugin = CloudRunIDPlugin() + plugin = CloudRunIdPlugin() config = ConnectConfig(target_host="localhost:7233") async def connect(_input: ConnectConfig) -> ServiceClient: From e7587928f5aaa020ef20667fe0a216289caaf4ee Mon Sep 17 00:00:00 2001 From: seanbollin Date: Tue, 15 Sep 2026 17:00:37 -0700 Subject: [PATCH 2/2] Add CHANGELOG entry naming CloudRunIdPlugin Names the renamed client plugin in the existing Unreleased entry so the changelog reflects the final CloudRunIdPlugin name and satisfies the changelog checkpoint. Co-Authored-By: Claude Opus 4.8 --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 172bc72d9..e8597d2c2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,7 +20,7 @@ to include examples, links to docs, or any other relevant information. ### Added -- Added the `temporalio.contrib.gcp.cloud_run.id` module plugin to help set the worker identity on Cloud Run. +- Added the `temporalio.contrib.gcp.cloud_run.id` module with the `CloudRunIdPlugin` client plugin to set the worker identity on Cloud Run. ### Changed ### Deprecated