Skip to content

Commit 86a344a

Browse files
jason810496claude
andcommitted
Java SDK: Describe native Java Dags without reference to Python
A Dag authored entirely in Java has no Python in the picture, so teaching its edge verbs as "Java's spelling of >> and <<" asks the reader to know a language the feature does not involve. The mixed-language surface keeps its Python references, because there the Python Dag file is part of what the reader has to understand. Co-Authored-By: Claude <noreply@anthropic.com>
1 parent e1cd364 commit 86a344a

3 files changed

Lines changed: 14 additions & 18 deletions

File tree

  • airflow-core/docs/authoring-and-scheduling/language-sdks
  • java-sdk

‎airflow-core/docs/authoring-and-scheduling/language-sdks/java.rst‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -537,16 +537,15 @@ calls with no arguments.
537537
Native Java Dags
538538
----------------
539539

540-
A Dag can also be authored entirely in Java, with no Python stub file: the ``DagDef`` and
541-
``TaskDef`` objects hold the tasks, and Java declares the graph.
540+
A Dag can also be authored entirely in Java: the ``DagDef`` and ``TaskDef`` objects hold the
541+
tasks, and Java declares the graph.
542542

543543
Building the Dag in Java
544544
~~~~~~~~~~~~~~~~~~~~~~~~
545545

546546
``dag.task(...)`` registers a task as it creates it and hands back a handle, so there is no second
547-
``addTask`` call to forget. ``before`` and ``after`` draw every edge on this surface — Python's
548-
``a >> b`` and ``b << a`` — and the task body moves the data itself, by reading the upstream's XCom
549-
through ``Client``:
547+
``addTask`` call to forget. ``before`` and ``after`` draw every edge on this surface, and the
548+
task body moves the data itself, by reading the upstream's XCom through ``Client``:
550549

551550
.. code-block:: java
552551

‎java-sdk/example/src/java/org/apache/airflow/example/nativedag/InterfaceExample.java‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,8 @@
2424

2525
import org.apache.airflow.sdk.*;
2626

27-
// A Dag defined entirely in Java, interface-style: no Python stub file
28-
// describes it. dag.task registers a task as it creates it and hands back the
29-
// handle, and `before`/`after` wire the graph -- Java's spelling of `>>` and `<<`.
27+
// A Dag defined entirely in Java, interface-style. dag.task registers a task as
28+
// it creates it and hands back the handle, and `before`/`after` wire the graph.
3029
public class InterfaceExample {
3130
private static final System.Logger log = System.getLogger(InterfaceExample.class.getName());
3231

‎java-sdk/sdk/src/main/kotlin/org/apache/airflow/sdk/Deps.kt‎

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,19 @@ interface Deps {
2424
/**
2525
* A point in the task graph: one task, or a set of them.
2626
*
27-
* [Flow] is Java's spelling of Python's `>>` and `<<`, for a dependency
28-
* where nothing flows but the ordering. An edge that carries a value is
29-
* declared by passing the upstream's handle instead.
27+
* [Flow] declares a dependency where nothing flows but the ordering. An
28+
* edge that carries a value is declared by passing the upstream's handle
29+
* instead.
3030
*/
3131
interface Flow {
3232
/** The tasks at this point in the flow. */
3333
fun nodes(): List<TaskDef>
3434

3535
/**
36-
* Runs the tasks here before each of [next], carrying no value — Java's
37-
* spelling of Python's `>>`.
36+
* Runs the tasks here before each of [next], carrying no value.
3837
*
3938
* ```java
40-
* loaded.before(cleaned, notified); // load >> [cleanup, notify]
39+
* loaded.before(cleaned, notified); // cleanup and notify both wait for load
4140
* ```
4241
*
4342
* Variadic, so one call fans out, and it returns its own receiver: a
@@ -54,11 +53,10 @@ interface Deps {
5453
}
5554

5655
/**
57-
* Runs the tasks here after each of [previous], carrying no value —
58-
* Python's `<<`.
56+
* Runs the tasks here after each of [previous], carrying no value.
5957
*
6058
* ```java
61-
* cleaned.after(loaded, transformed); // [load, transform] >> cleanup
59+
* cleaned.after(loaded, transformed); // cleanup waits for load and transform
6260
* ```
6361
*
6462
* @param previous Tasks that run before the ones here.
@@ -76,7 +74,7 @@ interface Deps {
7674
* every edge between two sets:
7775
*
7876
* ```java
79-
* Flow.of(a, b).before(c, d); // [a, b] >> [c, d]
77+
* Flow.of(a, b).before(c, d); // c and d both wait for a and b
8078
* ```
8179
*/
8280
@JvmStatic

0 commit comments

Comments
 (0)