Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 20 additions & 20 deletions ts-sdk/src/coordinator/serde.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,21 +100,19 @@ function serializeEdgeInfo(dag: Dag): SerializedValue {
return info;
}

/** The Dags this one's tasks depend on, for the UI dependency graph. */
function serializeDagDependencies(dag: Dag): SerializedValue {
const dependencies: SerializedValue[] = [];
for (const [taskId, record] of getDagTaskRecords(dag)) {
for (const dependency of record.operator?.getDagDependencies?.() ?? []) {
dependencies.push({
source: dag.dagId,
target: dependency.target,
label: taskId,
dependency_type: dependency.dependencyType,
dependency_id: taskId,
});
}
}
return dependencies;
/** The Dags this task depends on, for the UI dependency graph. */
function serializeDagDependencies(
dagId: string,
taskId: string,
record: TaskRecord,
): SerializedValue[] {
return (record.operator?.getDagDependencies?.() ?? []).map((dependency) => ({
source: dagId,
target: dependency.target,
label: taskId,
dependency_type: dependency.dependencyType,
dependency_id: taskId,
}));
}

/** How one set of authoring fields is written into a serialized object. */
Expand Down Expand Up @@ -164,6 +162,7 @@ export function serializeDag(
): Record<string, SerializedValue> {
const graph = buildDagGraph(dag);
const inputs = getDagTaskInputs(dag);
const dagDependencies: SerializedValue[] = [];
const data: Record<string, SerializedValue> = {
dag_id: dag.dagId,
fileloc,
Expand All @@ -174,17 +173,18 @@ export function serializeDag(
// a native TypeScript Dag's cron is read in UTC.
timezone: "UTC",
timetable: serializeTimetable(dag.spec.schedule, dag.dagId),
tasks: [...getDagTaskRecords(dag)].map(([taskId, record]) =>
serializeTask(
tasks: [...getDagTaskRecords(dag)].map(([taskId, record]) => {
dagDependencies.push(...serializeDagDependencies(dag.dagId, taskId, record));
return serializeTask(
dag.dagId,
taskId,
record,
graph.downstreamTaskIds.get(taskId),
inputs.get(taskId),
dag.spec.queue,
),
),
dag_dependencies: serializeDagDependencies(dag),
);
}),
dag_dependencies: dagDependencies,
task_group: serializeTaskGroups(dag, graph),
edge_info: serializeEdgeInfo(dag),
params: [],
Expand Down
Loading