09413a62a4
* PropertyTable component changed to use sub components * Separate run span component * Early WIP on tabs that use search query * Shortcut key tabs for the span panel * The span timeline is working * When runs get expired, update the OTEL event with an error * Improved the expired error message * Reveal env vars when editing * Tightened things up a bit * Added detail tab properties * Progress dashed line * Move the env label next to the Run number title * Top level cancel/replay buttons * Replay with a different payload and environment * Fix for non json payloads * Hide the clear/copy buttons * UI improvements with large payloads * Close the panels when you replay/cancel * Added the new timeline to spans * Use the u-turn left icon for replay * Added an index for spanId on TaskRun * Remove replay/cancel buttons the span view * Replay shortcut works inside the code editor * Split the log/span inspector between Overview and Detail as well * More improvements to the inspector * Context and output improvements * Focus on run working * Added version to run.ctx * Added some padding to the detail view * Added context tab with shortcut * Only load the replay data when the dialog is open * Replaying uses the tags from the original run * Links are now text links * Removed version links for now because we don’t have dropdown filters for them yet * Tabs are now outside of the scrollview * The inspector is now 30% of the width by default * Allow replaying and editing SuperJSON payloads * Deleted unused CodeGroup file * Increase the tags limit to 5, do the limiting on the server * The admin tooltip now always shows basic org, project and user info * Fix for schedule inspector disabled state layout * Remove new unused span metadata and context * Removed unused import
44 lines
1.3 KiB
TypeScript
44 lines
1.3 KiB
TypeScript
import { MachineConfig, MachinePreset, MachinePresetName } from "@trigger.dev/core/v3";
|
|
import { defaultMachine, machines } from "@trigger.dev/platform/v3";
|
|
import { logger } from "~/services/logger.server";
|
|
|
|
export function machinePresetFromConfig(config: unknown): MachinePreset {
|
|
const parsedConfig = MachineConfig.safeParse(config);
|
|
|
|
if (!parsedConfig.success) {
|
|
logger.error("Failed to parse machine config", { config });
|
|
|
|
return machinePresetFromName("small-1x");
|
|
}
|
|
|
|
if (parsedConfig.data.preset) {
|
|
return machinePresetFromName(parsedConfig.data.preset);
|
|
}
|
|
|
|
if (parsedConfig.data.cpu && parsedConfig.data.memory) {
|
|
const name = derivePresetNameFromValues(parsedConfig.data.cpu, parsedConfig.data.memory);
|
|
|
|
return machinePresetFromName(name);
|
|
}
|
|
|
|
return machinePresetFromName("small-1x");
|
|
}
|
|
|
|
export function machinePresetFromName(name: MachinePresetName): MachinePreset {
|
|
return {
|
|
name,
|
|
...machines[name],
|
|
};
|
|
}
|
|
|
|
// Finds the smallest machine preset name that satisfies the given CPU and memory requirements
|
|
function derivePresetNameFromValues(cpu: number, memory: number): MachinePresetName {
|
|
for (const [name, preset] of Object.entries(machines)) {
|
|
if (preset.cpu >= cpu && preset.memory >= memory) {
|
|
return name as MachinePresetName;
|
|
}
|
|
}
|
|
|
|
return defaultMachine;
|
|
}
|