From 00fc20531c297f81b82bffb82413394c844ec510 Mon Sep 17 00:00:00 2001 From: keisuke-umezawa Date: Thu, 18 Jul 2024 17:19:52 +0900 Subject: [PATCH 1/3] Add distribution property in ParamImportance of tslib --- tslib/types/src/index.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/tslib/types/src/index.ts b/tslib/types/src/index.ts index c37be5b03..60a90838b 100644 --- a/tslib/types/src/index.ts +++ b/tslib/types/src/index.ts @@ -93,4 +93,5 @@ export type SearchSpaceItem = { export type ParamImportance = { name: string importance: number + distribution: Distribution } From cd9b714b3c7c3c1dce378e6a9ce59e475421077a Mon Sep 17 00:00:00 2001 From: keisuke-umezawa Date: Sat, 20 Jul 2024 14:55:42 +0900 Subject: [PATCH 2/3] Remove distribution property in ParamImportance --- optuna_dashboard/ts/types/optuna.ts | 6 ------ tslib/types/src/index.ts | 1 - 2 files changed, 7 deletions(-) diff --git a/optuna_dashboard/ts/types/optuna.ts b/optuna_dashboard/ts/types/optuna.ts index 01844f722..f69d008a6 100644 --- a/optuna_dashboard/ts/types/optuna.ts +++ b/optuna_dashboard/ts/types/optuna.ts @@ -21,12 +21,6 @@ export type TrialParam = { distribution: Optuna.Distribution } -export type ParamImportance = { - name: string - importance: number - distribution: Optuna.Distribution -} - export type SearchSpaceItem = { name: string distribution: Optuna.Distribution diff --git a/tslib/types/src/index.ts b/tslib/types/src/index.ts index 60a90838b..c37be5b03 100644 --- a/tslib/types/src/index.ts +++ b/tslib/types/src/index.ts @@ -93,5 +93,4 @@ export type SearchSpaceItem = { export type ParamImportance = { name: string importance: number - distribution: Distribution } From 7366550729eba5e2f0e4402c6992c48ca7f6ce6f Mon Sep 17 00:00:00 2001 From: keisuke-umezawa Date: Sat, 20 Jul 2024 15:02:08 +0900 Subject: [PATCH 3/3] Fix code in optuna-dashboard --- optuna_dashboard/ts/apiClient.ts | 7 ++++--- optuna_dashboard/ts/axiosClient.ts | 5 +++-- optuna_dashboard/ts/hooks/useParamImportance.ts | 4 ++-- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/optuna_dashboard/ts/apiClient.ts b/optuna_dashboard/ts/apiClient.ts index f1a7ad8c5..e618e21fc 100644 --- a/optuna_dashboard/ts/apiClient.ts +++ b/optuna_dashboard/ts/apiClient.ts @@ -5,7 +5,6 @@ import { FeedbackComponentType, FormWidgets, Note, - ParamImportance, PlotlyGraphObject, PreferenceFeedbackMode, PreferenceHistory, @@ -113,7 +112,7 @@ export type UploadArtifactAPIResponse = { } export interface ParamImportancesResponse { - param_importances: ParamImportance[][] + param_importances: Optuna.ParamImportance[][] } export type PlotResponse = { @@ -228,7 +227,9 @@ export abstract class APIClient { trialId: number, user_attrs: { [key: string]: number | string } ): Promise - abstract getParamImportances(studyId: number): Promise + abstract getParamImportances( + studyId: number + ): Promise abstract reportPreference( studyId: number, candidates: number[], diff --git a/optuna_dashboard/ts/axiosClient.ts b/optuna_dashboard/ts/axiosClient.ts index bb2b811ad..9b29f2db4 100644 --- a/optuna_dashboard/ts/axiosClient.ts +++ b/optuna_dashboard/ts/axiosClient.ts @@ -15,7 +15,6 @@ import { } from "./apiClient" import { FeedbackComponentType, - ParamImportance, StudyDetail, StudySummary, Trial, @@ -230,7 +229,9 @@ export class AxiosClient extends APIClient { .then(() => { return }) - getParamImportances = (studyId: number): Promise => + getParamImportances = ( + studyId: number + ): Promise => this.axiosInstance .get( `/api/studies/${studyId}/param_importances` diff --git a/optuna_dashboard/ts/hooks/useParamImportance.ts b/optuna_dashboard/ts/hooks/useParamImportance.ts index 9cddaafa4..e5baef6f0 100644 --- a/optuna_dashboard/ts/hooks/useParamImportance.ts +++ b/optuna_dashboard/ts/hooks/useParamImportance.ts @@ -1,8 +1,8 @@ +import * as Optuna from "@optuna/types" import { useQuery } from "@tanstack/react-query" import { AxiosError } from "axios" import { useSnackbar } from "notistack" import { useEffect } from "react" -import { ParamImportance } from "ts/types/optuna" import { useAPIClient } from "../apiClientProvider" export const useParamImportance = ({ @@ -13,7 +13,7 @@ export const useParamImportance = ({ const { enqueueSnackbar } = useSnackbar() const { data, isLoading, error } = useQuery< - ParamImportance[][], + Optuna.ParamImportance[][], AxiosError<{ reason: string }> >({ queryKey: ["paramImportance", studyId, numCompletedTrials],