guan404ming commented on code in PR #77229:
URL: https://github.com/apache/airflow/pull/77229#discussion_r4750884148


##########
ts-sdk/src/sdk/task.ts:
##########
@@ -24,9 +24,30 @@
 
 import { AsyncLocalStorage } from "node:async_hooks";
 
+import type { DagRunType } from "../generated/supervisor.js";
 import type { JsonValue } from "./client-types.js";
 import type { TaskClient } from "./client.js";
 
+/** The Dag run that the current task instance belongs to. */
+export interface DagRun<TConf = Readonly<Record<string, JsonValue>>> {
+  /** Identifier of the Dag being run. */
+  readonly dagId: string;
+  /** Identifier of the Dag run. */
+  readonly runId: string;
+  /** Logical date of the Dag run, or `null` when the run has none. */
+  readonly logicalDate: Date | null;
+  /** Start of the Dag run data interval, or `null` when the run has none. */
+  readonly dataIntervalStart: Date | null;
+  /** End of the Dag run data interval, or `null` when the run has none. */
+  readonly dataIntervalEnd: Date | null;
+  /** Earliest time the Dag run can start, set even when the run has no 
logical date. */
+  readonly runAfter: Date;
+  /** How the Dag run was created, such as `"scheduled"` or `"manual"`. */
+  readonly runType: DagRunType;

Review Comment:
   Thanks, hand-wrote `DagRunType`, exported it from `index.ts`, and pinned it 
to the generated type in a test



##########
ts-sdk/src/sdk/task.ts:
##########
@@ -41,6 +62,8 @@ export interface TaskContext<TConf = Readonly<Record<string, 
JsonValue>>> {
   readonly mapIndex: number;
   /** `conf` of the Dag run, or `{}` when the run has none. */
   readonly conf: TConf;
+  /** The Dag run that this task instance belongs to. */
+  readonly dagRun: DagRun<TConf>;

Review Comment:
   `dagId` and `runId` shipped in `1.0.0`, and Go and Java keep both on 
`TaskInstance`, so I kept them



##########
ts-sdk/tests/coordinator/integration.test.ts:
##########
@@ -130,7 +130,15 @@ function makeStartupDetails(
     dag_rel_path: "test.py",
     bundle_info: { name: "test", version: null },
     start_date: "2026-04-23T00:00:00Z",
-    ti_context: tiContext,
+    ti_context: {
+      dag_run: {
+        dag_id: dagId,
+        run_id: runId,
+        run_after: "2026-04-23T00:00:00Z",
+        run_type: "manual",
+      },
+      ...tiContext,

Review Comment:
   `makeStartupDetails` now merges `dag_run` one level deeper, so partial runs 
keep the default ids and `run_after`



##########
ts-sdk/src/coordinator/runtime.ts:
##########
@@ -497,14 +497,30 @@ function responseType(body: unknown): string {
   return "unknown";
 }
 
+function toDate(value: string | null | undefined): Date | null {
+  return value ? new Date(value) : null;
+}

Review Comment:
   Unparsable nullable dates now log a warning and become `null` as Java does, 
with a test



-- 
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]

Reply via email to