23
23
ETC_PATH ,
24
24
MAX_NUMBER_OUTPUTS ,
25
25
PREVIOUS_LOGGING_CHECKSUMS ,
26
- SCRATCH_PATH ,
27
26
)
28
27
from ..exceptions import RSPErrorCode , RSPStartupError
29
28
from ..models .noninteractive import NonInteractiveExecutor
@@ -172,9 +171,9 @@ def _set_user(self) -> None:
172
171
173
172
def _check_user_scratch_subdir (self , path : Path ) -> Path | None :
174
173
# This is very Rubin specific. We generally have a large
175
- # world-writable filesystem in SCRATCH_PATH (`/ scratch`) .
174
+ # world-writable filesystem in a scratch path .
176
175
#
177
- # Given a path we well test that SCRATCH_PATH/user/path can be
176
+ # Given a path we will test that SCRATCH_PATH/user/path can be
178
177
# created as a writable directory (or that it already exists
179
178
# as a writable directory). If it can be (or is), we return the
180
179
# whole path, and if not, we return None.
@@ -183,17 +182,20 @@ def _check_user_scratch_subdir(self, path: Path) -> Path | None:
183
182
# they want to share, but for TMPDIR and DAF_BUTLER_CACHE_DIRECTORY
184
183
# they probably should not. The mode will not be reset if the
185
184
# directory already exists and is writeable
186
- if not SCRATCH_PATH .is_dir ():
185
+
186
+ scratch_path = Path (os .getenv ("SCRATCH_PATH" ) or "/scratch" )
187
+
188
+ if not scratch_path .is_dir ():
187
189
self ._logger .debug (
188
190
# Debug only: not having /scratch is reasonable.
189
- f"{ SCRATCH_PATH } is not a directory."
191
+ f"{ scratch_path } is not a directory."
190
192
)
191
193
return None
192
194
user = self ._env .get ("USER" , "" )
193
195
if not user :
194
196
self ._logger .warning ("Could not determine user from environment" )
195
197
return None
196
- user_scratch_path = SCRATCH_PATH / user / path
198
+ user_scratch_path = scratch_path / user / path
197
199
try :
198
200
user_scratch_path .mkdir (parents = True , exist_ok = True , mode = 0o700 )
199
201
except OSError as exc :
@@ -209,14 +211,14 @@ def _check_user_scratch_subdir(self, path: Path) -> Path | None:
209
211
210
212
def _set_tmpdir_if_scratch_available (self ) -> None :
211
213
# Assuming that TMPDIR is not already set (e.g. by the spawner),
212
- # we will try to create <SCRATCH_PATH >/<user>/tmp and ensure it is a
214
+ # we will try to create <scratch_path >/<user>/tmp and ensure it is a
213
215
# writeable directory, and if it is, TMPDIR will be repointed to it.
214
216
# This will then reduce our ephemeral storage issues, which have
215
217
# caused mass pod eviction and destruction of the prepull cache.
216
218
#
217
219
# In our tests at the IDF, on a 2CPU/8GiB "Medium", TMPDIR on
218
220
# /scratch (NFS) is about 15% slower than on local ephemeral storage.
219
- self ._logger .debug (f "Resetting TMPDIR if { SCRATCH_PATH } available" )
221
+ self ._logger .debug ("Resetting TMPDIR if scratch storage available" )
220
222
tmpdir = self ._env .get ("TMPDIR" , "" )
221
223
if tmpdir :
222
224
self ._logger .debug (f"Not setting TMPDIR: already set to { tmpdir } " )
0 commit comments