Show the console log on the job overview in the ui.

This commit is contained in:
Jaret Burkett
2025-03-21 11:45:36 -06:00
parent 0bbc69c135
commit 9a902c067f
6 changed files with 169 additions and 8 deletions

View File

@@ -0,0 +1,35 @@
import { NextRequest, NextResponse } from 'next/server';
import { PrismaClient } from '@prisma/client';
import path from 'path';
import fs from 'fs';
import { getTrainingFolder } from '@/server/settings';
const prisma = new PrismaClient();
export async function GET(request: NextRequest, { params }: { params: { jobID: string } }) {
const { jobID } = await params;
const job = await prisma.job.findUnique({
where: { id: jobID },
});
if (!job) {
return NextResponse.json({ error: 'Job not found' }, { status: 404 });
}
const trainingFolder = await getTrainingFolder();
const jobFolder = path.join(trainingFolder, job.name);
const logPath = path.join(jobFolder, 'log.txt');
if (!fs.existsSync(logPath)) {
return NextResponse.json({ log: '' });
}
let log = '';
try {
log = fs.readFileSync(logPath, 'utf-8');
} catch (error) {
console.error('Error reading log file:', error);
log = 'Error reading log file';
}
return NextResponse.json({ log: log });
}

View File

@@ -96,6 +96,7 @@ export async function GET(request: NextRequest, { params }: { params: { jobID: s
const additionalEnv: any = {
AITK_JOB_ID: jobID,
CUDA_VISIBLE_DEVICES: `${job.gpu_ids}`,
IS_AI_TOOLKIT_UI: '1'
};
// HF_TOKEN