Skip to content

[UPSTREAM-8] feat(python): add a client target with --targets - #54

Closed
moetemp wants to merge 1 commit into
moe/up/ts-long-resource-paramsfrom
moe/up/python-client
Closed

moetemp wants to merge 1 commit into
moe/up/ts-long-resource-paramsfrom
moe/up/python-client

Conversation

@moetemp

@moetemp moetemp commented Oct 22, 2026 •

Copy link
Copy Markdown
Owner

What changed?

This PR adds --targets, with workflow (the default) and client. The client target writes client.py, the workflow API for code outside a Workflow.

  • client.py has a <Service>ClientExtension per service, with the operation code of the workflow target as methods. So only the invocation differs.
  • A client class inherits the extension and implements _create_nexus_client, for example with a standalone Nexus operation. There's no transport.
  • A resource keeps the client that built it, so create_stream returns a Stream with methods. A service with no endpoint passes endpoint=None.
  • For now it's Python, System Nexus and the native API only, and it refuses a @nexus.source field. temporalio/nexgen#301 tracks taking such a field as a parameter instead.

Depends on temporalio/nexgen#308, #310, #311, #297, #296 and #312, which its base holds.
Part of the Brook review series.

Why?

Code outside a Workflow needs the same API as Workflow code, on the Temporal client and with no transport to write. Brook uses it from Activities and clients.

How did you test it?

The stream-service sample, Brook's WIT, generates both targets for Python. The stream-writer sample asks for the client target only, as Brook does. Its Python output comes with #71. A sample test drives client.py through a fake client, and rejection fixtures cover the refused cases. It's one commit, since today's generator ignores the new targets key and has no output to compare.
cargo validate passes and cargo clippy adds no warnings.

@moetemp moetemp changed the title [Upstream] Generated a Python caller per service over a transport. [Upstream] feat: generate a Python caller per service over a transport Oct 22, 2026
@moetemp moetemp changed the title [Upstream] feat: generate a Python caller per service over a transport feat(python): generate a caller per service over a transport Oct 22, 2026
@moetemp moetemp changed the title feat(python): generate a caller per service over a transport [Upstream] feat(python): generate a caller per service over a transport Oct 22, 2026
@moetemp moetemp changed the title [Upstream] feat(python): generate a caller per service over a transport [UPSTREAM-7] feat(python): generate a caller per service over a transport Oct 22, 2026
@moetemp moetemp changed the title [UPSTREAM-7] feat(python): generate a caller per service over a transport [UPSTREAM-8] feat(python): generate a caller per service over a transport Oct 23, 2026
@moetemp
moetemp changed the base branch from moe/up/main to moe/up/ts-long-resource-params October 23, 2026 06:24
moetemp added a commit to temporalio/nexgen that referenced this pull request Oct 23, 2026
)

## What changed?

This PR adds a `stream-service` sample for Python and TypeScript, with today's output. #272 adds .NET with its fix. It has a `stream` resource built from a ref, `create-stream`, append, read, describe and close, with 64-bit offsets, payloads and durations.

Its records are proto-backed, as a stream service's are. Upstream has no stream protos, so the sample has its own small proto in `descriptors/streamsample/v1/`, with checked-in bindings. The samples README has the commands that regenerate them. `build_examples` now loads every `*.bin` under `descriptors/`.

## Why?

Later fixes show their effect as a golden diff on this sample.

## How did you test it?

The goldens. A TypeScript test sends a full `ReadRecordsRequest` through the converter, so the TypeScript type file can't drift from the proto.

## What comes next

These fixes are ready, in this order. Each one adds its shape to this sample, then the fix.

