Skip to content

Commit

Permalink
fix: robust path finding
Browse files Browse the repository at this point in the history
  • Loading branch information
TianyiQ committed Nov 28, 2024
1 parent a58dcd6 commit 273e501
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/abstractions/configs/templates_configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@
if not os.path.exists(data_save_path):
data_save_path = f"{root}/" + data_save_path
if not os.path.exists(data_save_path):
raise FileNotFoundError(f"Data save path {data_save_path} doesn't exist.")
print(f"Data save path {data_save_path} doesn't exist. Creating it.")
os.makedirs(data_save_path)

for i, path in enumerate(data_search_paths):
if not os.path.exists(path):
Expand All @@ -144,7 +145,8 @@
if not os.path.exists(model_save_path):
model_save_path = f"{root}/" + model_save_path
if not os.path.exists(model_save_path):
raise FileNotFoundError(f"Model save path {model_save_path} doesn't exist.")
print(f"Model save path {model_save_path} doesn't exist. Creating it.")
os.makedirs(model_save_path)

for i, path in enumerate(model_search_paths):
if not os.path.exists(path):
Expand Down
2 changes: 1 addition & 1 deletion src/evaluation/quantify.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
if not os.path.exists(f"{root}/output/evaluation_results/figs"):
os.makedirs(f"{root}/output/evaluation_results/figs")

if not os.path.exists(f"{root}logs/eval"):
if not os.path.exists(f"{root}/logs/eval"):
os.makedirs(f"{root}/logs/eval")


Expand Down
2 changes: 1 addition & 1 deletion src/path.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import os, sys
root = "src".join(os.path.dirname(os.path.abspath(__file__)).split("src")[:-1]).strip("/").strip("\\")
root = "src".join(os.path.dirname(os.path.abspath(__file__)).split("src")[:-1]).rstrip("/").rstrip("\\")
print(f"Library root directory: {root}")

0 comments on commit 273e501

Please sign in to comment.