From cf16cd8507beac936b83502ead83ce53c75721fd Mon Sep 17 00:00:00 2001 From: keisuke-umezawa Date: Sat, 21 Jan 2023 15:37:00 +0900 Subject: [PATCH] Follow review comments --- optuna_dashboard/ts/action.ts | 2 +- optuna_dashboard/ts/apiClient.ts | 4 +- optuna_dashboard/ts/components/TrialTable.tsx | 43 +++++++++++-------- 3 files changed, 28 insertions(+), 21 deletions(-) diff --git a/optuna_dashboard/ts/action.ts b/optuna_dashboard/ts/action.ts index 72154514..6a2993f8 100644 --- a/optuna_dashboard/ts/action.ts +++ b/optuna_dashboard/ts/action.ts @@ -289,7 +289,7 @@ export const actionCreator = () => { studyId: number, trialId: number, state: TrialStateFinished, - values?: string[] + values?: number[] ): Promise => { const message = values === undefined diff --git a/optuna_dashboard/ts/apiClient.ts b/optuna_dashboard/ts/apiClient.ts index 58215826..f8db1eae 100644 --- a/optuna_dashboard/ts/apiClient.ts +++ b/optuna_dashboard/ts/apiClient.ts @@ -221,9 +221,9 @@ export const tellTrialAPI = ( studyId: number, trialId: number, state: TrialStateFinished, - values?: string[] + values?: number[] ): Promise => { - const req: { state: TrialState; values?: string[] } = { + const req: { state: TrialState; values?: number[] } = { state: state, values: values, } diff --git a/optuna_dashboard/ts/components/TrialTable.tsx b/optuna_dashboard/ts/components/TrialTable.tsx index 43973e79..fda62798 100644 --- a/optuna_dashboard/ts/components/TrialTable.tsx +++ b/optuna_dashboard/ts/components/TrialTable.tsx @@ -1,4 +1,11 @@ -import React, {ChangeEvent, createRef, FC, FormEvent, MouseEvent, useState} from "react" +import React, { + ChangeEvent, + createRef, + FC, + FormEvent, + MouseEvent, + useState, +} from "react" import { Typography, Grid, @@ -274,7 +281,9 @@ export const TrialTable: FC<{ ] const collapseBody = (index: number) => { - const objectiveFormRefs = studyDetail?.directions.map(d => createRef()) + const objectiveFormRefs = studyDetail?.directions.map((d) => + createRef() + ) const handleSubmit = (e: FormEvent): void => { if (objectiveFormRefs === undefined) { return @@ -283,14 +292,11 @@ export const TrialTable: FC<{ e.preventDefault() const studyId = (studyDetail as StudyDetail).id const trialId = trials[index].number - const objectiveValues = objectiveFormRefs.map(ref => ref.current ? ref.current.value : "") - console.dir(objectiveValues) - action.tellTrial( - studyId, - trialId, - "Complete", - objectiveValues + const objectiveValues = objectiveFormRefs.map((ref) => + ref.current ? ref.current.value : "" ) + console.dir(objectiveValues) + action.tellTrial(studyId, trialId, "Complete", objectiveValues) } const handleFailTrial = (e: MouseEvent): void => { const studyId = (studyDetail as StudyDetail).id @@ -337,15 +343,16 @@ export const TrialTable: FC<{
- {objectiveFormRefs !== undefined && objectiveFormRefs.map((ref, i) => ( - - ))} + {objectiveFormRefs !== undefined && + objectiveFormRefs.map((ref, i) => ( + + ))}