-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1b1a8aa
commit 18dd4b1
Showing
4 changed files
with
304 additions
and
171 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
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: "library", headerName: "Library", width: 120 }, | ||
{ field: "version", headerName: "Version", width: 90 }, | ||
]; | ||
|
||
const DependencyTable = ({ data }) => { | ||
// Split on ',' and '/n' | ||
const rows = data.split(/[,\n]+/).map((dependency) => { | ||
// Split on '==', '<=', '>=', '<', '>', and '_' | ||
const match = dependency.match(/([<>]?=|_)/); | ||
const index = match ? dependency.indexOf(match[0]) : -1; | ||
|
||
// Extract the library and version based on the index of the version specifier | ||
const library = index > -1 ? dependency.substring(0, index) : dependency; | ||
const version = index > -1 ? dependency.substring(index) : ""; | ||
|
||
return { | ||
library: library, | ||
version: version.replace(/_/g, "").replace(/([=><]+)([^ ])/, "$1 $2"), | ||
}; | ||
}); | ||
|
||
return ( | ||
<Card> | ||
<CardContent> | ||
<Typography variant="h4" mb={6}> | ||
{rows.length + " Dependencies"} | ||
</Typography> | ||
<Box sx={{ width: "100%" }}> | ||
<DataGrid | ||
rows={rows} | ||
columns={columns} | ||
getRowId={(row) => row.library} | ||
initialState={{ | ||
pagination: { | ||
paginationModel: { | ||
pageSize: 5, | ||
}, | ||
}, | ||
}} | ||
/> | ||
</Box> | ||
</CardContent> | ||
</Card> | ||
); | ||
}; | ||
|
||
export default DependencyTable; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
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: "name", | ||
headerName: "Name", | ||
width: 200, | ||
}, | ||
{ | ||
field: "data_type", | ||
headerName: "Data type", | ||
width: 120, | ||
}, | ||
{ | ||
field: "default_value", | ||
headerName: "Default value", | ||
width: 200, | ||
}, | ||
{ | ||
field: "description", | ||
headerName: "Description", | ||
width: 400, | ||
}, | ||
]; | ||
|
||
const ParameterTable = ({ data }) => { | ||
// Define the rows for the grid | ||
|
||
const rows = data.flatMap((param) => { | ||
// If the key is 'steps' and it's a valid JSON string, process it | ||
if (param.name === "steps" && typeof param.default_value === "string") { | ||
try { | ||
const stepsArray = JSON.parse(param.default_value); | ||
if (Array.isArray(stepsArray)) { | ||
return stepsArray.map((step) => { | ||
const stepValue = step.value || {}; | ||
return { | ||
name: `steps.${stepValue.step_name}` || "", | ||
type: "component", | ||
default_value: "", | ||
description: stepValue.key || "", | ||
}; | ||
}); | ||
} | ||
} catch (e) { | ||
console.error("Error parsing JSON:", e); | ||
// Handle the error or return an empty array | ||
return []; | ||
} | ||
} else { | ||
// For other cases, just return the original row format | ||
return [ | ||
{ | ||
id: param.name, | ||
...param, | ||
}, | ||
]; | ||
} | ||
}); | ||
|
||
return ( | ||
<Card> | ||
<CardContent> | ||
<Typography variant="h4" mb={6}> | ||
{data.length + " Hyperparameters"} | ||
</Typography> | ||
<Box sx={{ width: "100%" }}> | ||
<DataGrid | ||
rows={rows} | ||
columns={columns} | ||
getRowId={(row) => row.name} | ||
initialState={{ | ||
pagination: { | ||
paginationModel: { | ||
pageSize: 10, | ||
}, | ||
}, | ||
}} | ||
pageSizeOptions={[10, 20, 50, 100]} | ||
/> | ||
</Box> | ||
</CardContent> | ||
</Card> | ||
); | ||
}; | ||
|
||
export default ParameterTable; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.