-
-
Notifications
You must be signed in to change notification settings - Fork 93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace StudySummary to FrozenStudy in serializing #809
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -12,7 +12,7 @@ | |||
from optuna.distributions import CategoricalDistribution | ||||
from optuna.distributions import FloatDistribution | ||||
from optuna.distributions import IntDistribution | ||||
from optuna.study import StudySummary | ||||
from optuna.study._frozen import FrozenStudy | ||||
from optuna.trial import FrozenTrial | ||||
|
||||
from . import _note as note | ||||
|
@@ -116,25 +116,20 @@ def serialize_attrs(attrs: dict[str, Any]) -> list[Attribute]: | |||
return serialized | ||||
|
||||
|
||||
def serialize_study_summary(summary: StudySummary) -> dict[str, Any]: | ||||
def serialize_frozen_study(study: FrozenStudy) -> dict[str, Any]: | ||||
serialized = { | ||||
"study_id": summary._study_id, | ||||
"study_name": summary.study_name, | ||||
"directions": [d.name.lower() for d in summary.directions], | ||||
"user_attrs": serialize_attrs(summary.user_attrs), | ||||
"is_preferential": getattr(summary, "_system_attrs", {}).get( | ||||
_SYSTEM_ATTR_PREFERENTIAL_STUDY, False | ||||
), | ||||
"study_id": study._study_id, | ||||
"study_name": study.study_name, | ||||
"directions": [d.name.lower() for d in study.directions], | ||||
"user_attrs": serialize_attrs(study.user_attrs), | ||||
"is_preferential": study.system_attrs.get(_SYSTEM_ATTR_PREFERENTIAL_STUDY, False), | ||||
} | ||||
|
||||
if summary.datetime_start is not None: | ||||
serialized["datetime_start"] = summary.datetime_start.isoformat() | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To add There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would say we should drop
|
||||
|
||||
return serialized | ||||
|
||||
|
||||
def serialize_study_detail( | ||||
summary: StudySummary, | ||||
study: FrozenStudy, | ||||
best_trials: list[FrozenTrial], | ||||
trials: list[FrozenTrial], | ||||
intersection: list[tuple[str, BaseDistribution]], | ||||
|
@@ -145,20 +140,18 @@ def serialize_study_detail( | |||
skipped_trial_numbers: list[int], | ||||
) -> dict[str, Any]: | ||||
serialized: dict[str, Any] = { | ||||
"name": summary.study_name, | ||||
"directions": [d.name.lower() for d in summary.directions], | ||||
"user_attrs": serialize_attrs(summary.user_attrs), | ||||
"name": study.study_name, | ||||
"directions": [d.name.lower() for d in study.directions], | ||||
"user_attrs": serialize_attrs(study.user_attrs), | ||||
} | ||||
system_attrs = getattr(summary, "system_attrs", {}) | ||||
system_attrs = study.system_attrs | ||||
serialized["artifacts"] = list_study_artifacts(system_attrs) | ||||
if summary.datetime_start is not None: | ||||
serialized["datetime_start"] = summary.datetime_start.isoformat() | ||||
|
||||
serialized["trials"] = [ | ||||
serialize_frozen_trial(summary._study_id, trial, system_attrs) for trial in trials | ||||
serialize_frozen_trial(study._study_id, trial, system_attrs) for trial in trials | ||||
] | ||||
serialized["best_trials"] = [ | ||||
serialize_frozen_trial(summary._study_id, trial, system_attrs) for trial in best_trials | ||||
serialize_frozen_trial(study._study_id, trial, system_attrs) for trial in best_trials | ||||
] | ||||
serialized["intersection_search_space"] = serialize_search_space(intersection) | ||||
serialized["union_search_space"] = serialize_search_space(union) | ||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should I change the key name of
study_summaries
andstudy_summary
to something?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a todo comment? For now, we cannot introduce the breaking changes in JSON Web APIs since our Jupyter Lab extension uses it.