Uh oh!
There was an error while loading. Please reload this page.
Derive a mixed-language marker for Dags with task.stub - #71213
Derive a mixed-language marker for Dags with task.stub#71213jason810496 wants to merge 1 commit into
Conversation
68c208e to
8e0c2a4CompareUh oh!
There was an error while loading. Please reload this page.
8e0c2a4 to
7c94df5CompareA Lang-SDK artifact can either define a Dag natively or only supply the implementations behind a Python Dag's @task.stub tasks. A Dag processor has to treat those oppositely, persisting the first and discarding the second since the Python Dag already owns that dag_id, and nothing in the serialized Dag told them apart. The flag is derived, never authored: a Python Dag reports it from the presence of stub tasks, and neither the constructor nor attribute assignment can set it, so a Dag cannot claim to be mixed-language without actually holding one.
7c94df5 to
b1c7e11Compare
uranusjr
left a comment
There was a problem hiding this comment.
I guess this is the best given the restrictions since those names need to be public, and we don’t want to rename the Task protocol.
| # Derived, never authored -- see ``DAG.is_mixed_language_dag``. | ||
| is_mixed_language_dag: bool = False |
There was a problem hiding this comment.
When do we plan to actually use this? I wonder if a property similar to the SDK DAG class’s property is enough.
uranusjr
commented
Aug 17, 2026
This does not seem to be a part of the PR? Why are you putting this here? Even if it’s true, why is it the case? |
uranusjr
commented
Aug 17, 2026
The PR description diverges A LOT from the implementation. In the future, I would suggest not putting this verbose information in the description. Use an issue instead, and when you update the PR, add comments to the issue to record the design changes timeline. If you really do want to put this much stuff in the PR description, REMEMBER TO UPDATE IT. Tell Claude to do it, I don’t care, but you need to do it. |
When introducing the native Dag DSL. We have to introduce at "serialization Dag level" so the native Dag is able to set the flag. (native Dag DSL -> Serialized Dag JSON -> DagFileParsingResult -> LazyDeserializedDAG)
IMO, we need to define the spec first (which is the purpose of this PR) before wiring the native Dag part up. |
uranusjr
commented
Aug 17, 2026
I think there are two issues. First of all, why does a language sdk dag need to define this at dag-level? From Airflow Core’s prespective, such a dag is essentially equivalent to a Python-defined dag that only contains stub tasks. Why can’t the dag processor just emit task-level markers? Second, even if we accept a dag-level flag for this use case, |
jason810496
commented
Aug 17, 2026
The mixed Lang artifact is parseable once both #70805 (support optional DagBundle based deployment) and the DagImporter interface (JarImporter, able to get Dags from Jars) get merged. Without the flag, consider the case where we place the Python Dag with stub operator in one DagBundle and the Jar artifact in another DagBundle, the DagModel will jump between mixed Lang Dag and native Dag. Since the Jar artifact for mixed Lang itself is also a valid native Dag Jar. From my perspective, it's necessary to introduce the flag at the Dag-level to make the purpose explicit, so that the DagImporters are able to distinguish between the mixed Lang Jar and the native Dag Jar. |
Andrushika
commented
Aug 19, 2026
Just want to clarify a higher-level design question... Will the Lang SDK support stub syntax in native Dags in the future? (e.g. a native Java Dag that holds a Python or Go task) If it is planned, I think the current flag may not cover that case. Right now the same boolean means two different things:
A native Dag with stub tasks would hit both meanings at once. It has stub tasks, but it is also the real definition that should be persisted. Setting the flag to true would get it dropped, so it has no way to mark itself. If that case is planned, I would suggest a separate field such as Just a small suggestion and I could be completely wrong. Thanks! |
There was a problem hiding this comment.
Will the Lang SDK support stub syntax in native Dags in the future? (e.g. a native Java Dag that holds a Python or Go task)
Your understanding is correct! With the native Dag support in foreign Lang SDK, we can define the "primary" Dag with Stub Operator in foreign Lang SDK side and let the Python Dag implement the task body.
If not, please just ignore me.
From my perspective, I don't think we need to support this feature at all. It makes more sense to only support Python as the primary language for the mixed Lang Dag feature to keep the whole idea simple.
Airflow only supports Python DSL in the last decade! Additionally, the Stub Operator itself might be confusing for some of the user, so not to mention defining the Stub Operator in foreign Lang SDK (it will be mind blowing for the users I guess)
Andrushika
commented
Aug 19, 2026
Thanks for clarifying -- I have no further questions. These changes LGTM! |
is_stubflag was introduced thereWhy
A Lang-SDK artifact can play two roles that a Dag processor must treat oppositely, and nothing in the serialized Dag tells them apart:
@task.stubFor a native Dag the processor parses the artifact and the result is persisted. For a mixed-language Dag it must persist nothing: the Python Dag carrying the
@task.stubtasks already owns thatdag_id, so persisting the Lang-SDK side too would give conflicts.How
The new
is_mixed_language_dagflag at Dag level solves the problem.is_mixed_language_dagflag at Dag level argument.is_mixed_language_dagfield is a compute attribute that if there's anyStubOperatorin the Dag, the property will be true.DAGgains nothing, a Python Dag can never set theis_mixed_language_dagflag.The further mixed language Dag processing flow will be like:
JavaDagImporterdon't emit those Dag withis_mixed_language_dag=Trueby default.PythonDagImporter-> for all Dags whichis_mixed_language_dag=True(the flag will be on if there's StubOperator in the Dag) -> validate the corresponding Java Dag structure (viaTI.queue-> Coordinator ->JavaDagImporter(discover_mixed_language_dags=True)-> Java Dag structure) -> raise import error if there's validation errorWas generative AI tooling used to co-author this PR?