@@ -373,14 +373,15 @@ def job_kill(self, st_file_path):
373
373
374
374
@classmethod
375
375
def _create_nn (cls , job_file_path ):
376
- """Create NN symbolic link, if necessary.
376
+ """Create NN symbolic link, or remove old job logs if they exist.
377
+
378
+ If NN => 01, remove numbered dirs with submit numbers greater than 01.
377
379
378
- If NN => 01, remove numbered directories with submit numbers greater
379
- than 01.
380
380
Helper for "self._job_submit_impl".
381
381
382
382
"""
383
383
job_file_dir = os .path .dirname (job_file_path )
384
+
384
385
source = os .path .basename (job_file_dir )
385
386
task_log_dir = os .path .dirname (job_file_dir )
386
387
nn_path = os .path .join (task_log_dir , "NN" )
@@ -393,6 +394,7 @@ def _create_nn(cls, job_file_path):
393
394
old_source = None
394
395
if old_source is None :
395
396
os .symlink (source , nn_path )
397
+
396
398
# On submit 1, remove any left over digit directories from prev runs
397
399
if source == "01" :
398
400
for name in os .listdir (task_log_dir ):
@@ -401,6 +403,11 @@ def _create_nn(cls, job_file_path):
401
403
rmtree (
402
404
os .path .join (task_log_dir , name ), ignore_errors = True )
403
405
406
+ # Delete old job logs if necessary
407
+ for name in JOB_LOG_ERR , JOB_LOG_OUT :
408
+ with suppress (FileNotFoundError ):
409
+ os .unlink (os .path .join (job_file_dir , name ))
410
+
404
411
@classmethod
405
412
def _filter_submit_output (cls , st_file_path , job_runner , out , err ):
406
413
"""Filter submit command output, if relevant."""
@@ -567,9 +574,6 @@ def _job_submit_impl(
567
574
568
575
# Create NN symbolic link, if necessary
569
576
self ._create_nn (job_file_path )
570
- for name in JOB_LOG_ERR , JOB_LOG_OUT :
571
- with suppress (FileNotFoundError ):
572
- os .unlink (os .path .join (os .path .dirname (job_file_path ), name ))
573
577
574
578
# Start new status file
575
579
with open (f"{ job_file_path } .status" , "w" ) as job_status_file :
0 commit comments