Skip to content

Commit

Permalink
Converted run page to DataGrid tables and removed all old code
Browse files Browse the repository at this point in the history
  • Loading branch information
joaquinvanschoren committed Jan 24, 2024
1 parent fadb052 commit d68456a
Show file tree
Hide file tree
Showing 8 changed files with 138 additions and 388 deletions.
47 changes: 47 additions & 0 deletions app/src/components/run/EvaluationTable.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import * as React from "react";
import Box from "@mui/material/Box";
import { DataGrid } from "@mui/x-data-grid";
import { Card, CardContent, Typography } from "@mui/material";

const columns = [
{ field: "measure", headerName: "Evaluation measure", width: 240 },
{ field: "value", headerName: "Value", width: 200 },
{ field: "array_data", headerName: "Per class", width: 200 },
{ field: "per_fold", headerName: "Per fold", width: 200 },
];

const EvaluationTable = ({ data }) => {
const rows = data.map((item, index) => ({
id: index,
measure: item.evaluation_measure,
value: item.value !== undefined ? `${item.value} +- ${item.stdev}` : "",
array_data: item.array_data,
per_fold: item.per_fold,
}));

return (
<Card>
<CardContent>
<Typography variant="h4" mb={6}>
{rows.length + " Evaluation metrics"}
</Typography>
<Box sx={{ width: "100%" }}>
<DataGrid
rows={rows}
columns={columns}
initialState={{
pagination: {
paginationModel: {
pageSize: 20,
},
},
}}
pageSizeOptions={[10, 20, 50, 100]}
/>
</Box>
</CardContent>
</Card>
);
};

export default EvaluationTable;
72 changes: 72 additions & 0 deletions app/src/components/run/ParameterTable.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import * as React from "react";
import Box from "@mui/material/Box";
import { DataGrid } from "@mui/x-data-grid";
import { Card, CardContent, Tooltip, Typography } from "@mui/material";

const columns = [
{
field: "parameter",
headerName: "Hyperparameter",
width: 600,
},
{
field: "value",
headerName: "Value",
width: 200,
renderCell: (params) => {
const maxChars = 50;
try {
// Attempt to parse the value as JSON
const jsonObject = JSON.parse(params.value);
const prettyJson = JSON.stringify(jsonObject, null, 2);
const displayText =
prettyJson && prettyJson.length > maxChars
? prettyJson.substring(0, maxChars) + "..."
: prettyJson;
return (
<Tooltip title={<pre>{prettyJson}</pre>} arrow>
<span>{displayText}</span>
</Tooltip>
);
} catch {
// If parsing fails, just display the raw string
return <span>{params.value}</span>;
}
},
},
];

const ParameterTable = ({ data }) => {
// Define the rows for the grid
const rows = data.map((param, index) => ({
id: index,
parameter: param.parameter.replace(/\(.*?\)/g, ""),
value: param.value,
}));

return (
<Card>
<CardContent>
<Typography variant="h4" mb={6}>
{rows.length + " Hyperparameters"}
</Typography>
<Box sx={{ width: "100%" }}>
<DataGrid
rows={rows}
columns={columns}
initialState={{
pagination: {
paginationModel: {
pageSize: 10,
},
},
}}
pageSizeOptions={[10, 20, 50, 100]}
/>
</Box>
</CardContent>
</Card>
);
};

export default ParameterTable;
189 changes: 0 additions & 189 deletions app/src/pages/api/itemDetail.js

This file was deleted.

Loading

0 comments on commit d68456a

Please sign in to comment.