Repository navigation
TS SDK: minify packed bundles and find them by metadata, not filename - #73126
jason810496 merged 1 commit into
Conversation
3d54b56 to
df24628
Compare
pierrejeambrun
left a comment
There was a problem hiding this comment.
Thanks one feedback regarding "keepNames"
NodeCoordinator looked for exactly `bundle.mjs` in each configured root, so a `bundles_root` could hold only one bundle and its name was fixed. That defeats the Dag-to-bundle routing the embedded metadata already supports, and it is out of step with JavaCoordinator and ExecutableCoordinator, which walk their roots and select on metadata. Each root is now searched recursively for `*.min.mjs` bundles, so one directory can hold several and each Dag is routed to whichever bundle declares it. Roots are searched in configured order and each directory in sorted path order, so which bundle wins no longer depends on the order a filesystem returns entries in. `airflow-ts-pack` gains `--outfile` for naming the artifact. esbuild output is also minified now. An integrity digest over the code region is only worth taking when the artifact is not something anyone is expected to read or edit in place, which is what `.min` records. Dependencies' license banners are preserved. Identifier names are not: nothing identifies a Dag, a task, or a handler by a function name, so there is nothing for minification to break, and ADR-0002 already settled that a bundle-wide `keepNames` is not how a name reaches the registration that needs it. The bundle container format is unchanged; minification only changes which bytes land inside the already-digested code region.
df24628 to
3c76d37
Compare
There was a problem hiding this comment.
Addressed in the latest commit, thanks.
I don't see the 'onLoad' here, do you plan on adding
In the case of mixed language TaskHandler, since user need to explicitly mention task_id (new TaskHandler(dagId, taskId, handler)), so it's fine to minify without keeping the function name.
taskid remains 'optional' for mixed dag as documented here #73126.
task_id is optional but should probably be written out here.** Most of the time because of
naming convention difference between python and typescript, names won't match. Omitting it defaults
the id to the handler's function name —new TaskHandler(transformStep)binds the"transformStep"fn to the
"transformStep" task. On the other handnew TaskHandler("transform_step", transformStep)will bind to
"transform_step" task.
Should we add the onLoad in this PR or did you plan to add it later? (Did I get it wrong and you want to keep 'taskId' required for mixed dag? I thought about it when drafting #73126 but didn't want to enforce that. Mostly for consistency with the native dag and also because that's probably the expected behavior, especially if those are double checked at parse time, it won't be too bad if there is a mismatch. Many 'single word' task ID will still match and can rely on this feature 'transform', 'extract', 'load', etc.).
There was a problem hiding this comment.
Omitting it defaults
the id to the handler's function name —new TaskHandler(transformStep)binds the"transformStep"fn to the
"transformStep" task. On the other handnew TaskHandler("transform_step", transformStep)will bind to
"transform_step" task.
I overlooked this part in previous review. The signature should be new TaskHandler(mandatory dag_id, optional task_id, fn), the ADR recorded it incorrect (missing the dag_id from the signature).
I'd like to have a follow-up PR that fixes the statement, make the task_id in TaskHandler optional and add the onLoad hook in the packing stage.
|
Actually in the case of Go SDK:
How about let's follow the same convention as Go SDK side as well on TS SDK? Since whether to omit the task_id makes more sense in the native Dag feature. |
|
Ok let's do that, let me update the ts ADR |
Why
NodeCoordinatorhard coded thebundle.mjswhen discovery, so abundles_rootcould hold only one bundle and its name was fixed. That defeats the Dag-to-bundle routing the embedded metadata already supports.How
*.min.mjsand select on metadata likeJavaCoordinatorwalks for*.jarandExecutableCoordinatorwalks for executables. One root can now hold several bundles, and each Dag is routed to whichever bundle declares it.anyone reads or edits in place, which is what
.minrecords.airflow-ts-packgains--outfile, rejecting it alongside--outdirand rejecting a name the coordinator couldnever find.
The bundle container format is unchanged. Minification only changes which bytes land inside the already-digested code region.
Was generative AI tooling used to co-author this PR?