From cb977fa09b36e2e659da3425f8e8895571f02dae Mon Sep 17 00:00:00 2001 From: c-bata Date: Sun, 28 Feb 2021 18:29:39 +0900 Subject: [PATCH] Make datetime_start optional --- optuna_dashboard/static/apiClient.ts | 6 ++++-- optuna_dashboard/static/components/GraphHistory.tsx | 2 +- optuna_dashboard/static/types/index.d.ts | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/optuna_dashboard/static/apiClient.ts b/optuna_dashboard/static/apiClient.ts index cd68c40a..cf9348f9 100644 --- a/optuna_dashboard/static/apiClient.ts +++ b/optuna_dashboard/static/apiClient.ts @@ -9,7 +9,7 @@ interface TrialResponse { state: TrialState values?: number[] intermediate_values: TrialIntermediateValue[] - datetime_start: string + datetime_start?: string datetime_complete?: string params: TrialParam[] user_attrs: Attribute[] @@ -24,7 +24,9 @@ const convertTrialResponse = (res: TrialResponse): Trial => { state: res.state, values: res.values, intermediate_values: res.intermediate_values, - datetime_start: new Date(res.datetime_start), + datetime_start: res.datetime_start + ? new Date(res.datetime_start) + : undefined, datetime_complete: res.datetime_complete ? new Date(res.datetime_complete) : undefined, diff --git a/optuna_dashboard/static/components/GraphHistory.tsx b/optuna_dashboard/static/components/GraphHistory.tsx index c740549c..f3d121e0 100644 --- a/optuna_dashboard/static/components/GraphHistory.tsx +++ b/optuna_dashboard/static/components/GraphHistory.tsx @@ -224,7 +224,7 @@ const plotHistory = ( return xAxis === "number" ? trial.number : xAxis === "datetime_start" - ? trial.datetime_start + ? trial.datetime_start! : trial.datetime_complete! } diff --git a/optuna_dashboard/static/types/index.d.ts b/optuna_dashboard/static/types/index.d.ts index a534a02f..cc320769 100644 --- a/optuna_dashboard/static/types/index.d.ts +++ b/optuna_dashboard/static/types/index.d.ts @@ -32,7 +32,7 @@ declare interface Trial { state: TrialState values?: number[] intermediate_values: TrialIntermediateValue[] - datetime_start: Date + datetime_start?: Date datetime_complete?: Date params: TrialParam[] user_attrs: Attribute[]