Skip to content
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

Improve the document of JournalStorage #4308

Merged
merged 1 commit into from
Jan 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 15 additions & 1 deletion optuna/storages/_journal/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class JournalStorage(BaseStorage):
operations stored from the beginning.

Journal storage has several benefits over the conventional value logging storages.

1. The number of IOs can be reduced because of larger granularity of logs.
2. Journal storage has simpler backend API than value logging storage.
3. Journal storage keeps a snapshot in-memory so no need to add more cache.
Expand All @@ -77,11 +78,24 @@ def objective(trial):


storage = optuna.storages.JournalStorage(
optuna.storages.JournalFileStorage("./log_file"),
optuna.storages.JournalFileStorage("./journal.log"),
)

study = optuna.create_study(storage=storage)
study.optimize(objective)

In a Windows environment, an error message "A required privilege is not held by the
client" may appear. In this case, you can solve the problem with creating storage
by specifying :class:`~optuna.storages.JournalFileOpenLock` as follows.

.. code::

file_path = "./journal.log"
lock_obj = optuna.storages.JournalFileOpenLock(file_path)

storage = optuna.storages.JournalStorage(
optuna.storages.JournalFileStorage(file_path, lock_obj=lock_obj),
)
"""

def __init__(self, log_storage: BaseJournalLogStorage) -> None:
Expand Down