import useJobsList from '@/hooks/useJobsList';
import Link from 'next/link';
import UniversalTable, { TableColumn } from '@/components/UniversalTable';
import { JobConfig, JobRecord } from '@/types';
import JobActionBar from './JobActionBar';
import HFJobStatus from './HFJobStatus';
interface JobsTableProps {
onlyActive?: boolean;
}
export default function JobsTable({ onlyActive = false }: JobsTableProps) {
const { jobs, status, refreshJobs } = useJobsList(onlyActive);
const isLoading = status === 'loading';
const columns: TableColumn[] = [
{
title: 'Name',
key: 'name',
render: (row: JobRecord) => {
const jobConfig: JobConfig = JSON.parse(row.job_config);
const isHFJob = jobConfig.is_hf_job;
return (
{row.name}
{isHFJob && (
HF Cloud
)}
);
},
},
{
title: 'Steps',
key: 'steps',
render: (row: JobRecord) => {
const jobConfig: JobConfig = JSON.parse(row.job_config);
const isHFJob = jobConfig.is_hf_job;
if (isHFJob) {
return (
Cloud Training
);
}
const totalSteps = jobConfig.config.process[0].train.steps;
return (
{row.step} / {totalSteps}
);
},
},
{
title: 'GPU',
key: 'gpu_ids',
render: (row: JobRecord) => {
const jobConfig: JobConfig = JSON.parse(row.job_config);
const isHFJob = jobConfig.is_hf_job;
if (isHFJob) {
return (
{jobConfig.hardware || row.gpu_ids}
);
}
return {row.gpu_ids};
},
},
{
title: 'Status',
key: 'status',
render: (row: JobRecord) => {
const jobConfig: JobConfig = JSON.parse(row.job_config);
const isHFJob = jobConfig.is_hf_job;
if (isHFJob) {
if (jobConfig.hf_job_id) {
// HF Job that has been submitted
return (
);
} else {
// HF Job that hasn't been submitted yet
return (
Pending Submission
);
}
}
// Local job status
let statusClass = 'text-gray-400';
if (row.status === 'completed') statusClass = 'text-green-400';
if (row.status === 'failed') statusClass = 'text-red-400';
if (row.status === 'running') statusClass = 'text-blue-400';
return {row.status};
},
},
{
title: 'Info',
key: 'info',
className: 'truncate max-w-xs',
},
{
title: 'Actions',
key: 'actions',
className: 'text-right',
render: (row: JobRecord) => {
return ;
},
},
];
return ;
}