File tree Expand file tree Collapse file tree 3 files changed +16
-14
lines changed
Expand file tree Collapse file tree 3 files changed +16
-14
lines changed Original file line number Diff line number Diff line change @@ -85,18 +85,18 @@ def experiment_exists(experiment_dir: Path) -> bool:
8585 return (experiment_dir / "results.json" ).exists ()
8686
8787
88- def check_safe_to_run (experiment_dir : Path , * , force : bool = False ) -> None :
89- """Check if it's safe to run an experiment .
88+ def should_skip_experiment (experiment_dir : Path , * , force : bool = False ) -> bool :
89+ """Check if an experiment should be skipped .
9090
9191 Args:
9292 experiment_dir: Path to experiment directory.
9393 force: If True, allow overwriting existing results.
9494
95- Raises :
96- FileExistsError: If experiment exists and force is False .
95+ Returns :
96+ True if the experiment should be skipped (already exists and not forcing) .
9797 """
9898 if experiment_exists (experiment_dir ) and not force :
99- raise FileExistsError (
100- f"Experiment already exists: { experiment_dir } \n "
101- f"Use --force to overwrite, or check if this is a duplicate run."
102- )
99+ print ( f" \n [SKIP] Experiment already exists: { experiment_dir } " )
100+ print ( " Use --force to overwrite. \n ")
101+ return True
102+ return False
Original file line number Diff line number Diff line change 2626)
2727from experiments .datasets .factory import AUGMENT_CHOICES , get_dataset
2828from experiments .models .factory import get_model
29- from experiments .paths import check_safe_to_run
29+ from experiments .paths import should_skip_experiment
3030from experiments .training import checkpoint , logging_config
3131from experiments .training .loops import evaluate , get_scheduler , train_epoch
3232
@@ -199,8 +199,9 @@ def main() -> None:
199199 quiet = args .quiet ,
200200 )
201201
202- # Safety check: prevent accidental overwrites
203- check_safe_to_run (Path (config .output_dir ), force = args .force )
202+ # Skip if experiment already exists (unless --force)
203+ if should_skip_experiment (Path (config .output_dir ), force = args .force ):
204+ return
204205
205206 train (config )
206207
Original file line number Diff line number Diff line change 2525)
2626from experiments .datasets .factory import AUGMENT_CHOICES , get_dataset
2727from experiments .models .factory import get_model
28- from experiments .paths import ExperimentType , check_safe_to_run , get_experiment_dir
28+ from experiments .paths import ExperimentType , get_experiment_dir , should_skip_experiment
2929from experiments .training import checkpoint , logging_config
3030from experiments .training .kd_loss import KDLoss
3131from experiments .training .loops import evaluate , get_scheduler
@@ -253,8 +253,9 @@ def main() -> None:
253253 )
254254 args .output_dir = str (experiment_dir )
255255
256- # Safety check: prevent accidental overwrites
257- check_safe_to_run (Path (args .output_dir ), force = args .force )
256+ # Skip if experiment already exists (unless --force)
257+ if should_skip_experiment (Path (args .output_dir ), force = args .force ):
258+ return
258259
259260 config = TrainConfig (
260261 model = args .model ,
You can’t perform that action at this time.
0 commit comments