You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "FrankYang0529 (via GitHub)" <gi...@apache.org> on 2026/10/10 02:42:45 UTC

[PR] Java SDK: Add edge labels to native Dags [airflow]

FrankYang0529 opened a new pull request, #74523:
URL: https://github.com/apache/airflow/pull/74523

   - `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.
   - A later label on the same edge replaces the earlier label.
   
   
    <!-- SPDX-License-Identifier: Apache-2.0
         https://www.apache.org/licenses/LICENSE-2.0 -->
   
   <!--
   Thank you for contributing!
   
   Please provide above a brief description of the changes made in this pull request.
   Write a good git commit message following this guide: https://chris.beams.io/posts/git-commit/
   
   Please make sure that your code changes are covered with tests.
   And in case of new features or big changes remember to adjust the documentation.
   
   For user-facing UI changes, please attach before/after screenshots (or a short
   screen recording) so reviewers can assess the visual impact.
   
   Feel free to ping (in general) for the review if you do not see reaction for a few days
   (72 Hours is the minimum reaction time you can expect from volunteers) - we sometimes miss notifications.
   
   In case of an existing issue, reference it using one of the following:
   
   * closes: #ISSUE
   * related: #ISSUE
   -->
   
   ---
   
   ##### Was generative AI tooling used to co-author this PR?
   
   <!--
   If generative AI tooling has been used in the process of authoring this PR, please
   change below checkbox to `[X]` followed by the name of the tool, uncomment the "Generated-by".
   -->
   
   - [X] Yes - Claude Code
   
   <!--
   Generated-by: [Tool Name] following [the guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)
   -->
   
   


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Java SDK: Add edge labels to native Dags [airflow]

Posted by "jason810496 (via GitHub)" <gi...@apache.org>.
jason810496 merged PR #74523:
URL: https://github.com/apache/airflow/pull/74523


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Java SDK: Add edge labels to native Dags [airflow]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #74523:
URL: https://github.com/apache/airflow/pull/74523#issuecomment-6281499553

   ### Backport successfully created: v3-4-test
   
   Note: As of [Merging PRs targeted for Airflow 3.X](https://github.com/apache/airflow/blob/main/dev/README_AIRFLOW3_DEV.md#merging-prs-targeted-for-airflow-3x)
   the committer who merges the PR is responsible for backporting the PRs that are bug fixes (generally speaking) to the maintenance branches.
   
   In matter of doubt please ask in [#release-management](https://apache-airflow.slack.com/archives/C03G9H97MM2) Slack channel.
   
   <table>
           <tr>
           <th>Status</th>
           <th>Branch</th>
           <th>Result</th>
       </tr>
       <tr>
           <td>✅</td>
           <td>v3-4-test</td>
           <td><a href="https://github.com/apache/airflow/pull/75173"><img src="https://img.shields.io/badge/PR-75173-blue" alt="PR Link"></a></td>
       </tr>
   </table>


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Java SDK: Add edge labels to native Dags [airflow]

Posted by "uranusjr (via GitHub)" <gi...@apache.org>.
uranusjr commented on PR #74523:
URL: https://github.com/apache/airflow/pull/74523#issuecomment-6144239185

   Python uses the `>> Label >>` syntax because this naturally reads like having a label in the arrow. This does not read as well in other languages without `>>`, and makes even less sense with `before`.
   
   I think we should come up with a better syntax instead just copying Python with `>>` and `<<` substituted.


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Java SDK: Add edge labels to native Dags [airflow]

Posted by "FrankYang0529 (via GitHub)" <gi...@apache.org>.
FrankYang0529 commented on PR #74523:
URL: https://github.com/apache/airflow/pull/74523#issuecomment-6263873433

   Thanks for the suggestion. The label term between tasks is more clear. I switched to following syntax:
   
   ```java
   loaded.before(Label.of("when empty").on(reportEmpty), Label.of("when suspicious").on(reportSuspicious));
   ```
   
   About Python syntax:
   - `a >> Label("forks") >> [b, c]` labels both edges.
   - `a >> [Label("x") >> b, Label("y") >> c]` draws both edges but labels neither, and raises no error. When `Label("x") >> b` runs, the label has no upstream yet, and the expression returns `b`. So the outer expression is just `a >> [b, c]`.
   
   `on` can take several tasks, so the first form maps to:
   
   ```java
   loaded.before(Label.of("forks").on(reportEmpty, reportSuspicious)); // a >> Label("forks") >> [b, c]
   ```
   
   To keep the text between the tasks, I did not add `loaded.labeled("forks")`. `after` also works with the same syntax:
   
   ```java
   cleaned.after(Label.of("always").on(loaded)); // load >> Label("always") >> cleanup
   ```
   
   The Go SDK (`airflow.Label(node, text)`) and the TS SDK (`label(node, text)`) both put the task first. Should those two SDKs follow the Java syntax?


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Java SDK: Add edge labels to native Dags [airflow]

Posted by "FrankYang0529 (via GitHub)" <gi...@apache.org>.
FrankYang0529 commented on PR #74523:
URL: https://github.com/apache/airflow/pull/74523#issuecomment-6160343537

   Thanks for the comments and suggestions.
   
   I agree with Jason that Java checks every varargs argument against the same type. A `before(Object...)` signature would accept the call above, but it would also accept nodes and labels in any order. Only a runtime check could then catch a misplaced label.
   
   With each label still paired with its node, two changes may make the Java code read better. WDYT?
   
   1. Add a `labeled` method to the node so that each call reads more like an arrow with a label on it:
   
      ```java
      loaded.before(reportEmpty.labeled("when empty"), reportSuspicious.labeled("when suspicious"));
      cleaned.after(loaded.labeled("always"));
      ```
   
     A bad part is that `labeled` becomes a reserved name for task methods inside a task group, because the generated view of a group inherits every method of the node type.
   
   2. Let `Then`, `Else` and `Case` take a label directly, because labels are used most often on branches:
   
      ```java
      dag.If(HasRows.class).Then(load, "rows found").Else(reportEmpty, "no rows");
      dag.Switch(PickPath.class).Case(handleLong, "long").Case(handleShort, "short");
      ```


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Java SDK: Add edge labels to native Dags [airflow]

Posted by "jason810496 (via GitHub)" <gi...@apache.org>.
jason810496 commented on PR #74523:
URL: https://github.com/apache/airflow/pull/74523#issuecomment-6281465340

   
   > The Go SDK (`airflow.Label(node, text)`) and the TS SDK (`label(node, text)`) both put the task first. Should those two SDKs follow the Java syntax?
   
   The TS SDK side edge label just merged yesterday btw.
   Yes, let's align the Java side syntax please, thanks a lot.
   
   


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Java SDK: Add edge labels to native Dags [airflow]

Posted by "FrankYang0529 (via GitHub)" <gi...@apache.org>.
FrankYang0529 commented on PR #74523:
URL: https://github.com/apache/airflow/pull/74523#issuecomment-6285258320

   > > The Go SDK (`airflow.Label(node, text)`) and the TS SDK (`label(node, text)`) both put the task first. Should those two SDKs follow the Java syntax?
   > 
   > The TS SDK side edge label just merged yesterday btw. Yes, let's align the Java side syntax please, thanks a lot.
   
   Go SDK: https://github.com/apache/airflow/pull/75185
   TS SDK: https://github.com/apache/airflow/pull/75190


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Java SDK: Add edge labels to native Dags [airflow]

Posted by "uranusjr (via GitHub)" <gi...@apache.org>.
uranusjr commented on PR #74523:
URL: https://github.com/apache/airflow/pull/74523#issuecomment-6261858194

   I feel it’d make more sense to put the label before the task. Maybe something like
   
   ```java
   loaded.before(Label.of("when empty").on(reportEmpty), Label.of("when suspicious").on(reportSuspicious))
   ```
   
   I’m not sure if Python currently has both `a >> label >> [b, c]` and `a >> [label_for_b >> b, label_for_c >> c]` (label before or after the flow forks). If this is a thing, it also makes sense to also have
   
   ```java
   loaded.labeled("forks").before(reportEmpty, reportSuspicious)
   ```
   
   It’s more difficult to come up with a syntax for `after` (since that one is backwards by design), but the general idea is to keep the label text between the tasks to reflect its position in the rendered graph.


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org