FrankYang0529 commented on code in PR #73596:
URL: https://github.com/apache/airflow/pull/73596#discussion_r4151225262
##########
java-sdk/sdk/src/main/kotlin/org/apache/airflow/sdk/Context.kt:
##########
@@ -123,9 +123,14 @@ data class TaskInstance(
data class Context(
@JvmField val dagRun: DagRun,
@JvmField val ti: TaskInstance,
+ /** Registration of the executing task; resolves wired data inputs. */
+ internal val taskDef: TaskDef? = null,
Review Comment:
Agree with this comment. Adding taskDef to the constructor also breaks Java
callers. We can change it like following:
```diff
--- a/java-sdk/sdk/src/main/kotlin/org/apache/airflow/sdk/Context.kt
+++ b/java-sdk/sdk/src/main/kotlin/org/apache/airflow/sdk/Context.kt
data class Context(
@JvmField val dagRun: DagRun,
@JvmField val ti: TaskInstance,
- /** Registration of the executing task; resolves wired data inputs. */
- internal val taskDef: TaskDef? = null,
) {
+ /** Registration of the executing task; resolves wired data inputs. */
+ internal var taskDef: TaskDef? = null
+
internal companion object {
fun from(
request: StartupDetails,
taskDef: TaskDef? = null,
): Context =
Context(
dagRun = ...,
ti = with(request.ti) { TaskInstance(dagId, runId, taskId,
mapIndex, tryNumber) },
- taskDef = taskDef,
- )
+ ).also { it.taskDef = taskDef }
}
}
```
```diff
--- a/java-sdk/sdk/src/test/kotlin/org/apache/airflow/sdk/ArgTestSupport.kt
- return taskContext().copy(taskDef = def)
+ return taskContext().also { it.taskDef = def }
---
a/java-sdk/sdk/src/test/kotlin/org/apache/airflow/sdk/internal/ArgValuesTest.kt
- return contextWithoutTaskDef().copy(taskDef = def)
+ return contextWithoutTaskDef().also { it.taskDef = def }
```
--
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]