Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 22 additions & 3 deletions src/virtualship/cli/_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import logging
import os
import shutil
import sys
import time
from datetime import datetime
from pathlib import Path
Expand Down Expand Up @@ -131,9 +132,12 @@ def _run(
return

# delete and create results directory
if os.path.exists(expedition_dir.joinpath(RESULTS)):
shutil.rmtree(expedition_dir.joinpath(RESULTS))
os.makedirs(expedition_dir.joinpath(RESULTS))
results_dir = expedition_dir.joinpath(RESULTS)
_warn_overwrite_results_dir(results_dir)

if os.path.exists(results_dir):
shutil.rmtree(results_dir)
os.makedirs(results_dir)

print("\n----- EXPEDITION SUMMARY ------")

Expand Down Expand Up @@ -284,6 +288,21 @@ def _unique_id(expedition: Expedition, cache_dir: Path) -> str:
return new_id


def _warn_overwrite_results_dir(results_dir: Path) -> None:
if os.path.exists(results_dir):
print(
f"\nWARNING: The '{results_dir}' directory already exists and will be overwritten. If you want to keep the previous results, please move or rename the '{results_dir}' directory before re-running the expedition.\n"
)
decision = input(
"Do you want to continue the expedition run and thereby overwrite the existing results? (y/n): "
)
if decision.lower() != "y":
print("Expedition run cancelled by user.")
sys.exit(0)
if decision.lower() == "y":
print("Continuing with expedition run and overwriting existing results...")


def _load_checkpoint(expedition_dir: Path) -> Checkpoint | None:
file_path = expedition_dir.joinpath(CHECKPOINT)
try:
Expand Down