diff --git a/optuna_dashboard/ts/components/TrialList.tsx b/optuna_dashboard/ts/components/TrialList.tsx index d90bdf88..9bd83e12 100644 --- a/optuna_dashboard/ts/components/TrialList.tsx +++ b/optuna_dashboard/ts/components/TrialList.tsx @@ -19,6 +19,13 @@ import { CardContent, CardMedia, CardActionArea, + TextField, + Button, + Slider, + FormControl, + FormLabel, + RadioGroup, + Radio, } from "@mui/material" import Chip from "@mui/material/Chip" import Divider from "@mui/material/Divider" @@ -42,6 +49,7 @@ import { useRecoilValue } from "recoil" import { artifactIsAvailable } from "../state" import { actionCreator } from "../action" import { useDeleteArtifactDialog } from "./DeleteArtifactDialog" +import FormControlLabel from "@mui/material/FormControlLabel" const states: TrialState[] = [ "Complete", @@ -143,7 +151,16 @@ const useIsBestTrial = ( const TrialListDetail: FC<{ trial: Trial isBestTrial: (trialId: number) => boolean -}> = ({ trial, isBestTrial }) => { + directions: StudyDirection[] + objectiveNames: string[] + objectiveFormWidgets: ObjectiveFormWidget[] +}> = ({ + trial, + isBestTrial, + directions, + objectiveNames, + objectiveFormWidgets, +}) => { const theme = useTheme() const artifactEnabled = useRecoilValue(artifactIsAvailable) const startMs = trial.datetime_start?.getTime() @@ -180,7 +197,12 @@ const TrialListDetail: FC<{ "Completed At", trial?.datetime_complete ? trial?.datetime_complete.toString() : null, ], - ["Duration (ms)", (startMs !== undefined && completeMs !== undefined) ? (completeMs - startMs).toString() : null], + [ + "Duration (ms)", + startMs !== undefined && completeMs !== undefined + ? (completeMs - startMs).toString() + : null, + ], [ "User Attributes", @@ -260,7 +282,9 @@ const TrialListDetail: FC<{ flexDirection: "column", }} > - {info.map(([key, value]) => value !== null ? renderInfo(key, value) : null)} + {info.map(([key, value]) => + value !== null ? renderInfo(key, value) : null + )} + {trial.state === "Running" && directions.length > 0 && ( + + )} {artifactEnabled && } ) } +const ObjectiveForms: FC<{ + trial: Trial + directions: StudyDirection[] + names: string[] + widgets: ObjectiveFormWidget[] +}> = ({ trial, directions, names, widgets }) => { + const theme = useTheme() + const action = actionCreator() + + return ( + <> + + Tell Objective Values + + + + {directions.map((d, i) => { + const widget = widgets.at(i) + const key = `objective-${i}` + if (widget === undefined) { + return ( + + {names.at(i) || `Objective ${i}`} + + + ) + } else if (widget.type === "text") { + return ( + + {names.at(i) || `Objective ${i}`} + + + ) + } else if (widget.type === "choice") { + return ( + + {names.at(i) || `Objective ${i}`} + + {widget.choices.map((c, i) => ( + } + label={c} + /> + ))} + + + ) + } else if (widget.type === "slider") { + return ( + + {names.at(i) || `Objective ${i}`} + + + + + ) + } + return null + })} + + + + + + + + ) +} + const TrialArtifact: FC<{ trial: Trial }> = ({ trial }) => { const theme = useTheme() const action = actionCreator() @@ -712,6 +877,11 @@ export const TrialList: FC<{ studyDetail: StudyDetail | null }> = ({ key={t.trial_id} trial={t} isBestTrial={isBestTrial} + directions={studyDetail?.directions || []} + objectiveNames={studyDetail?.objective_names || []} + objectiveFormWidgets={ + studyDetail?.objective_form_widgets || [] + } /> ))}