Skip to content

Commit

Permalink
Merge pull request #228 from optuna/fix-nplus1-problem
Browse files Browse the repository at this point in the history
Fix performance issues on the top page.
  • Loading branch information
c-bata authored May 6, 2022
2 parents 545ef2f + 9ddf2da commit 5dda769
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 28 deletions.
6 changes: 3 additions & 3 deletions optuna_dashboard/_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def decorated(*args: List[Any], **kwargs: Dict[str, Any]) -> BottleViewReturn:

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:
Expand All @@ -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
Expand Down Expand Up @@ -212,7 +212,7 @@ def post_incompatible_rdb_schema() -> BottleViewReturn:
@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]
Expand Down
5 changes: 0 additions & 5 deletions optuna_dashboard/_serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
7 changes: 0 additions & 7 deletions optuna_dashboard/ts/apiClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down
13 changes: 1 addition & 12 deletions optuna_dashboard/ts/components/StudyList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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: "",
Expand Down Expand Up @@ -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}
/>
Expand Down
1 change: 0 additions & 1 deletion optuna_dashboard/ts/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 5dda769

Please sign in to comment.