Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
machinePreset -> machine
  • Loading branch information
nicktrn committed Jan 14, 2025
commit d21003c4b415c30656294583b6d6d1393ea5084b
18 changes: 9 additions & 9 deletions .changeset/gold-melons-fetch.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,25 @@ Add support for specifying machine preset at trigger time. Works with any trigge
await childTask.trigger({ message: "Hello, world!" });

// This will override the task's machine preset and any defaults. Works with all trigger functions.
await childTask.trigger({ message: "Hello, world!" }, { machinePreset: "small-2x" });
await childTask.triggerAndWait({ message: "Hello, world!" }, { machinePreset: "small-2x" });
await childTask.trigger({ message: "Hello, world!" }, { machine: "small-2x" });
await childTask.triggerAndWait({ message: "Hello, world!" }, { machine: "small-2x" });

await childTask.batchTrigger([
{ payload: { message: "Hello, world!" }, options: { machinePreset: "micro" } },
{ payload: { message: "Hello, world!" }, options: { machinePreset: "large-1x" } },
{ payload: { message: "Hello, world!" }, options: { machine: "micro" } },
{ payload: { message: "Hello, world!" }, options: { machine: "large-1x" } },
]);
await childTask.batchTriggerAndWait([
{ payload: { message: "Hello, world!" }, options: { machinePreset: "micro" } },
{ payload: { message: "Hello, world!" }, options: { machinePreset: "large-1x" } },
{ payload: { message: "Hello, world!" }, options: { machine: "micro" } },
{ payload: { message: "Hello, world!" }, options: { machine: "large-1x" } },
]);

await tasks.trigger<typeof childTask>(
"child",
{ message: "Hello, world!" },
{ machinePreset: "small-2x" }
{ machine: "small-2x" }
);
await tasks.batchTrigger<typeof childTask>("child", [
{ payload: { message: "Hello, world!" }, options: { machinePreset: "micro" } },
{ payload: { message: "Hello, world!" }, options: { machinePreset: "large-1x" } },
{ payload: { message: "Hello, world!" }, options: { machine: "micro" } },
{ payload: { message: "Hello, world!" }, options: { machine: "large-1x" } },
]);
```
2 changes: 1 addition & 1 deletion apps/webapp/app/v3/services/triggerTask.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ export class TriggerTaskService extends BaseService {
: undefined,
runTags: bodyTags,
oneTimeUseToken: options.oneTimeUseToken,
machinePreset: body.options?.machinePreset,
machinePreset: body.options?.machine,
},
});

Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/v3/schemas/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export const TriggerTaskRequestBody = z.object({
metadata: z.any(),
metadataType: z.string().optional(),
maxDuration: z.number().optional(),
machinePreset: MachinePresetName.optional(),
machine: MachinePresetName.optional(),
})
.optional(),
});
Expand Down Expand Up @@ -133,7 +133,7 @@ export const BatchTriggerTaskItem = z.object({
metadataType: z.string().optional(),
maxDuration: z.number().optional(),
parentAttempt: z.string().optional(),
machinePreset: MachinePresetName.optional(),
machine: MachinePresetName.optional(),
})
.optional(),
});
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/v3/types/tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -780,7 +780,7 @@ export type TriggerOptions = {
/**
* The machine preset to use for this run. This will override the task's machine preset and any defaults.
*/
machinePreset?: MachinePresetName;
machine?: MachinePresetName;
};

export type TriggerAndWaitOptions = Omit<TriggerOptions, "idempotencyKey" | "idempotencyKeyTTL">;
Expand Down
30 changes: 15 additions & 15 deletions packages/trigger-sdk/src/v3/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ import type {
TaskOutputHandle,
TaskPayload,
TaskRunResult,
TaskRunResultFromTask,
TaskSchema,
TaskWithSchema,
TaskWithSchemaOptions,
Expand All @@ -75,6 +74,7 @@ import type {
TriggerOptions,
AnyTaskRunResult,
BatchTriggerAndWaitOptions,
BatchTriggerTaskV2RequestBody,
} from "@trigger.dev/core/v3";

export type {
Expand Down Expand Up @@ -613,9 +613,9 @@ export async function batchTriggerById<TTask extends AnyTask>(
parentAttempt: taskContext.ctx?.attempt.id,
metadata: item.options?.metadata,
maxDuration: item.options?.maxDuration,
machinePreset: item.options?.machinePreset,
machine: item.options?.machine,
},
};
} satisfies BatchTriggerTaskV2RequestBody["items"][0];
})
),
},
Expand Down Expand Up @@ -787,9 +787,9 @@ export async function batchTriggerByIdAndWait<TTask extends AnyTask>(
maxAttempts: item.options?.maxAttempts,
metadata: item.options?.metadata,
maxDuration: item.options?.maxDuration,
machinePreset: item.options?.machinePreset,
machine: item.options?.machine,
},
};
} satisfies BatchTriggerTaskV2RequestBody["items"][0];
})
),
dependentAttempt: ctx.attempt.id,
Expand Down Expand Up @@ -949,9 +949,9 @@ export async function batchTriggerTasks<TTasks extends readonly AnyTask[]>(
parentAttempt: taskContext.ctx?.attempt.id,
metadata: item.options?.metadata,
maxDuration: item.options?.maxDuration,
machinePreset: item.options?.machinePreset,
machine: item.options?.machine,
},
};
} satisfies BatchTriggerTaskV2RequestBody["items"][0];
})
),
},
Expand Down Expand Up @@ -1125,9 +1125,9 @@ export async function batchTriggerAndWaitTasks<TTasks extends readonly AnyTask[]
maxAttempts: item.options?.maxAttempts,
metadata: item.options?.metadata,
maxDuration: item.options?.maxDuration,
machinePreset: item.options?.machinePreset,
machine: item.options?.machine,
},
};
} satisfies BatchTriggerTaskV2RequestBody["items"][0];
})
),
dependentAttempt: ctx.attempt.id,
Expand Down Expand Up @@ -1204,7 +1204,7 @@ async function trigger_internal<TRunTypes extends AnyRunTypes>(
parentAttempt: taskContext.ctx?.attempt.id,
metadata: options?.metadata,
maxDuration: options?.maxDuration,
machinePreset: options?.machinePreset,
machine: options?.machine,
},
},
{
Expand Down Expand Up @@ -1264,9 +1264,9 @@ async function batchTrigger_internal<TRunTypes extends AnyRunTypes>(
parentAttempt: taskContext.ctx?.attempt.id,
metadata: item.options?.metadata,
maxDuration: item.options?.maxDuration,
machinePreset: item.options?.machinePreset,
machine: item.options?.machine,
},
};
} satisfies BatchTriggerTaskV2RequestBody["items"][0];
})
),
},
Expand Down Expand Up @@ -1358,7 +1358,7 @@ async function triggerAndWait_internal<TIdentifier extends string, TPayload, TOu
maxAttempts: options?.maxAttempts,
metadata: options?.metadata,
maxDuration: options?.maxDuration,
machinePreset: options?.machinePreset,
machine: options?.machine,
},
},
{},
Expand Down Expand Up @@ -1435,9 +1435,9 @@ async function batchTriggerAndWait_internal<TIdentifier extends string, TPayload
maxAttempts: item.options?.maxAttempts,
metadata: item.options?.metadata,
maxDuration: item.options?.maxDuration,
machinePreset: item.options?.machinePreset,
machine: item.options?.machine,
},
};
} satisfies BatchTriggerTaskV2RequestBody["items"][0];
})
),
dependentAttempt: ctx.attempt.id,
Expand Down