jason810496 commented on code in PR #77229:
URL: https://github.com/apache/airflow/pull/77229#discussion_r4736743675
##########
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:
`DagRunType` comes from the generated module, so it leaks into the public
types. Could we hand-write the union here and having a unit test to avoid
drift, like `DagRunState`, and export it from `index.ts`?
##########
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:
Since `dagRun` now holds `dagId`, `runId` and `conf`, should we drop the
flat ones? The Java and Go contexts only expose the Dag run.
--
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]