fix: adding more time log for the run status
This commit is contained in:
parent
c7727fc1be
commit
0ce07c88f8
@ -16,12 +16,14 @@ import { z } from "zod";
|
||||
const Request = z.object({
|
||||
run_id: z.string(),
|
||||
status: WorkflowRunStatusSchema.optional(),
|
||||
time: z.date().optional(),
|
||||
time: z.coerce.date().optional(),
|
||||
output_data: z.any().optional(),
|
||||
});
|
||||
|
||||
export async function POST(request: Request) {
|
||||
try {
|
||||
const [data, error] = await parseDataSafe(Request, request);
|
||||
|
||||
if (!data || error) return error;
|
||||
|
||||
const { run_id, status, time, output_data } = data;
|
||||
@ -108,4 +110,20 @@ export async function POST(request: Request) {
|
||||
status: 200,
|
||||
},
|
||||
);
|
||||
} catch (error: unknown) {
|
||||
console.log("An error here");
|
||||
|
||||
const errorMessage =
|
||||
error instanceof Error ? error.message : "Unknown error";
|
||||
console.log(errorMessage);
|
||||
|
||||
return NextResponse.json(
|
||||
{
|
||||
error: errorMessage,
|
||||
},
|
||||
{
|
||||
status: 500,
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,12 @@ export async function RunDisplay({
|
||||
<Dialog>
|
||||
<DialogTrigger asChild className="appearance-none hover:cursor-pointer">
|
||||
<TableRow>
|
||||
<TableCell>{run.number}</TableCell>
|
||||
<TableCell>
|
||||
<Tooltip>
|
||||
<TooltipTrigger>{run.number}</TooltipTrigger>
|
||||
<TooltipContent>{run.id}</TooltipContent>
|
||||
</Tooltip>
|
||||
</TableCell>
|
||||
<TableCell className="font-medium truncate">
|
||||
{run.machine?.name}
|
||||
</TableCell>
|
||||
@ -46,7 +51,12 @@ export async function RunDisplay({
|
||||
<Tooltip>
|
||||
<TooltipTrigger>{getDuration(run.duration)}</TooltipTrigger>
|
||||
<TooltipContent>
|
||||
<div>Cold start: {getDuration(run.cold_start_duration)}</div>
|
||||
<div>
|
||||
Serverless latency: {getDuration(run.comfy_deploy_cold_start)}
|
||||
</div>
|
||||
<div>
|
||||
GPU Cold start: {getDuration(run.cold_start_duration)}
|
||||
</div>
|
||||
<div>Run duration: {getDuration(run.run_duration)}</div>
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
|
@ -12,13 +12,21 @@ export function getRelativeTime(time: string | Date | null | undefined) {
|
||||
}
|
||||
|
||||
function formatDuration(seconds: number) {
|
||||
const minutes = Math.floor(seconds / 60);
|
||||
const hours = Math.floor(seconds / 3600);
|
||||
const minutes = Math.floor((seconds % 3600) / 60);
|
||||
const remainingSeconds = seconds % 60;
|
||||
if (minutes > 0) {
|
||||
return `${minutes}.${remainingSeconds} mins`;
|
||||
} else {
|
||||
return `${remainingSeconds.toFixed(1)} secs`;
|
||||
|
||||
let result = "";
|
||||
if (hours > 0) {
|
||||
result += `${hours} hrs `;
|
||||
}
|
||||
if (minutes > 0) {
|
||||
result += `${minutes} mins `;
|
||||
}
|
||||
if (remainingSeconds > 0) {
|
||||
result += `${remainingSeconds.toFixed(1)} secs`;
|
||||
}
|
||||
return result.trim();
|
||||
}
|
||||
|
||||
export function getDuration(durationInSecs: number) {
|
||||
|
@ -148,14 +148,14 @@ export const createRun = withServerPromise(
|
||||
body: JSON.stringify(_data),
|
||||
cache: "no-store",
|
||||
});
|
||||
console.log(___result);
|
||||
// console.log(___result);
|
||||
if (!___result.ok)
|
||||
throw new Error(
|
||||
`Error creating run, ${
|
||||
___result.statusText
|
||||
} ${await ___result.text()}`,
|
||||
);
|
||||
console.log(_data, ___result);
|
||||
// console.log(_data, ___result);
|
||||
break;
|
||||
case "runpod-serverless":
|
||||
const data = {
|
||||
@ -182,14 +182,14 @@ export const createRun = withServerPromise(
|
||||
body: JSON.stringify(data),
|
||||
cache: "no-store",
|
||||
});
|
||||
console.log(__result);
|
||||
// console.log(__result);
|
||||
if (!__result.ok)
|
||||
throw new Error(
|
||||
`Error creating run, ${
|
||||
__result.statusText
|
||||
} ${await __result.text()}`,
|
||||
);
|
||||
console.log(data, __result);
|
||||
// console.log(data, __result);
|
||||
break;
|
||||
case "classic":
|
||||
const body = {
|
||||
|
@ -27,6 +27,10 @@ export async function findAllRuns({
|
||||
sql<number>`(extract(epoch from ended_at) - extract(epoch from created_at))`.as(
|
||||
"duration",
|
||||
),
|
||||
comfy_deploy_cold_start:
|
||||
sql<number>`(extract(epoch from queued_at) - extract(epoch from created_at))`.as(
|
||||
"cold_start_duration",
|
||||
),
|
||||
cold_start_duration:
|
||||
sql<number>`(extract(epoch from started_at) - extract(epoch from queued_at))`.as(
|
||||
"cold_start_duration",
|
||||
|
Loading…
x
Reference in New Issue
Block a user