From 3100f9ac42a0fc98faa0b2d4f904ee4e88fac940 Mon Sep 17 00:00:00 2001 From: wassname <1103714+wassname@users.noreply.github.com> Date: Sun, 6 Oct 2024 13:50:50 +0800 Subject: [PATCH] issue #977 [object Object] in slice xaxis --- .gitignore | 1 + mjc_notes.md | 22 ++++++++++++++++++++++ optuna_dashboard/ts/graphUtil.ts | 2 +- tslib/react/src/components/PlotSlice.tsx | 6 +++--- tslib/react/src/components/TrialTable.tsx | 2 +- 5 files changed, 28 insertions(+), 5 deletions(-) create mode 100644 mjc_notes.md diff --git a/.gitignore b/.gitignore index 98571a6a..7bc67d76 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ *.pyc __pycache__/ venv/ +.venv/ .eggs/ *.egg-info dist/ diff --git a/mjc_notes.md b/mjc_notes.md new file mode 100644 index 00000000..0661fbcf --- /dev/null +++ b/mjc_notes.md @@ -0,0 +1,22 @@ +# https://github.com/nvm-sh/nvm?tab=readme-ov-file#installing-and-updating +```sh +nvm install 16 +nvm use 16 + +# in one terminal +cd optuna_dashboard/ +npm i +npm run watch + + +# npm install -g wasm-pack +# sudo apt install rustup +# rustup default stable +# make serve-browser-app + +# in another terminal python +python3 -m venv .venv --prompt optunadashboard +. ./.venv/bin/activate +pip install -e . +OPTUNA_DASHBOARD_DEBUG=1 optuna-dashboard sqlite:///optuna3.db --port=8089 +``` diff --git a/optuna_dashboard/ts/graphUtil.ts b/optuna_dashboard/ts/graphUtil.ts index 64f5d801..3cd03352 100644 --- a/optuna_dashboard/ts/graphUtil.ts +++ b/optuna_dashboard/ts/graphUtil.ts @@ -45,7 +45,7 @@ const getAxisInfoForCategoricalParams = ( ) const indices = distribution.choices - .map((c) => c?.toString() ?? "null") + .map((c) => c?.value?.toString() ?? "null") .sort((a, b) => a.toLowerCase() < b.toLowerCase() ? -1 diff --git a/tslib/react/src/components/PlotSlice.tsx b/tslib/react/src/components/PlotSlice.tsx index 82e569cd..e289f282 100644 --- a/tslib/react/src/components/PlotSlice.tsx +++ b/tslib/react/src/components/PlotSlice.tsx @@ -222,10 +222,10 @@ const plotSlice = ( ) const feasibleValues = feasibleTrials.map( - (t) => selectedParamTarget.getTargetValue(t) as number + (t) => selectedParamTarget.getTargetValue(t) as string | number ) const infeasibleValues = infeasibleTrials.map( - (t) => selectedParamTarget.getTargetValue(t) as number + (t) => selectedParamTarget.getTargetValue(t) as string | number ) const trace: plotly.Data[] = [ { @@ -268,7 +268,7 @@ const plotSlice = ( } } else { const vocabArr = selectedParamSpace.distribution.choices.map( - (c) => c?.toString() ?? "null" + (c) => c?.value?.toString() ?? "null" ) const tickvals: number[] = vocabArr.map((_v, i) => i) layout.xaxis = { diff --git a/tslib/react/src/components/TrialTable.tsx b/tslib/react/src/components/TrialTable.tsx index fe148e06..99d93a24 100644 --- a/tslib/react/src/components/TrialTable.tsx +++ b/tslib/react/src/components/TrialTable.tsx @@ -78,7 +78,7 @@ export const TrialTable: FC<{ const sortable = s.distribution.type !== "CategoricalDistribution" const filterChoices: (string | null)[] | undefined = s.distribution.type === "CategoricalDistribution" - ? s.distribution.choices.map((c) => c?.toString() ?? "null") + ? s.distribution.choices.map((c) => c?.value?.toString() ?? "null") : undefined const hasMissingValue = trials.some( (t) => !t.params.some((p) => p.name === s.name)