Sync main from upstream temporalio/sdk-python - #2
Merged
Merged
Conversation
* Remove Experimental tag from Standalone Activities.
* NexusSerializationContext for data/failure converters * Updating the nexus context for summary * Moving decoding logic to the nexus operation handle * Adding GetNexusOperationResultOutput for the interceptor * Refine Nexus serialization context propagation
* Add Google Cloud Run worker identity/deployment helper
Adds an experimental Google Cloud Run helper, mirroring the existing AWS
Lambda module's worker-ID behavior. Because Cloud Run runs a long-lived
container (unlike Lambda's per-invocation model), this is a metadata
helper rather than a worker wrapper: it reads the Cloud Run instance
metadata -- the instance id from the metadata server, plus the worker
pool/service name and revision from CLOUD_RUN_WORKER_POOL / CLOUD_RUN_REVISION
(worker pools) or K_SERVICE / K_REVISION (services) -- and derives a worker
identity and a WorkerDeploymentVersion to apply to a normal long-lived
worker. Covers both Cloud Run worker pools and services.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* Set worker versioning behavior to PINNED in the Cloud Run worker apply
The worker-side apply helper enabled versioning and set the deployment
version but left the default versioning behavior unset, so a versioned
worker with a plain (un-annotated) workflow failed to register. Default it
to PINNED; a per-workflow versioning behavior still takes precedence.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* Add unit tests for the Google Cloud Run metadata helper
Cover the temporalio.contrib.gcp.cloud_run helper:
- Environment precedence for the deployment name (CLOUD_RUN_WORKER_POOL over
K_SERVICE) and revision (CLOUD_RUN_REVISION over K_REVISION).
- Worker identity formatting and its revision -> name -> instance-id fallbacks.
- WorkerDeploymentVersion derivation and its ValueError when name/revision empty.
- WorkerDeploymentConfig enabling worker versioning with PINNED default behavior.
- The metadata HTTP fetch via a local in-process server: asserts the
Metadata-Flavor: Google header is sent, the body is trimmed, and a clear
RuntimeError is raised on non-200 and unreachable responses.
Uses the helper's dependency-injection seams (getenv and metadata_url) so no
real environment or network access is required.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* Add CloudRunPlugin for Google Cloud Run worker defaults
Re-architect the Cloud Run worker-ID helper into a plugin mirroring the
SDK's OpenTelemetry Cloud Run plugin. CloudRunPlugin subclasses
temporalio.plugin.SimplePlugin and is registered once on the client via
Client.connect(plugins=[...]); it propagates to workers automatically.
The plugin fetches Cloud Run instance metadata lazily at client connect
and caches it, then sets the client identity (only when the caller did
not provide one) and configures the worker with a PINNED
WorkerDeploymentConfig derived from the Cloud Run revision. Connecting
off Cloud Run fails fast with a clear error.
The GoogleCloudRunMetadata dataclass and its worker_identity /
worker_deployment_version / worker_deployment_config properties are kept
for advanced and non-plugin use.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* Rename CloudRunPlugin to WorkerIDPlugin and fix test type errors
Cloud Run can host multiple plugins (a worker-ID plugin and an
OpenTelemetry plugin both live in the same cloud_run area), so the
worker-ID plugin needs a specific name rather than the generic
CloudRunPlugin.
- Rename class CloudRunPlugin -> WorkerIDPlugin and move
_plugin.py -> _worker_id_plugin.py (cloud_run package and
GoogleCloudRunMetadata unchanged).
- Update the package __init__ export/__all__, quick-start, and README.
- Rename test_plugin.py -> test_worker_id_plugin.py and fix the
basedpyright reportInvalidCast errors by constructing WorkerConfig()
instead of cast(WorkerConfig, {}); silence reportUnusedParameter on
the unused connect() callbacks.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* Move Cloud Run worker-ID plugin under cloud_run/worker_id/
Relocate the Google Cloud Run worker-ID plugin from directly inside
temporalio/contrib/gcp/cloud_run/ into a new worker_id/ sub-package so it
owns its own __init__.py and README.md. This avoids a hard collision with
the separate OTel Cloud Run plugin, which also owns cloud_run/README.md and
cloud_run/__init__.py; after the move the two plugins share only the
minimal cloud_run/ and gcp/ namespace-marker __init__.py files.
The public names are unchanged; only the import path gains .worker_id:
from temporalio.contrib.gcp.cloud_run.worker_id import WorkerIDPlugin
cloud_run/__init__.py is reduced to a minimal namespace-marker docstring
with no worker-ID exports. Mirrors the Go (contrib/gcp/cloudrun/workerid)
and .NET (CloudRun.WorkerId) layouts.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* Add CHANGELOG entry for Cloud Run worker-ID plugin
Satisfies the changelog checkpoint, which requires a user-facing change to
add an entry under Unreleased in a CHANGELOG.md.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* Align gcp namespace markers with the Cloud Run OTel PR
Reduce temporalio/contrib/gcp/__init__.py and
temporalio/contrib/gcp/cloud_run/__init__.py to the same generic namespace
markers used by the Cloud Run OpenTelemetry PR, so both PRs add
byte-identical files and merge into main without an add/add conflict. The
worker_id plugin imports from cloud_run.worker_id, so this docstring-only
change to the cloud_run root is safe.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* Make Cloud Run WorkerID plugin identity-only
Drop all Worker Deployment Versioning from the Cloud Run WorkerID plugin so it
only sets the worker identity from Cloud Run instance metadata.
- Remove the worker_deployment_version and worker_deployment_config (PINNED)
properties from GoogleCloudRunMetadata, plus the now-unused WorkerDeploymentVersion,
WorkerDeploymentConfig, and VersioningBehavior imports.
- Remove WorkerIDPlugin.configure_worker (which set deployment_config); the plugin no
longer overrides the worker configurator. The client hook still sets the identity
when unset or equal to the SDK pid@host default, and the worker inherits it.
- Update tests, docstrings, README, and the CHANGELOG entry to identity-only wording.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* Remove deployment-name/build-ID wording from Cloud Run worker-ID docs
The plugin sets only the worker identity, so describe the Cloud Run metadata as the worker pool/service name and revision rather than a Temporal deployment name and build ID.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* Simplify worker identity docs and comments
Trim negative-contrast framing and editorializing so the comments and docs describe only the worker identity functionality, per review feedback.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* Fixing Claude Code prose to be more succinct
* Put the experimental warning back to allow for future updates
* Rename plugin to CloudRunIDPlugin
The plugin sets the client identity (which in turn sets the worker identity), and the new name carries the Cloud Run context without relying on the full package path.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* Rename package leaf to id and metadata accessor to Identity
Renames the Cloud Run extension package from cloud_run.worker_id to cloud_run.id, and GoogleCloudRunMetadata.worker_identity to .identity.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
* 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 <noreply@anthropic.com> * 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 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Sync fork main with upstream temporalio/sdk-python main to unblock rebasing PR temporalio#1882.