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) since fcntl() 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() and set_user_attr() excessively.

Parameters:

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.

append_logs(logs)[source]

Append logs to the backend.

Parameters:

logs (list[dict[str, Any]]) – A list that contains json-serializable logs.

Return type:

None

read_logs(log_number_from)[source]

Read logs with a log number greater than or equal to log_number_from.

If log_number_from is 0, read all the logs.

Parameters:

log_number_from (int) – A non-negative integer value indicating which logs to read.

Returns:

Logs with log number greater than or equal to log_number_from.

Return type:

list[dict[str, Any]]