Mor ui work

This commit is contained in:
Jaret Burkett
2025-02-21 12:40:17 -07:00
parent ad87f72384
commit 2b6e66e0cb
7 changed files with 44 additions and 32 deletions

View File

@@ -70,7 +70,7 @@ export async function GET(request: NextRequest, { params }: { params: { jobID: s
return NextResponse.json({ error: 'run.py not found' }, { status: 500 });
}
console.log('Spawning command:', `AITK_JOB_ID=${jobID} CUDA_VISIBLE_DEVICES=${job.gpu_id} ${pythonPath} ${runFilePath} ${configPath}`);
console.log('Spawning command:', `AITK_JOB_ID=${jobID} CUDA_VISIBLE_DEVICES=${job.gpu_ids} ${pythonPath} ${runFilePath} ${configPath}`);
// start job
const subprocess = spawn(pythonPath, [runFilePath, configPath], {
@@ -79,7 +79,7 @@ export async function GET(request: NextRequest, { params }: { params: { jobID: s
env: {
...process.env,
AITK_JOB_ID: jobID,
CUDA_VISIBLE_DEVICES: `${job.gpu_id}`,
CUDA_VISIBLE_DEVICES: `${job.gpu_ids}`,
},
cwd: TOOLKIT_ROOT,
});

View File

@@ -9,16 +9,16 @@ export async function GET(request: Request) {
try {
if (id) {
const training = await prisma.job.findUnique({
const job = await prisma.job.findUnique({
where: { id },
});
return NextResponse.json(training);
return NextResponse.json(job);
}
const trainings = await prisma.job.findMany({
const jobs = await prisma.job.findMany({
orderBy: { created_at: 'desc' },
});
return NextResponse.json(trainings);
return NextResponse.json({ jobs: jobs });
} catch (error) {
console.error(error);
return NextResponse.json({ error: 'Failed to fetch training data' }, { status: 500 });
@@ -28,7 +28,7 @@ export async function GET(request: Request) {
export async function POST(request: Request) {
try {
const body = await request.json();
const { id, name, job_config, gpu_id } = body;
const { id, name, job_config, gpu_ids } = body;
if (id) {
// Update existing training
@@ -36,7 +36,7 @@ export async function POST(request: Request) {
where: { id },
data: {
name,
gpu_id,
gpu_ids,
job_config: JSON.stringify(job_config),
},
});
@@ -46,7 +46,7 @@ export async function POST(request: Request) {
const training = await prisma.job.create({
data: {
name,
gpu_id,
gpu_ids,
job_config: JSON.stringify(job_config),
},
});