Skip to content

feat(python): add a client target - #324

Closed
moetemp wants to merge 1 commit into
moe/up/python-unknown-enum-numberfrom
moe/up/python-client-target
Closed

moetemp wants to merge 1 commit into
moe/up/python-unknown-enum-numberfrom
moe/up/python-client-target

Conversation

@moetemp

@moetemp moetemp commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

What changed?

This PR adds the client target to Python. --targets workflow,client also writes a client package inside the service's output directory, with its own resource classes and a <Service>ClientExtension per service. A client class inherits the extensions and implements _create_nexus_client. A call returns the result with one await.

  • The models are generated once, and the client package imports them from ..models. A resource crosses the targets as data, and each side decodes it as its own class.
  • The Workflow package doesn't change. A client resource calls its operations through the client that made it. The client is in the private _operations attribute, which isn't a dataclass field, so the resource still converts as data.
  • A @nexus.source field is a call parameter, since the client target has no sources yet. The stream WIT has no source, so this first shows in the stream output with the sources of feat: limit @nexus.api-omit to some targets moetemp/nexgen#84.
  • Only Python takes the client target, with --native-api and next to workflow. Language::has_client_target lists the languages that have it, so each new language is one line. nexgen refuses the client target for a service with no endpoint, a method name that two services share, an operation named client (the name of the client package), and a resource method that leaves a sourced field to its source. That last check is in resource_plan.rs, so each language calls the same one.

In the stream sample's Python output, stream_service/client/ appears, with its own Stream and StreamServiceClientExtension. The Workflow Stream stays as it is.

Why?

Brook and native Streams call these operations from clients and Activities, not only from Workflow code. With one WIT file, both packages come from the same definitions and have the same names, so the WIT has no copies.

How did you test it?

Link to a test plan if any -

  • Unit Tests
  • Staging
  • End to End Tests

test_client_target.py runs the stream sample's client package on a fake Nexus client, checks that a handle built by hand has no client, and decodes a Workflow Stream as a client Stream. Rejection fixtures and a unit test cover the refusals.

This was referenced Oct 28, 2026
@moetemp
moetemp force-pushed the moe/up/python-render-targets branch from acbcec8 to e73ff45 Compare October 29, 2026 04:00
@moetemp
moetemp force-pushed the moe/up/python-client-target branch from f44a7bf to 902fec2 Compare October 29, 2026 04:00
@moetemp
moetemp force-pushed the moe/up/python-render-targets branch from e73ff45 to f6b2ea8 Compare October 29, 2026 06:28
@moetemp
moetemp force-pushed the moe/up/python-client-target branch 2 times, most recently from 08b159a to 580cdfe Compare October 29, 2026 07:00
@moetemp
moetemp force-pushed the moe/up/python-render-targets branch from f6b2ea8 to 2196319 Compare October 29, 2026 07:00
@moetemp
moetemp force-pushed the moe/up/python-client-target branch from 580cdfe to 9dda880 Compare October 29, 2026 07:35
@moetemp
moetemp force-pushed the moe/up/python-render-targets branch from 2196319 to 08e197f Compare October 29, 2026 07:35
@moetemp
moetemp force-pushed the moe/up/python-client-target branch from 9dda880 to cb8ec99 Compare October 29, 2026 09:29
@moetemp
moetemp changed the base branch from moe/up/python-render-targets to moe/up/python-unknown-enum-number October 29, 2026 09:29
@moetemp
moetemp force-pushed the moe/up/python-unknown-enum-number branch from 6aa1acb to 66eee48 Compare October 29, 2026 17:08
@moetemp
moetemp force-pushed the moe/up/python-client-target branch from cb8ec99 to 48b2b79 Compare October 29, 2026 17:08
@moetemp
moetemp force-pushed the moe/up/python-unknown-enum-number branch from 66eee48 to df16584 Compare October 29, 2026 17:18
@moetemp
moetemp force-pushed the moe/up/python-client-target branch from 48b2b79 to 90341f4 Compare October 29, 2026 17:18
@moetemp
moetemp force-pushed the moe/up/python-unknown-enum-number branch from df16584 to 5d3c1c0 Compare October 29, 2026 18:27
@moetemp
moetemp force-pushed the moe/up/python-client-target branch from 90341f4 to 4d12251 Compare October 29, 2026 18:27
@@ -0,0 +1,127 @@
# Generated by nexgen latest. DO NOT EDIT!

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Either workflow has the named module, or they both do.

`--targets workflow,client` also writes a `client` package, with its own resource classes and a
client extension for each service. Its methods start each operation through `_create_nexus_client`
and return the result. The models are shared, and the Workflow package doesn't change. The
operation renderers take a target and start each line at its indent, so both targets share them.
The stream sample gets the client target.
@moetemp
moetemp force-pushed the moe/up/python-client-target branch from dd3e142 to df29fb0 Compare October 30, 2026 01:00
@moetemp
moetemp force-pushed the moe/up/python-unknown-enum-number branch from fd46000 to 412faaa Compare October 30, 2026 01:00
@moetemp

moetemp commented Oct 30, 2026

Copy link
Copy Markdown
Contributor Author

Closed in favour of #344

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

2 participants