Skip to content

Commit

Permalink
fix: fixed typescript bug
Browse files Browse the repository at this point in the history
  • Loading branch information
jeafreezy committed Nov 21, 2024
1 parent c759545 commit 5a79447
Show file tree
Hide file tree
Showing 2 changed files with 113 additions and 112 deletions.
1 change: 1 addition & 0 deletions frontend/src/features/models/api/update-trainings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export const useUpdateTraining = ({
String(modelId),
0,
PAGE_LIMIT,
"-id"
);

const { onSuccess, ...restConfig } = mutationConfig || {};
Expand Down
224 changes: 112 additions & 112 deletions frontend/src/features/models/components/training-history-table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,121 +41,121 @@ const columnDefinitions = (
handleTrainingModal: (trainingId: number) => void,
publishTraining: (trainingId: number) => void,
): ColumnDef<TTrainingDetails>[] => [
{
accessorKey: "id",
header: ({ column }) => <SortableHeader title={"ID"} column={column} />,
},
{
header:
APP_CONTENT.models.modelsDetailsCard.trainingHistoryTableHeader
.epochAndBatchSize,
accessorFn: (row) => `${row.epochs}/${row.batch_size}`,
cell: (row) => (
<span title={row.getValue() as string}>{row.getValue() as string}</span>
),
},
{
accessorKey: "started_at",
accessorFn: (row) =>
row.started_at !== null ? formatDate(row.started_at) : "-",
header:
APP_CONTENT.models.modelsDetailsCard.trainingHistoryTableHeader.startedAt,
cell: (row) => {
return <span>{row.getValue() as string}</span>;
{
accessorKey: "id",
header: ({ column }) => <SortableHeader title={"ID"} column={column} />,
},
},
{
header:
APP_CONTENT.models.modelsDetailsCard.trainingHistoryTableHeader.duration,
accessorFn: (row) =>
row.finished_at && row.started_at
? formatDuration(new Date(row.started_at), new Date(row.finished_at))
: "-",
cell: (row) => (
<span title={row.getValue() as string}>{row.getValue() as string}</span>
),
},
{
accessorKey: "user.username",
header:
APP_CONTENT.models.modelsDetailsCard.trainingHistoryTableHeader
.sumittedBy,
cell: ({ row }) => {
return <span>{truncateString(row.original.user.username)}</span>;
{
header:
APP_CONTENT.models.modelsDetailsCard.trainingHistoryTableHeader
.epochAndBatchSize,
accessorFn: (row) => `${row.epochs}/${row.batch_size}`,
cell: (row) => (
<span title={row.getValue() as string}>{row.getValue() as string}</span>
),
},
},
{
accessorKey: "chips_length",
header:
APP_CONTENT.models.modelsDetailsCard.trainingHistoryTableHeader.dsSize,
cell: ({ row }) => {
return <span>{row.getValue("chips_length") ?? 0}</span>;
{
accessorKey: "started_at",
accessorFn: (row) =>
row.started_at !== null ? formatDate(row.started_at) : "-",
header:
APP_CONTENT.models.modelsDetailsCard.trainingHistoryTableHeader.startedAt,
cell: (row) => {
return <span>{row.getValue() as string}</span>;
},
},
},
{
accessorKey: "accuracy",
header: ({ column }) => (
<SortableHeader
title={
APP_CONTENT.models.modelsDetailsCard.trainingHistoryTableHeader
.accuracy
}
column={column}
/>
),
cell: ({ row }) => {
return (
<span>
{Number(row.getValue("accuracy")) > 0
? roundNumber(row.getValue("accuracy"))
: "-"}
</span>
);
{
header:
APP_CONTENT.models.modelsDetailsCard.trainingHistoryTableHeader.duration,
accessorFn: (row) =>
row.finished_at && row.started_at
? formatDuration(new Date(row.started_at), new Date(row.finished_at))
: "-",
cell: (row) => (
<span title={row.getValue() as string}>{row.getValue() as string}</span>
),
},
{
accessorKey: "user.username",
header:
APP_CONTENT.models.modelsDetailsCard.trainingHistoryTableHeader
.sumittedBy,
cell: ({ row }) => {
return <span>{truncateString(row.original.user.username)}</span>;
},
},
{
accessorKey: "chips_length",
header:
APP_CONTENT.models.modelsDetailsCard.trainingHistoryTableHeader.dsSize,
cell: ({ row }) => {
return <span>{row.getValue("chips_length") ?? 0}</span>;
},
},
{
accessorKey: "accuracy",
header: ({ column }) => (
<SortableHeader
title={
APP_CONTENT.models.modelsDetailsCard.trainingHistoryTableHeader
.accuracy
}
column={column}
/>
),
cell: ({ row }) => {
return (
<span>
{Number(row.getValue("accuracy")) > 0
? roundNumber(row.getValue("accuracy"))
: "-"}
</span>
);
},
},
},
{
header:
APP_CONTENT.models.modelsDetailsCard.trainingHistoryTableHeader.status,
accessorKey: "status",
cell: (row) => {
const statusToVariant: Record<string, TBadgeVariants> = {
finished: "green",
failed: "red",
submitted: "blue",
running: "yellow",
};
{
header:
APP_CONTENT.models.modelsDetailsCard.trainingHistoryTableHeader.status,
accessorKey: "status",
cell: (row) => {
const statusToVariant: Record<string, TBadgeVariants> = {
finished: "green",
failed: "red",
submitted: "blue",
running: "yellow",
};

return (
<Badge
variant={
statusToVariant[
return (
<Badge
variant={
statusToVariant[
String(row.getValue()).toLocaleLowerCase() as TBadgeVariants
]
}
>
{String(row.getValue()).toLocaleLowerCase() as string}
</Badge>
);
]
}
>
{String(row.getValue()).toLocaleLowerCase() as string}
</Badge>
);
},
},
},
{
header:
APP_CONTENT.models.modelsDetailsCard.trainingHistoryTableHeader.inUse,
{
header:
APP_CONTENT.models.modelsDetailsCard.trainingHistoryTableHeader.inUse,

cell: ({ row }) => {
return (
<span>
{row.getValue("id") === trainingId ? (
<Badge variant="green" rounded>
<CheckIcon className="icon" />
</Badge>
) : null}
</span>
);
cell: ({ row }) => {
return (
<span>
{row.getValue("id") === trainingId ? (
<Badge variant="green" rounded>
<CheckIcon className="icon" />
</Badge>
) : null}
</span>
);
},
},
},
...(modelOwner !== authUsername
? [
...(modelOwner !== authUsername
? [
{
header:
APP_CONTENT.models.modelsDetailsCard.trainingHistoryTableHeader
Expand All @@ -174,9 +174,9 @@ const columnDefinitions = (
},
},
]
: []),
...(modelOwner === authUsername && isAuthenticated
? [
: []),
...(modelOwner === authUsername && isAuthenticated
? [
{
header:
APP_CONTENT.models.modelsDetailsCard.trainingHistoryTableHeader
Expand Down Expand Up @@ -225,8 +225,8 @@ const columnDefinitions = (
},
},
]
: []),
];
: []),
];

const TrainingHistoryTable: React.FC<TrainingHistoryTableProps> = ({
trainingId,
Expand All @@ -242,7 +242,7 @@ const TrainingHistoryTable: React.FC<TrainingHistoryTableProps> = ({
PAGE_LIMIT,
"-id",
);
const [sorting, setSorting] = useState<SortingState>();
const [sorting, setSorting] = useState<SortingState>([]);
const { user, isAuthenticated } = useAuth();
const { isOpened, openDialog, closeDialog } = useDialog();
const toast = useToastNotification();
Expand Down

0 comments on commit 5a79447

Please sign in to comment.