Repository navigation
Conversation
ADR-0002 adds the $import value marker. It imports a Python object by its import path, and optionally calls it when args or kwargs is given. It is recognized under a task's with: and on callback keys, so a YAML Dag can set callbacks, operator arguments, etc. that must be Python objects, such as PythonOperator's python_callable. ADR-0003 (draft) sketches how references in other languages could be added later, selected through queue routing rather than a language name. This is provided both as notes for future design, and a reference for reviewers to judge whether ADR-0002 leaves enough room for it. Being a draft, the ADR is not proposed for acceptance, and suggestions toward its content should be avoided unless they also affect the content of ADR-0002.
uranusjr
force-pushed
the
yaml-callbacks
branch
from
December 2, 2026 19:31
a078946 to
8e4f77f
Compare
jason810496
reviewed
Dec 3, 2026
| - Either may be left out when it would be empty: `{$import: f, args: [1]}` is `f(1)`, and `{$import: f, kwargs: {x: 1}}` is `f(x=1)`. Both are needed only when both kinds of arguments are given. | ||
| - `args` is a list or null, and `kwargs` a mapping or null. Null and empty both mean no arguments of that kind, so `{$import: f, args:}`, `{$import: f, kwargs:}`, and a mapping with both empty all mean `f()`. | ||
|
|
||
| 3. **`args` and `kwargs` are the marker's only options.** |
Member
There was a problem hiding this comment.
Not the question for this PR, but do you think we need to add args on non-Python SDK Dag authoring interface? Or just keep them as kwargs only (current proposed state)?
| - `runtime: dag`, the default, is the language the team's default queue routes to. This is what ADR-0002's `$import` means, a Python callback, so documents written for ADR-0002 keep their meaning. | ||
| - `runtime: task` is the language the task's own queue routes to: the handler's for a `run:` task, and the operator's for a `uses:` task once an operator can be written in another language. | ||
| - The option is the same on both task kinds, and optional on both. Running a callback with the task's definition is what every SDK does, so `dag` is a lasting default, not a placeholder. | ||
| - `runtime` selects the language that resolves the reference, not where the callback runs. Where a callback runs follows Airflow's rules: in the task's process, or for a routed callback, on the queue #76303 picks. |
Member
There was a problem hiding this comment.
Thinking from the Lang-SDK world where I kept the Python as special one (python.callbackRef) whereas the YAML Dag we consider Python is the default and the non-Python callback is special.
Would it make sense to have the second primitive for the non-Python callable import as the special case?
on_retry_callback:
# only $lang_sdk_import primitive allow using the "queue" arg
- {$lang_sdk_import: go_pkg.alerts.Notify, kwargs: {level: warn} queue: go}IIRC, the runtime is what we avoid in the very first place of Lang-SDK. Though the purpose of the runtime here is sightly different.
This branch has not been deployed
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.
ADR-0002 is proposed. A
$importvalue marker that imports a Python object by its import path, and calls it whenargsorkwargsis given. It is recognized under a task'swith:and onon_*_callbackkeys. This unblocks callbacks and notifiers in YAML Dags, operator arguments that must be Python objects, and operators that take a callable such asPythonOperator, which DagFactory Dags commonly use.ADR-0003 is in draft. It sketches how references could later resolve in other languages, selected through queue routing (AIP-108, #76303) rather than by naming a language. It is not proposed for acceptance.
Review ADR-0002 in full. Consider ADR-0003 only on whether ADR-0002 leaves enough room for that direction. The details shall be discussed later, when the ADR is formally proposed.
This depends on the ADR-0001 amendment in #77944. ADR-0002 Decision 7 relies on literal
$expandrows following the rules ofwith:.