Charles Azam commited on
Commit
485e053
·
1 Parent(s): 6a6d57d

feat: check if on spaces

Browse files
Files changed (1) hide show
  1. src/deepengineer/common_path.py +11 -2
src/deepengineer/common_path.py CHANGED
@@ -1,4 +1,9 @@
1
  from pathlib import Path
 
 
 
 
 
2
 
3
  DEEPENGINEER_CODE_DIR = Path(__file__).parent
4
  DEEPENGINEER_SRC_DIR = DEEPENGINEER_CODE_DIR.parent
@@ -7,5 +12,9 @@ DEEPENGINEER_ROOT_DIR = DEEPENGINEER_SRC_DIR.parent
7
  assert DEEPENGINEER_CODE_DIR.name == "deepengineer"
8
  assert DEEPENGINEER_SRC_DIR.name == "src"
9
 
10
- DATA_DIR = DEEPENGINEER_ROOT_DIR / "data"
11
- assert DATA_DIR.exists()
 
 
 
 
 
1
  from pathlib import Path
2
+ import os
3
+
4
+ def is_on_spaces():
5
+ return "SPACE_ID" in os.environ or "HF_SPACE_ID" in os.environ
6
+
7
 
8
  DEEPENGINEER_CODE_DIR = Path(__file__).parent
9
  DEEPENGINEER_SRC_DIR = DEEPENGINEER_CODE_DIR.parent
 
12
  assert DEEPENGINEER_CODE_DIR.name == "deepengineer"
13
  assert DEEPENGINEER_SRC_DIR.name == "src"
14
 
15
+ if is_on_spaces():
16
+ DATA_DIR = Path("/data")
17
+ else:
18
+ DATA_DIR = DEEPENGINEER_ROOT_DIR / "data"
19
+
20
+ assert DATA_DIR.exists()