Support TaskFlow call syntax on stub tasks for the Go SDK#69757
Draft
jason810496 wants to merge 3 commits into
Draft
Support TaskFlow call syntax on stub tasks for the Go SDK#69757jason810496 wants to merge 3 commits into
jason810496 wants to merge 3 commits into
Conversation
Stub Dags could only declare argless tasks, so cross-language dataflow required hand-written GetXCom calls inside each Go task. Capturing the TaskFlow call's argument spec at parse time and delivering it through the Execution API and StartupDetails lets a Go task receive upstream outputs and Dag-file literals as plain typed parameters, with loud arity/type errors instead of silently zero-filled values.
"stub_args" leaked the _StubOperator implementation detail into the wire contract that foreign-language SDKs code-generate against; "arg bindings" names what the data actually is -- the ordered spec a runtime binds onto the task function. Renaming now, before the field ships in a released execution API or supervisor schema version, keeps the contract clean without any compatibility shims.
The single try/except made Airflow 3.0 (whose SDK predates KNOWN_CONTEXT_KEYS) fall back to the Airflow 2 import paths and fail; the arg-capture tests imported airflow.sdk directly, which does not exist on 2.11; and the .expand() rejection relies on the supports_expand opt-out that only ships with Airflow 3.4. Also reword the context-key rejection to stop implying foreign runtimes have no task context -- the lang SDKs inject their own natively; stub signatures just must not declare Airflow context parameters.
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.
Why
@task.stubtasks can only be declared argless today, so a Go task that needs an upstream's output has to hand-writeGetXComcalls (with the upstreamtask_idhard-coded in Go, duplicating the wiring the Dag file already expresses). This PR makes the natural TaskFlow call work across the language boundary:What
_StubOperatorbinds the TaskFlow call to the stub's signature and serializes an ordered positional-arg spec with the Dag (_arg_bindings): each entry is an XCom reference or a JSON literal, withdata_typederived from the parameter annotation.ti_runreturns the spec as a new optionalTIRunContext.arg_bindingsfield — extracted from the serialized-dag blob only for_StubOperatortasks, and stripped for older API versions (Cadwyn change in the in-progress2026-06-30block). The supervisor needs zero changes becauseTIRunContextis embedded verbatim inStartupDetails.2026-07-30(AddArgBindingsToTIRunContext); the downgrade path strips the field, so bundles pinned to2026-06-16keep working unchanged.pkg/bindingpackage.Analyzeclassifies parameters once at registration (injectables likecontext.Context/*slog.Loggervs JSON-decodable data parameters);Resolvebinds the spec onto the data parameters in order — literals decode directly, XCom entries pull on demand. Arity or declared-type mismatches fail the task loudly before the body runs, replacing the old silentreflect.Zerofill..expand()/.partial()(via a new genericsupports_expandopt-out),map/zip/concatXComArgs,*args/**kwargs, context-key parameter names, and non-JSON-serializable literals.Was generative AI tooling used to co-author this PR?