guan404ming commented on issue #69288:
URL: https://github.com/apache/airflow/issues/69288#issuecomment-5094074264
Hi @jason810496 @shivaam,
Thanks for the discussion about the design. Overall LGTM as well and I'd
like to propose some adjustments to the shape to make it better.
- **Single source for `taskId`**: it currently appears twice (variable name
+ `spec.taskId`). Taking it as the first argument avoids drift on rename.
- **Handlers as plain functions**: keeping `run` standalone lets one handler
be reused across Dags.
For referencing the source argument name in TS -> object keys + a runtime
`args` schema in `spec`, no tag mechanism needed:
```ts
const pipeline = new Dag({ dagId: "example_pipeline", schedule: "@daily" });
const extract = pipeline.task("extract", {
run: extractFn,
spec: { retries: 3 },
});
const transform = pipeline.task("transform", {
run: async ({ region_code: region }) => { ... },
spec: {
args: { region_code: { type: "string" } },
},
});
```
- Naming: schema keys are the source argument names; destructuring
(region_code: region) handles differing local names. Caller side works the same
way: `pythonTask({ region_code: someOutput })`. Object keys survive
minification, so no reflection needed.
- Validation: TS types are erased at runtime (unlike Go's reflectable
structs), so the runtime schema is what lets us validate arg_bindings before
invoking the handler, and it serializes straight to the #69757 JSON-schema
annotations.
- Codegen: the args shape can be generated from serialization/schema.json
along with the rest of Spec, and handler param types inferred from it —> single
source of truth.
About `registerDags(d1, d2)`, which LGTM. For casing I'd keep lowercase task
since uppercase methods are unusual in TS even for factories.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]