@@ -364,14 +364,14 @@ def _per_job_subpath(self) -> str:
364364 obj_id = self ._job .id
365365 return os .path .join (* directory_hash_id (obj_id ), str (obj_id ))
366366
367- def _per_job_path (self ) -> str :
367+ def _per_job_path (self , custom_path : str ) -> str :
368368 """Return ``<custom_base>/<directory_hash_id(job.id)>/<job.id>/``."""
369- return os .path .join (self . _custom_path , self ._per_job_subpath ())
369+ return os .path .join (custom_path , self ._per_job_subpath ())
370370
371371 def resolve (self ) -> str :
372372 """Return the working directory path, creating nothing on disk."""
373- if self ._custom_path :
374- return self ._per_job_path ()
373+ if custom_path := self ._custom_path :
374+ return self ._per_job_path (custom_path )
375375 return self ._object_store .get_filename (
376376 self ._job ,
377377 base_dir = _JOB_WORK_BASE_DIR ,
@@ -381,8 +381,8 @@ def resolve(self) -> str:
381381
382382 def exists (self ) -> bool :
383383 """Check whether the working directory exists on disk."""
384- if self ._custom_path :
385- return os .path .exists (self ._per_job_path ())
384+ if custom_path := self ._custom_path :
385+ return os .path .exists (self ._per_job_path (custom_path ))
386386 return self ._object_store .exists (
387387 self ._job ,
388388 base_dir = _JOB_WORK_BASE_DIR ,
@@ -396,9 +396,9 @@ def create(self) -> str:
396396 Raises ``FileExistsError`` if the per-job directory already exists
397397 (job id collision or leftover from a crashed run).
398398 """
399- if self ._custom_path :
400- validate_working_directory_path (self . _custom_path )
401- path = self ._per_job_path ()
399+ if custom_path := self ._custom_path :
400+ validate_working_directory_path (custom_path )
401+ path = self ._per_job_path (custom_path )
402402 try :
403403 os .makedirs (path , exist_ok = False )
404404 except FileExistsError as exc :
@@ -427,9 +427,9 @@ def delete(self) -> None:
427427 For custom paths, only the per-job subdirectory is removed; the
428428 admin-supplied base is preserved for other jobs.
429429 """
430- if self ._custom_path :
431- validate_working_directory_path (self . _custom_path )
432- resolved = self ._per_job_path ()
430+ if custom_path := self ._custom_path :
431+ validate_working_directory_path (custom_path )
432+ resolved = self ._per_job_path (custom_path )
433433 if os .path .exists (resolved ):
434434 shutil .rmtree (resolved )
435435 return
@@ -448,10 +448,10 @@ def cleared_contents_base(self) -> str:
448448 sibling tree of the JWD (keyed by ``<hash>/<job.id>``) so resubmits
449449 don't collide on the archive name.
450450 """
451- if self ._custom_path :
452- validate_working_directory_path (self . _custom_path )
451+ if custom_path := self ._custom_path :
452+ validate_working_directory_path (custom_path )
453453 path = os .path .join (
454- self . _custom_path ,
454+ custom_path ,
455455 _CLEARED_CONTENTS_EXTRA_DIR ,
456456 self ._per_job_subpath (),
457457 )
0 commit comments