Skip to content

Commit

Permalink
Enable FileStorage loading of existing read-only files
Browse files Browse the repository at this point in the history
  • Loading branch information
Guillaume227 committed Nov 10, 2023
1 parent f966055 commit 1a123b4
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 1a123b4

Please sign in to comment.