pierrejeambrun commented on code in PR #73439:
URL: https://github.com/apache/airflow/pull/73439#discussion_r4133896994


##########
ts-sdk/src/sdk/dag.ts:
##########
@@ -406,6 +508,25 @@ export class Dag {
     taskIdOrHandler: string | ((args: TArgs) => TReturn | Promise<TReturn>),
     handlerOrOptions?: ((args: TArgs) => TReturn | Promise<TReturn>) | 
TaskOptions,
     maybeOptions?: TaskOptions,
+  ): TaskFactory<TArgs, TReturn> {
+    return this.#addTask(undefined, taskIdOrHandler, handlerOrOptions, 
maybeOptions);
+  }
+
+  /**
+   * Declare a task group of this Dag.
+   *
+   * The group prefixes the id of every task declared in it, and stands at
+   * either end of an order-only edge in its own right.
+   */
+  taskGroup(groupId: string): TaskGroupRef {
+    return this.#addGroup(undefined, groupId);
+  }

Review Comment:
   `prefix_group_id=True/False` similarly as the pyton implementation ? 



##########
ts-sdk/src/sdk/dag.ts:
##########
@@ -508,6 +639,70 @@ export class Dag {
     return spec as TaskSpec;
   }
 
+  #addGroup(parentGroupId: string | undefined, groupId: string): TaskGroupRef {
+    if (typeof groupId !== "string" || groupId.length === 0) {
+      throw new Error(`A task group of Dag "${this.dagId}" must have a 
non-empty ID`);
+    }
+    if (groupId.includes(GROUP_SEPARATOR)) {
+      // The separator is what joins a group to what it holds, so one inside an
+      // ID would make the resulting task id ambiguous.
+      throw new Error(
+        `Task group ID "${groupId}" of Dag "${this.dagId}" cannot contain ` +
+          `"${GROUP_SEPARATOR}"; nest groups with taskGroup(...) instead`,
+      );
+    }
+    if (this.#finalized) {
+      throw new Error(
+        `Task group "${groupId}" cannot be added to Dag "${this.dagId}" after 
the Dag was read; ` +
+          "declare every group while the module is loading",
+      );
+    }
+    const fullId = prefixWithGroup(parentGroupId, groupId);
+    this.#reserveNodeId(fullId, "Task group");
+    this.#groups.set(fullId, {
+      groupId: fullId,
+      ...(parentGroupId !== undefined && { parentGroupId }),

Review Comment:
   Does not check the same things as `validate_group_key` on the python side 



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