Skip to content

Commit

Permalink
Merge pull request optuna#5103 from Guillaume227/master
Browse files Browse the repository at this point in the history
FileStorage: enable loading of read-only files
  • Loading branch information
not522 authored Nov 28, 2023
2 parents f742a10 + 1a123b4 commit 4a9a121
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion optuna/storages/_journal/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,8 @@ class JournalFileStorage(BaseJournalLogStorage):
def __init__(self, file_path: str, lock_obj: Optional[JournalFileBaseLock] = None) -> None:
self._file_path: str = file_path
self._lock = lock_obj or JournalFileSymlinkLock(self._file_path)
open(self._file_path, "ab").close() # Create a file if it does not exist
if not os.path.exists(self._file_path):
open(self._file_path, "ab").close() # Create a file if it does not exist
self._log_number_offset: Dict[int, int] = {0: 0}

def read_logs(self, log_number_from: int) -> List[Dict[str, Any]]:
Expand Down

0 comments on commit 4a9a121

Please sign in to comment.