Repository navigation
Java SDK: Add edge labels to native Dags - #74523
Conversation
There was a problem hiding this comment.
Nice, thanks.
I pushed 255a2b1 on top with a few fixes from review:
- Labels are now applied in the order they were set, so the label set last wins, as in Python's
DAG.set_edge_info. Before, a task edge's own label always beat its group edge's label, and relabeling an existing
group edge didn't take effect. - Updated
EdgeLabelTestto match. I checked both cases against Python'sLabel, and theedge_infomatches. - Corrected the KDoc and docs note: Python's
Labelalso changes the edge when one end is in no task group.
|
Python uses the I think we should come up with a better syntax instead just copying Python with |
There was a problem hiding this comment.
I think we should come up with a better syntax instead just copying Python with
>>and<<substituted.
I considered the following syntax before:
loaded.before(reportEmpty, "when empty");
cleaned.after(loaded, "always");However, the wiring should supports fan-in and fan-out.
loaded.before(reportEmpty, "when empty", reportSuspicious, "when suspicious"); // this is not a working syntax to support fan-in.
// the only sutiable way might looks like:
loaded.before([reportEmpty, reportSuspicious], ["when empty", "when suspicious"]);
loaded.before([reportEmpty,"when empty"], [reportSuspicious,, "when suspicious"]); This is why the current syntax goes with current shape, having a dedicated Flow.label wrapper to representing the edge with label:
loaded.before(Flow.label(reportEmpty, "when empty"), Flow.label(reportSuspicious, "when suspicious"));
cleaned.after(Flow.label(loaded, "always"));The Go-SDK went with the same shape already and there was't objection back then.
I don't have a better user interface design at this moment.
255a2b1 to
ab70317
Compare
|
Thanks for the comments and suggestions. I agree with Jason that Java checks every varargs argument against the same type. A With each label still paired with its node, two changes may make the Java code read better. WDYT?
A bad part is that
|
jason810496
left a comment
There was a problem hiding this comment.
Hi @uranusjr,
Please let me know if there's any further concern from merging this PR when you have a moment, thanks.
|
I feel it’d make more sense to put the label before the task. Maybe something like loaded.before(Label.of("when empty").on(reportEmpty), Label.of("when suspicious").on(reportSuspicious))I’m not sure if Python currently has both loaded.labeled("forks").before(reportEmpty, reportSuspicious)It’s more difficult to come up with a syntax for |
ab70317 to
f1c4362
Compare
|
Thanks for the suggestion. The label term between tasks is more clear. I switched to following syntax: loaded.before(Label.of("when empty").on(reportEmpty), Label.of("when suspicious").on(reportSuspicious));About Python syntax:
loaded.before(Label.of("forks").on(reportEmpty, reportSuspicious)); // a >> Label("forks") >> [b, c]To keep the text between the tasks, I did not add cleaned.after(Label.of("always").on(loaded)); // load >> Label("always") >> cleanupThe Go SDK ( |
Signed-off-by: PoAn Yang <payang@apache.org>
A task edge's own label always won over a group edge's label, and a relabeled group edge kept its first position, so edge_info differed from Python's, where the label set last wins. Also note that Python's Label rewrites an edge when one end is in no task group. Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: PoAn Yang <payang@apache.org>
f1c4362 to
7ffa469
Compare
The TS SDK side edge label just merged yesterday btw. |
Backport successfully created: v3-4-testNote: As of Merging PRs targeted for Airflow 3.X In matter of doubt please ask in #release-management Slack channel.
|
* Java SDK: Add edge labels to native Dags Signed-off-by: PoAn Yang <payang@apache.org> * Apply edge labels in the order they were set A task edge's own label always won over a group edge's label, and a relabeled group edge kept its first position, so edge_info differed from Python's, where the label set last wins. Also note that Python's Label rewrites an edge when one end is in no task group. * Java SDK: Write the edge label text before the task Signed-off-by: PoAn Yang <payang@apache.org> --------- (cherry picked from commit 5a64dfc) Co-authored-by: PoAn Yang <payang@apache.org> Signed-off-by: PoAn Yang <payang@apache.org> Co-authored-by: ZHE YOU LIU <zhu424.dev@gmail.com>
Deps.Flow.label(flow, text)wraps one end of an edge. Each edge of a fan-out can then carry its own label. Declaring an existing edge again only adds the label to that edge.Was generative AI tooling used to co-author this PR?