From 42f5a9b5538246b57de4fc4a9f379ed5cc88aa15 Mon Sep 17 00:00:00 2001 From: anrp Date: Sun, 25 Jan 2026 14:04:01 +0000 Subject: [PATCH] fix: Use file instead of symlink lock (for windows) (#116) --- src/heretic/main.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/heretic/main.py b/src/heretic/main.py index 3ee924b..e8d4f0a 100644 --- a/src/heretic/main.py +++ b/src/heretic/main.py @@ -28,7 +28,7 @@ from optuna import Trial, TrialPruned from optuna.exceptions import ExperimentalWarning from optuna.samplers import TPESampler from optuna.storages import JournalStorage -from optuna.storages.journal import JournalFileBackend +from optuna.storages.journal import JournalFileBackend, JournalFileOpenLock from optuna.study import StudyDirection from optuna.trial import TrialState from pydantic import ValidationError @@ -257,7 +257,8 @@ def run(): ) os.makedirs(settings.study_checkpoint_dir, exist_ok=True) - backend = JournalFileBackend(study_checkpoint_file) + lock_obj = JournalFileOpenLock(study_checkpoint_file) + backend = JournalFileBackend(study_checkpoint_file, lock_obj=lock_obj) storage = JournalStorage(backend) try: @@ -302,7 +303,7 @@ def run(): ) elif choice == "restart": os.unlink(study_checkpoint_file) - backend = JournalFileBackend(study_checkpoint_file) + backend = JournalFileBackend(study_checkpoint_file, lock_obj=lock_obj) storage = JournalStorage(backend) else: print("Cancelled; exiting.")