mirror of
https://github.com/wassname/optuna-dashboard.git
synced 2026-09-12 12:40:33 +08:00
Merge pull request #773 from knshnb/plotlypy-dependency
Resolve plotly.py dependency issue
This commit is contained in:
@@ -2,6 +2,7 @@ from __future__ import annotations
|
||||
|
||||
import csv
|
||||
import functools
|
||||
import importlib
|
||||
import io
|
||||
from itertools import chain
|
||||
import logging
|
||||
@@ -95,6 +96,7 @@ def create_app(
|
||||
def api_meta() -> dict[str, Any]:
|
||||
return {
|
||||
"artifact_is_available": artifact_store is not None,
|
||||
"plotlypy_is_available": importlib.util.find_spec("plotly") is not None,
|
||||
}
|
||||
|
||||
@app.get("/api/studies")
|
||||
|
||||
@@ -28,6 +28,7 @@ import {
|
||||
paramImportanceState,
|
||||
isFileUploading,
|
||||
artifactIsAvailable,
|
||||
plotlypyIsAvailableState,
|
||||
reloadIntervalState,
|
||||
trialsUpdatingState,
|
||||
studySummariesLoadingState,
|
||||
@@ -47,6 +48,9 @@ export const actionCreator = () => {
|
||||
const setUploading = useSetRecoilState<boolean>(isFileUploading)
|
||||
const setTrialsUpdating = useSetRecoilState(trialsUpdatingState)
|
||||
const setArtifactIsAvailable = useSetRecoilState<boolean>(artifactIsAvailable)
|
||||
const setPlotlypyIsAvailable = useSetRecoilState<boolean>(
|
||||
plotlypyIsAvailableState
|
||||
)
|
||||
const setStudySummariesLoading = useSetRecoilState<boolean>(
|
||||
studySummariesLoadingState
|
||||
)
|
||||
@@ -215,6 +219,7 @@ export const actionCreator = () => {
|
||||
const updateAPIMeta = () => {
|
||||
getMetaInfoAPI().then((r) => {
|
||||
setArtifactIsAvailable(r.artifact_is_available)
|
||||
setPlotlypyIsAvailable(r.plotlypy_is_available)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ const axiosInstance = axios.create({ baseURL: API_ENDPOINT })
|
||||
|
||||
type APIMeta = {
|
||||
artifact_is_available: boolean
|
||||
plotlypy_is_available: boolean
|
||||
}
|
||||
|
||||
export const getMetaInfoAPI = (): Promise<APIMeta> => {
|
||||
|
||||
@@ -17,6 +17,8 @@ import { useMergedUnionSearchSpace } from "../searchSpace"
|
||||
import { getAxisInfo } from "../graphUtil"
|
||||
import { useQuery } from "../urlQuery"
|
||||
import { getPlotAPI, PlotType } from "../apiClient"
|
||||
import { useRecoilValue } from "recoil"
|
||||
import { plotlypyIsAvailableState } from "../state"
|
||||
|
||||
const plotDomId = "graph-contour"
|
||||
|
||||
@@ -24,8 +26,16 @@ export const Contour: FC<{
|
||||
study: StudyDetail | null
|
||||
}> = ({ study = null }) => {
|
||||
const query = useQuery()
|
||||
const plotlypyIsAvailable = useRecoilValue<boolean>(plotlypyIsAvailableState)
|
||||
if (query.get("plotlypy_rendering") === "true") {
|
||||
return <ContourBackend study={study} />
|
||||
if (plotlypyIsAvailable) {
|
||||
return <ContourBackend study={study} />
|
||||
} else {
|
||||
console.warn(
|
||||
"Use frontend rendering because plotlypy is specified but not available."
|
||||
)
|
||||
return <ContourFrontend study={study} />
|
||||
}
|
||||
} else {
|
||||
return <ContourFrontend study={study} />
|
||||
}
|
||||
|
||||
@@ -43,6 +43,11 @@ export const artifactIsAvailable = atom<boolean>({
|
||||
default: false,
|
||||
})
|
||||
|
||||
export const plotlypyIsAvailableState = atom<boolean>({
|
||||
key: "plotlypyIsAvailable",
|
||||
default: true,
|
||||
})
|
||||
|
||||
export const studySummariesLoadingState = atom<boolean>({
|
||||
key: "studySummariesLoadingState",
|
||||
default: false,
|
||||
|
||||
@@ -59,6 +59,10 @@ preferential = [
|
||||
"botorch>=0.8.1",
|
||||
]
|
||||
|
||||
plotlypy = [
|
||||
"plotly",
|
||||
]
|
||||
|
||||
[project.scripts]
|
||||
optuna-dashboard = "optuna_dashboard._cli:main"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user