optuna.storages.journal.JournalFileBackend
- class optuna.storages.journal.JournalFileBackend(file_path, lock_obj=None)[source]
File storage class for Journal log backend.
Compared to SQLite3, the benefit of this backend is that it is more suitable for environments where the file system does not support
fcntl()
file locking. For example, as written in the SQLite3 FAQ, SQLite3 might not work on NFS (Network File System) sincefcntl()
file locking is broken on many NFS implementations. In such scenarios, this backend provides several workarounds for locking files. For more details, refer to the Medium blog post.It’s important to note that, similar to SQLite3, this class doesn’t support a high level of write concurrency, as outlined in the SQLAlchemy documentation. However, in typical situations where the objective function is computationally expensive, Optuna users don’t need to be concerned about this limitation. The reason being, the write operations are not the bottleneck as long as the objective function doesn’t invoke
report()
andset_user_attr()
excessively.- Parameters:
file_path (str) – Path of file to persist the log to.
lock_obj (BaseJournalFileLock | None) – Lock object for process exclusivity. An instance of
JournalFileSymlinkLock
andJournalFileOpenLock
can be passed.
Methods
append_logs
(logs)Append logs to the backend.
read_logs
(log_number_from)Read logs with a log number greater than or equal to
log_number_from
.