Skip to content

Commit 093ae4b

Browse files
committed
Fix dat path handling
Use public cache in xp65 by default on gadi if accessible
1 parent 778898c commit 093ae4b

File tree

1 file changed

+19
-10
lines changed

1 file changed

+19
-10
lines changed

src/accessvis/earth.py

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,23 +30,32 @@ class Settings():
3030
GRIDRES = 1024
3131
MAXGRIDRES = 4096
3232

33-
#Where data is stored, defaults to module dir unless on gadi
3433
INSTALL_PATH = Path(__file__).parents[0]
3534

3635
# Default to non-headless mode
3736
HEADLESS = False
37+
hostname = os.getenv('HOSTNAME', '')
38+
gadi = 'gadi.nci.org.au' in hostname
39+
if gadi:
40+
#Enable headless via moderngl when running on gadi
41+
HEADLESS = True
42+
43+
# Where data is stored, should use public cache dir on gadi
3844
# Check if the data directory is specified in environment variables
39-
DATA_PATH = os.getenv("ACCESSVIS_DATA_DIR")
45+
DATA_PATH = Path(os.getenv("ACCESSVIS_DATA_DIR"))
4046

4147
# Check if running on 'gadi.nci.org.au'
42-
hostname = os.getenv('HOSTNAME', '')
43-
if not DATA_PATH and 'gadi.nci.org.au' in hostname:
44-
project = os.getenv("PROJECT")
45-
user = os.getenv("USER")
46-
DATA_PATH = Path(f'/scratch/{project}/{user}/.accessvis')
47-
HEADLESS = True
48-
else:
49-
DATA_PATH = Path.home() / ".accessvis"
48+
if not DATA_PATH:
49+
if gadi:
50+
#Use public shared data cache on gadi
51+
DATA_PATH = Path('/g/data/xp65/public/apps/access-vis-data')
52+
if not os.access(DATA_PATH, os.R_OK):
53+
#Use /scratch
54+
project = os.getenv("PROJECT")
55+
user = os.getenv("USER")
56+
DATA_PATH = Path(f'/scratch/{project}/{user}/.accessvis')
57+
else:
58+
DATA_PATH = Path.home() / ".accessvis"
5059

5160
os.makedirs(DATA_PATH, exist_ok=True)
5261

0 commit comments

Comments
 (0)