jason810496 commented on code in PR #71189:
URL: https://github.com/apache/airflow/pull/71189#discussion_r4182767860
##########
java-sdk/processor/src/main/kotlin/org/apache/airflow/sdk/BuilderProcessor.kt:
##########
@@ -190,46 +231,206 @@ class BuilderProcessor : AbstractProcessor() {
explicitConfig(el, DAG_ANNOTATION, DAG_STRUCTURAL_ATTRIBUTES,
SchemaFields.DAG).forEach { (key, value) ->
buildMethod.addStatement($$"dag.config($S, $L)", key, value)
}
-
- for (inner in el.enclosedElements) {
- if (inner !is ExecutableElement) continue
- if (inner.isVarArgs) throw IllegalArgumentException("Cannot create task
from vararg function ${inner.simpleName}")
-
- val taskAnn = inner.getAnnotation(Builder.Task::class.java) ?: continue
- val innerName =
inner.simpleName.toString().replaceFirstChar(Char::uppercase)
-
- builderClass.addType(buildTask(innerName, inner, el))
-
+ if (deps != null) {
buildMethod.addStatement(
- $$"dag.addTask($L)",
- taskDefCode(inner, taskAnn.id.ifBlank { inner.simpleName.toString() },
innerName),
+ $$"return $T.record(dag, $T.of($L), new $T()::depends)",
+ REFS_TYPE,
+ ClassName.get(List::class.java),
+ CodeBlock.join(declarations.map { CodeBlock.of($$"$S", it.id) }, ", "),
+ ClassName.get(deps),
)
+ } else {
+ // No wiring class: register every task with no Java-side edges, which
+ // is the task-handler shape rather than a Dag Java owns.
+ declarations.forEach { decl ->
+ buildMethod.addStatement($$"dag.addTask($L)", taskDefCode(decl,
CodeBlock.of($$"$L", decl.className)))
+ }
+ buildMethod.addStatement("return dag")
Review Comment:
I agreed, the processor now rejects a `@Builder.Dag` class that declares no
`@Builder.Deps` class:
```
Dag class TestExample must declare a @Builder.Deps class implementing
TestExampleDeps to declare
its task graph; a class of task bodies for a Dag the Python file owns carries
@Builder.TaskHandler instead
```
Fixed in 23be1d072a6.
--
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]