diff --git a/standalone_app/src/components/StorageProvider.tsx b/standalone_app/src/components/StorageProvider.tsx index ac6019c5c..f47676005 100644 --- a/standalone_app/src/components/StorageProvider.tsx +++ b/standalone_app/src/components/StorageProvider.tsx @@ -1,5 +1,6 @@ import { JournalFileStorage } from "@optuna/storage" import { SQLite3Storage } from "@optuna/storage" +import type { OptunaStorage } from "@optuna/storage" import React, { FC, createContext, useState } from "react" export const StorageContext = createContext<{ diff --git a/standalone_app/src/components/StudyDetail.tsx b/standalone_app/src/components/StudyDetail.tsx index 4c60e0e5b..b5366554a 100644 --- a/standalone_app/src/components/StudyDetail.tsx +++ b/standalone_app/src/components/StudyDetail.tsx @@ -33,7 +33,7 @@ export const StudyDetail: FC<{ const idxNumber = parseInt(idx || "", 10) const { storage } = useContext(StorageContext) - const [study, setStudy] = useState(null) + const [study, setStudy] = useState(null) useEffect(() => { const fetchStudy = async () => { if (storage === null) { diff --git a/standalone_app/src/components/StudyList.tsx b/standalone_app/src/components/StudyList.tsx index 4119747f7..e12274970 100644 --- a/standalone_app/src/components/StudyList.tsx +++ b/standalone_app/src/components/StudyList.tsx @@ -19,6 +19,7 @@ import { useTheme, } from "@mui/material" import { styled } from "@mui/system" +import * as Optuna from "@optuna/types" import React, { FC, useEffect, @@ -36,7 +37,7 @@ export const StudyList: FC<{ }> = ({ toggleColorMode }) => { const theme = useTheme() const { storage } = useContext(StorageContext) - const [studies, setStudies] = useState([]) + const [studies, setStudies] = useState([]) const [_studyFilterText, setStudyFilterText] = useState("") const [sortBy, setSortBy] = useState<"id-asc" | "id-desc">("id-asc") @@ -52,7 +53,7 @@ export const StudyList: FC<{ fetchStudies() }, [storage]) const filteredStudies = useMemo(() => { - const studyFilter = (row: StudySummary): boolean => { + const studyFilter = (row: Optuna.StudySummary): boolean => { const keywords = studyFilterText.split(" ") return !keywords.every((k) => { if (k === "") { @@ -61,7 +62,9 @@ export const StudyList: FC<{ return row.study_name.indexOf(k) >= 0 }) } - let filteredStudies: StudySummary[] = studies.filter((s) => !studyFilter(s)) + let filteredStudies: Optuna.StudySummary[] = studies.filter( + (s) => !studyFilter(s) + ) if (sortBy === "id-desc") { filteredStudies = filteredStudies.reverse() } diff --git a/standalone_app/src/types/index.d.ts b/standalone_app/src/types/index.d.ts index eb1f7e597..c07d8188f 100644 --- a/standalone_app/src/types/index.d.ts +++ b/standalone_app/src/types/index.d.ts @@ -1,99 +1 @@ declare const IS_VSCODE: boolean - -type TrialState = "Running" | "Complete" | "Pruned" | "Fail" | "Waiting" -type TrialStateFinished = "Complete" | "Fail" | "Pruned" -type StudyDirection = "maximize" | "minimize" - -type OptunaStorage = { - getStudies: () => Promise - getStudy: (idx: number) => Promise -} - -type FloatDistribution = { - type: "FloatDistribution" - low: number - high: number - step: number | null - log: boolean -} - -type IntDistribution = { - type: "IntDistribution" - low: number - high: number - step: number | null - log: boolean -} - -type CategoricalChoiceType = null | boolean | number | string -type CategoricalDistribution = { - type: "CategoricalDistribution" - choices: CategoricalChoiceType[] -} - -type TrialIntermediateValue = { - step: number - value: number -} - -type Distribution = - | FloatDistribution - | IntDistribution - | CategoricalDistribution - -type Attribute = { - key: string - value: string -} - -type AttributeSpec = { - key: string - sortable: boolean -} - -type StudySummary = { - study_id: number - study_name: string - directions: StudyDirection[] -} - -type Study = { - study_id: number - study_name: string - directions: StudyDirection[] - union_search_space: SearchSpaceItem[] - intersection_search_space: SearchSpaceItem[] - union_user_attrs: AttributeSpec[] - datetime_start?: Date - trials: Trial[] -} - -type Trial = { - trial_id: number - number: number - study_id: number - state: TrialState - values?: number[] - params: TrialParam[] - intermediate_values: TrialIntermediateValue[] - user_attrs: Attribute[] - datetime_start?: Date - datetime_complete?: Date -} - -type TrialParam = { - name: string - param_internal_value: number - param_external_value: CategoricalChoiceType - param_external_type: string - distribution: Distribution -} - -type SearchSpaceItem = { - name: string -} - -type ParamImportance = { - name: string - importance: number -} diff --git a/tslib/storage/src/index.ts b/tslib/storage/src/index.ts index fe384d10a..ad8afcd5b 100644 --- a/tslib/storage/src/index.ts +++ b/tslib/storage/src/index.ts @@ -1,2 +1,3 @@ export { JournalFileStorage } from "./journal" export { SQLite3Storage } from "./sqlite" +export type { OptunaStorage } from "./storage"