Skip to content

Commit

Permalink
Add document specifying FileOpenLock code
Browse files Browse the repository at this point in the history
  • Loading branch information
hrntsm committed Jan 5, 2023
1 parent 2a48efa commit 02fa77d
Showing 1 changed file with 15 additions and 1 deletion.
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

0 comments on commit 02fa77d

Please sign in to comment.