Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change Chip's colors and show durations #343

Merged
merged 2 commits into from
Jan 5, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 26 additions & 7 deletions optuna_dashboard/ts/components/TrialList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ type Color =

const getChipColor = (state: TrialState): Color => {
if (state === "Complete") {
return "success"
return "primary"
} else if (state === "Running") {
return "secondary"
return "default"
} else if (state === "Waiting") {
return "secondary"
return "default"
} else if (state === "Pruned") {
return "warning"
} else if (state === "Fail") {
Expand Down Expand Up @@ -93,6 +93,14 @@ export const TrialList: FC<{
let content = null
if (trials.length > selected) {
const trial = trials[selected]

const startMs = trial.datetime_start?.getTime()
const completeMs = trial.datetime_complete?.getTime()
let duration = ""
if (startMs !== undefined && completeMs !== undefined) {
duration = (completeMs - startMs).toString()
}

content = (
<>
<Card sx={{ margin: theme.spacing(2) }}>
Expand All @@ -107,17 +115,28 @@ export const TrialList: FC<{
sx={{ marginRight: theme.spacing(1) }}
/>
{isBestTrial(trial.trial_id) ? (
<Chip label={"Best Trial"} color="primary" />
<Chip label={"Best Trial"} color="secondary" />
) : null}
</Box>
<Typography>
Values:{" "}
{trial.values?.map((v) => v.toString()).join(" ") || "None"}
Values: [
{trial.values?.map((v) => v.toString()).join(" ") || "None"}]
</Typography>
<Typography>
Params = [
{trial.params.map((p) => `${p.name}: ${p.value}`).join(", ")}]
</Typography>
<Typography>
Started At ={" "}
{trial?.datetime_start ? trial?.datetime_start.toString() : null}
</Typography>
<Typography>
Completed At ={" "}
{trial?.datetime_complete
? trial?.datetime_complete.toString()
: null}
</Typography>
<Typography>Duration = {duration} ms</Typography>
</CardContent>
</Card>
<TrialNote
Expand Down Expand Up @@ -207,7 +226,7 @@ export const TrialList: FC<{
{isBestTrial(trial.trial_id) ? (
<Chip
label={"Best Trial"}
color="primary"
color="secondary"
sx={{ marginLeft: theme.spacing(1) }}
size="small"
/>
Expand Down