mirror of
https://github.com/wassname/optuna-dashboard.git
synced 2026-09-21 13:10:53 +08:00
Merge pull request #228 from optuna/fix-nplus1-problem
Fix performance issues on the top page.
This commit is contained in:
@@ -136,7 +136,7 @@ def json_api_view(view: BottleView) -> BottleView:
|
||||
|
||||
def get_study_summary(storage: BaseStorage, study_id: int) -> Optional[StudySummary]:
|
||||
if version.parse(optuna_ver) >= version.Version("3.0.0b0.dev"):
|
||||
summaries = storage.get_all_study_summaries(include_best_trial=True) # type: ignore
|
||||
summaries = storage.get_all_study_summaries(include_best_trial=False) # type: ignore
|
||||
else:
|
||||
summaries = storage.get_all_study_summaries() # type: ignore
|
||||
for summary in summaries:
|
||||
@@ -158,7 +158,7 @@ def get_trials(
|
||||
and datetime.now() - last_fetched_at < timedelta(seconds=ttl_seconds)
|
||||
):
|
||||
return trials
|
||||
trials = storage.get_all_trials(study_id)
|
||||
trials = storage.get_all_trials(study_id, deepcopy=False)
|
||||
with trials_cache_lock:
|
||||
trials_last_fetched_at[study_id] = datetime.now()
|
||||
trials_cache[study_id] = trials
|
||||
@@ -212,7 +212,7 @@ def create_app(storage: BaseStorage, debug: bool = False) -> Bottle:
|
||||
@json_api_view
|
||||
def list_study_summaries() -> BottleViewReturn:
|
||||
if version.parse(optuna_ver) >= version.Version("3.0.0b0.dev"):
|
||||
summaries = storage.get_all_study_summaries(include_best_trial=True) # type: ignore
|
||||
summaries = storage.get_all_study_summaries(include_best_trial=False) # type: ignore
|
||||
else:
|
||||
summaries = storage.get_all_study_summaries() # type: ignore
|
||||
serialized = [serialize_study_summary(summary) for summary in summaries]
|
||||
|
||||
@@ -79,11 +79,6 @@ def serialize_study_summary(summary: StudySummary) -> Dict[str, Any]:
|
||||
if summary.datetime_start is not None:
|
||||
serialized["datetime_start"] = (summary.datetime_start.isoformat(),)
|
||||
|
||||
if summary.best_trial:
|
||||
serialized["best_trial"] = serialize_frozen_trial(
|
||||
summary._study_id, summary.best_trial
|
||||
)
|
||||
|
||||
return serialized
|
||||
|
||||
|
||||
|
||||
@@ -70,9 +70,6 @@ export const getStudyDetailAPI = (
|
||||
name: res.data.name,
|
||||
datetime_start: new Date(res.data.datetime_start),
|
||||
directions: res.data.directions,
|
||||
best_trial: res.data.best_trial
|
||||
? convertTrialResponse(res.data.best_trial)
|
||||
: undefined,
|
||||
trials: trials,
|
||||
union_search_space: res.data.union_search_space,
|
||||
intersection_search_space: res.data.intersection_search_space,
|
||||
@@ -111,14 +108,10 @@ export const getStudySummariesAPI = (): Promise<StudySummary[]> => {
|
||||
.get<StudySummariesResponse>(`/api/studies`, {})
|
||||
.then((res) => {
|
||||
return res.data.study_summaries.map((study): StudySummary => {
|
||||
const best_trial = study.best_trial
|
||||
? convertTrialResponse(study.best_trial)
|
||||
: undefined
|
||||
return {
|
||||
study_id: study.study_id,
|
||||
study_name: study.study_name,
|
||||
directions: study.directions,
|
||||
best_trial: best_trial,
|
||||
user_attrs: study.user_attrs,
|
||||
system_attrs: study.system_attrs,
|
||||
datetime_start: study.datetime_start
|
||||
|
||||
@@ -123,17 +123,6 @@ export const StudyList: FC<{
|
||||
sortable: false,
|
||||
toCellValue: (i) => studies[i].directions.join(),
|
||||
},
|
||||
{
|
||||
field: "best_trial",
|
||||
label: "Best value",
|
||||
sortable: false,
|
||||
toCellValue: (i) => {
|
||||
if (studies[i].directions.length !== 1) {
|
||||
return "-" // Multi-objective study does not hold best_trial attribute.
|
||||
}
|
||||
return studies[i].best_trial?.values?.[0] || null
|
||||
},
|
||||
},
|
||||
{
|
||||
field: "study_name",
|
||||
label: "",
|
||||
@@ -362,7 +351,7 @@ export const StudyList: FC<{
|
||||
rows={studies}
|
||||
keyField={"study_id"}
|
||||
collapseBody={collapseBody}
|
||||
initialRowsPerPage={-1}
|
||||
initialRowsPerPage={10}
|
||||
rowsPerPageOption={[5, 10, { label: "All", value: -1 }]}
|
||||
defaultFilter={studyFilter}
|
||||
/>
|
||||
|
||||
Vendored
-1
@@ -68,7 +68,6 @@ declare interface StudySummary {
|
||||
study_id: number
|
||||
study_name: string
|
||||
directions: StudyDirection[]
|
||||
best_trial?: Trial
|
||||
user_attrs: Attribute[]
|
||||
system_attrs: Attribute[]
|
||||
datetime_start?: Date
|
||||
|
||||
Reference in New Issue
Block a user