-
-
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
Add journal storage loader #732
Add journal storage loader #732
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #732 +/- ##
=======================================
Coverage 68.22% 68.22%
=======================================
Files 35 35
Lines 2329 2329
=======================================
Hits 1589 1589
Misses 740 740 ☔ View full report in Codecov by Sentry. |
@c-bata Could you review this PR? |
@c-bata I removed you from the assignee of this PR. |
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.
This is early review comment. I checked PR other than JournalStorage implementation. I will check it later 🙏
Btw, I hope we can add some tests for it. At least, can you add e2e test for this one similar to this test?
optuna-dashboard/e2e_tests/test_standalone/test_study_list.py
Lines 28 to 74 in 38cc928
def test_load_storage( | |
page: Page, | |
server_url: str, | |
) -> None: | |
study_name = "single-objective" | |
url = f"{server_url}" | |
def create_storage_file(filename: str): | |
import optuna | |
storage = optuna.storages.RDBStorage(f"sqlite:///{filename}") | |
study = optuna.create_study(study_name=study_name, storage=storage) | |
def objective(trial: optuna.Trial) -> float: | |
x1 = trial.suggest_float("x1", 0, 10) | |
x2 = trial.suggest_float("x2", 0, 10) | |
return (x1 - 2) ** 2 + (x2 - 5) ** 2 | |
study.optimize(objective, n_trials=100) | |
with tempfile.TemporaryDirectory() as dir: | |
with tempfile.NamedTemporaryFile() as fp: | |
filename = fp.name | |
path = os.path.join(dir, filename) | |
create_storage_file(filename) | |
page.goto(url) | |
with page.expect_file_chooser() as fc_info: | |
page.get_by_role( | |
"button", | |
name="Load an Optuna Storage Drag your SQLite3 file here or click to browse.", | |
).click() | |
file_chooser = fc_info.value | |
file_chooser.set_files(path) | |
page.get_by_role("link", name=study_name).click() | |
def count_components(page: Page, component_name: str): | |
component_count = page.evaluate( | |
f"""() => {{ | |
const components = document.querySelectorAll('.{component_name}'); | |
return components.length; | |
}}""" | |
) | |
return component_count | |
count = count_components(page, "MuiCard-root") | |
assert count == 4 |
if (headerString === "SQLite format 3\u0000") { | ||
loadSQLite3Storage(arrayBuffer, setStudies) | ||
} else { | ||
loadJournalStorage(arrayBuffer, setStudies) |
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.
[question] Do you have any way to check that the file is compatible with JournalStorage? If yes, we can add "else if" to check it.
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.
Unfortunately, there is no "header" or special "flag" in the JournalStorage log. The only requirement for JournalStorage is a JSON line file. We can detect the format by parsing the first line of the log, but I believe this should be handled in the JournalStorage
class.
if (headerString === "SQLite format 3\u0000") { | ||
loadSQLite3Storage(arrayBuffer, onceSetStudies) | ||
} else { | ||
loadJournalStorage(arrayBuffer, onceSetStudies) |
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.
ditto.
@keisuke-umezawa Thank you for your comments! |
@gen740 |
I confirmed that it also works well in my env. I merge it. Let's add some tests later. |
Contributor License Agreement
This repository (
optuna-dashboard
) and Goptuna share common code.This pull request may therefore be ported to Goptuna.
Make sure that you understand the consequences concerning licenses and check the box below if you accept the term before creating this pull request.
Reference Issues/PRs
None
What does this implement/fix? Explain your changes.
journalStorage.ts
into standalone app, enablingjournal storage
support.