Skip to content

Commit 7328b7c

Browse files
committed
Tweak previous commit.
1 parent 320e98b commit 7328b7c

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

cylc/flow/job_runner_mgr.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -373,14 +373,15 @@ def job_kill(self, st_file_path):
373373

374374
@classmethod
375375
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.
377379
378-
If NN => 01, remove numbered directories with submit numbers greater
379-
than 01.
380380
Helper for "self._job_submit_impl".
381381
382382
"""
383383
job_file_dir = os.path.dirname(job_file_path)
384+
384385
source = os.path.basename(job_file_dir)
385386
task_log_dir = os.path.dirname(job_file_dir)
386387
nn_path = os.path.join(task_log_dir, "NN")
@@ -393,6 +394,7 @@ def _create_nn(cls, job_file_path):
393394
old_source = None
394395
if old_source is None:
395396
os.symlink(source, nn_path)
397+
396398
# On submit 1, remove any left over digit directories from prev runs
397399
if source == "01":
398400
for name in os.listdir(task_log_dir):
@@ -401,6 +403,11 @@ def _create_nn(cls, job_file_path):
401403
rmtree(
402404
os.path.join(task_log_dir, name), ignore_errors=True)
403405

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+
404411
@classmethod
405412
def _filter_submit_output(cls, st_file_path, job_runner, out, err):
406413
"""Filter submit command output, if relevant."""
@@ -567,9 +574,6 @@ def _job_submit_impl(
567574

568575
# Create NN symbolic link, if necessary
569576
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))
573577

574578
# Start new status file
575579
with open(f"{job_file_path}.status", "w") as job_status_file:

0 commit comments

Comments
 (0)