Skip to content

[UPSTREAM-18] feat(python): let a @nexus.source name the target it fills - #76

Closed
moetemp wants to merge 1 commit into
moe/up/python-endpointless-resource-importfrom
moe/up/python-source-targets
Closed

moetemp wants to merge 1 commit into
moe/up/python-endpointless-resource-importfrom
moe/up/python-source-targets

Conversation

@moetemp

@moetemp moetemp commented Oct 27, 2026

Copy link
Copy Markdown
Owner

What changed?

This PR lets a @nexus.source name the target it fills, with target="workflow" or target="client". A field can have one source for each target. A source with no target fills every target, as before.

  • The workflow source stays the model's default. The Python client target passes the client source in each request it builds, since both targets share the models.
  • The client target refuses only a field whose single source is for the workflow target. The sourced-field fixture keeps that refusal, now with target="workflow".
  • A field with only a client source must be an option, since the workflow target can leave it unset.
  • A sourced option field gets a None guard in the proto converter.

Depends on #75 (UPSTREAM-17).
Part of the Brook review series.

Why?

Brook's writes carry context fields that a user never sets, such as the producer. In a Workflow they come from the run, in an Activity from its attempt, and in a client from the client. The client target refused every sourced field, so each SDK filled them by hand. The client target runs in Activities and clients alike, so one client helper serves both, and it can check temporalio.activity.in_activity() at run time. temporalio/nexgen#301 asked for this.

How did you test it?

The streaming example's append-records-request gets a producer with a workflow source and a client source. The client test checks that a call outside a Workflow sends the client producer. Four new parser fixtures cover a duplicate target, a mixed untargeted and targeted source, an unknown target, and a required field with only a client source.
cargo validate passes. It's one commit, since today's parser refuses two sources on one field, so there's no output to compare.

A source takes target="workflow" or target="client", and a field can have one of each. The
client target passes the client source in each request, since the models are shared. It refuses
only a field whose single source is for the workflow target.
@moetemp

moetemp commented Oct 27, 2026

Copy link
Copy Markdown
Owner Author

Closed for now. Brook's generated Stream client is private in sdk-python, behind the SDK's own Stream API, so this doesn't change what a user writes. It can come back with native Streams, where the generated API is the user API. temporalio/nexgen#301 stays open.

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