- #272: adds .NET, where the `stream` field of the `Stream` class fails with CS0542, then the fix.
- [moetemp#52](moetemp#52): Check required resource fields of a response. Adds `create-stream` returning the `stream` resource.
- [moetemp#56](moetemp#56): Allow a result record to hold a resource. Adds a `create-stream-result` holder record.
- [moetemp#53](moetemp#53): Emit `@nexus.doc` on resources and methods as Python docstrings.
- [moetemp#70](moetemp#70): Convert 64-bit resource method values to `Long` for a proto request in TypeScript. Adds 64-bit method parameters. Needs #265.
- [moetemp#54](moetemp#54): Generate a Python caller per service over a transport. Turns on the client for the sample.
- [moetemp#55](moetemp#55): Add `@nexus.long-poll` to the Python caller. Marks `read-records` as a long poll.
- [moetemp#57](moetemp#57): Add Python client classes for resources with methods.
- [moetemp#71](moetemp#71): Drop the bare keyword marker from a Python signature with no parameters. Adds a `stream-writer` interface with no endpoint.
- [moetemp#60](moetemp#60): Indent the docstrings of Python caller methods. Adds a doc on a writer operation.
- [moetemp#69](moetemp#69): Import record types that an endpoint-less Python client uses in unpacked parameters. Adds `open-writer`.
- [moetemp#72](moetemp#72): Plan proto unsigned integers as unsigned. Adds a `uint64` writer id.
- [moetemp#73](moetemp#73): Build a returned proto-wire resource in an endpoint-less TypeScript client. Makes `open-writer` return the `writer` resource.

#262 adds a `status` enum to the holder record once it merges.
@moetemp
moetemp force-pushed the moe/up/python-client branch from 3b1fc80 to d38df9d Compare October 25, 2026 22:19
@moetemp
moetemp force-pushed the moe/up/ts-long-resource-params branch from 9567a26 to 8321346 Compare October 25, 2026 22:19
@moetemp
moetemp marked this pull request as ready for review October 25, 2026 22:20
@moetemp
moetemp force-pushed the moe/up/ts-long-resource-params branch from 8321346 to b7daf25 Compare October 26, 2026 20:56
@moetemp
moetemp force-pushed the moe/up/python-client branch 2 times, most recently from 2e720ad to fb988c7 Compare October 26, 2026 22:34
@moetemp
moetemp force-pushed the moe/up/ts-long-resource-params branch from b7daf25 to f518ff8 Compare October 26, 2026 22:34
@moetemp moetemp changed the title [UPSTREAM-8] feat(python): generate a caller per service over a transport [UPSTREAM-8] feat(python): add a client target with --targets Oct 26, 2026
@moetemp
moetemp force-pushed the moe/up/ts-long-resource-params branch from f518ff8 to 7046833 Compare October 26, 2026 22:37
@moetemp
moetemp force-pushed the moe/up/python-client branch 3 times, most recently from a13f250 to c19f0c9 Compare October 27, 2026 01:06
@moetemp
moetemp force-pushed the moe/up/ts-long-resource-params branch 2 times, most recently from 2056cfc to 7227a0c Compare October 27, 2026 09:08
@moetemp
moetemp force-pushed the moe/up/python-client branch from c19f0c9 to d4962e0 Compare October 27, 2026 09:08
@moetemp
moetemp force-pushed the moe/up/python-client branch from d4962e0 to 551d4a5 Compare October 27, 2026 18:07
@moetemp
moetemp force-pushed the moe/up/ts-long-resource-params branch 2 times, most recently from 1600a86 to e87464a Compare October 27, 2026 19:00
@moetemp
moetemp force-pushed the moe/up/python-client branch from 551d4a5 to 814da54 Compare October 27, 2026 19:00
The client target renders the workflow target's operations as methods of a generated client extension. A client class inherits it and starts each operation through _create_nexus_client, so the generated API needs no transport. For now it's Python and System Nexus only.
@moetemp

moetemp commented Oct 29, 2026

Copy link
Copy Markdown
Owner Author

Closing this. Replaced by temporalio#324.

@moetemp moetemp closed this Oct 29, 2026
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.

1 participant