Repository navigation
Conversation
| assert getattr(result.dags[0].get_task("t"), "is_stub", False) is True | ||
|
|
||
|
|
||
| def test_matching_arguments_pass(mock_bundle, monkeypatch): |
There was a problem hiding this comment.
Every declaration in this file has a single required=True param, so dropping if p.required in the builder keeps all five tests green. A case with TaskHandlerParam(name="limit", required=False) left out of run: would pin it. _patch_declaration's for_queue=lambda queue: coordinator ignores the queue, so routing by the task's queue: isn't tested either, and test_none_declaration_skips covers the same branch as test_no_declaration_available_skips_and_builds.
jason810496
left a comment
There was a problem hiding this comment.
Thanks for the filling up the gap.
| if missing := sorted({p.name for p in declaration.params if p.required} - run_names): | ||
| yield f"task {task.id_!r}: missing required handler argument(s) {missing}" | ||
| if unknown := sorted(run_names - {p.name for p in declaration.params}): | ||
| yield f"task {task.id_!r}: run argument(s) {unknown} are not parameters of its task handler" |
There was a problem hiding this comment.
Do we need to validate against the type like https://github.com/apache/airflow/pull/74067/changes#diff-a62ed98ec4693a9a9f43c7807c68805f64c92e233f808ce26121dcb70d03b81cR184 ?
e.g. reject a int literal being binded to a argument in list type
930bbc7 to
872aa73
Compare
This is the Python equivalent to the Language SDK ADR-0007 interface. The new interface allows a Dag author to write a Dag in YAML (other languages will also automatically work as long as they implement the stub interface), and wire up a PythonCoordinator in the configuration plus the correct queue mapping to have it execute a Python function at runtime.
This implements the Language SDK ADR-0011 interface between Python task handlers and the YAML Dag parser. This allows the parser to use the interface to validate 'run:' arguments against a matched task handler if it exists. As specified in ADR-0011, a missing task handler at parse-time does not fail parsing; the error is only surfaced at execution time.
872aa73 to
3fe883e
Compare
ccf4f1f to
4055abe
Compare
This implements a Python equivalent to Language SDK’s ADR-0011 interface as a
@task_handler(...)decorator function. The general design matches exactly to the ADR; a task handler is registered (with the decorator) under adag_id, task_idkey, and a coordinator is specified to find the handler.This information is used twice, once at parse-time to do a best-effort signature validation (as specified in ADR-0011), and again on execution through the same AIP-108 interface that routes a Python stub to non-Python task handlers.
While the feature as it stands now solely serves the YAML Dag format, it also is not specific to it. We now have the Python interface to allow Dags in any language to create a stub to resolve into a Python function at runtime—although no Dag formats currently have such a stub interface (except Python, but you don’t need this to call Python from Python in the first place).
Close #75273.