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


##########
ts-sdk/README.md:
##########
@@ -65,6 +65,23 @@ A Dag also has order-only dependencies (`before` and 
`after`), task groups, bran
 
[guide](https://airflow.apache.org/docs/apache-airflow/stable/authoring-and-scheduling/language-sdks/typescript.html)
 for all of them.
 
+To trigger another Dag with a specific logical date and earliest start time:
+
+```ts
+import { triggerDagRun } from "apache-airflow-ts-sdk";

Review Comment:
   This import should be `@apache-airflow/ts-sdk`, the package name in 
`package.json`



##########
ts-sdk/src/sdk/trigger-dag-run.ts:
##########
@@ -119,6 +127,13 @@ function checkType(name: string, value: unknown, type: 
"string" | "boolean"): vo
   }
 }
 
+function checkDate(name: string, value: unknown, allowNull = false): void {
+  if (value === undefined || (allowNull && value === null)) return;
+  if (!(value instanceof Date) || Number.isNaN(value.getTime())) {

Review Comment:
   Could we also reject years outside 1 to 9999 as Go `checkTime` does, since 
`pythonIsoformat` assumes four digits



##########
ts-sdk/src/sdk/trigger-dag-run-execute.ts:
##########
@@ -34,8 +35,17 @@ export async function executeTriggerDagRun(
   op: OperatorContext,
 ): Promise<OperatorOutcome> {
   const { client, logs } = op;
-  const logicalDate = new Date();
-  const runId = trigger.runId ?? `manual__${pythonIsoformat(logicalDate)}`;
+  const logicalDate =
+    trigger.logicalDate === undefined
+      ? trigger.runAfter === undefined
+        ? new Date()
+        : null
+      : trigger.logicalDate;
+  const runAfter = trigger.runAfter?.toISOString();
+  const runId =
+    trigger.runId ??
+    `manual__${pythonIsoformat(runAfter ? trigger.runAfter! : (logicalDate ?? 
new Date()))}` +

Review Comment:
   nit: `trigger.runAfter ?? logicalDate ?? new Date()` gives the same date 
without the non-null assertion



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