From 797bb9d869c8bad23cf57121773ffc39ab8a6e6c Mon Sep 17 00:00:00 2001 From: Yuman Hordijk Date: Fri, 17 May 2024 16:40:43 +0200 Subject: [PATCH 1/5] Printing line to check sbatch output --- src/tcutility/slurm.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/tcutility/slurm.py b/src/tcutility/slurm.py index e1eb3d0c..fda0a646 100644 --- a/src/tcutility/slurm.py +++ b/src/tcutility/slurm.py @@ -102,7 +102,8 @@ def sbatch(runfile: str, **options: dict) -> results.Result: sbatch_out = sp.check_output(cmd.split(), stderr=sp.STDOUT).decode() # get the slurm job id from the output for line in sbatch_out.splitlines(): - if line.startswith('Submitted batch job'): + print(line) + if 'Submitted batch job' in line: # set the slurm job id for this calculation, we use this in order to set dependencies between jobs. ret.id = line.strip().split()[-1] break From 3f0cdd2f0a1d3fe1f6f564f0c3b4c43bf8642e49 Mon Sep 17 00:00:00 2001 From: Yuman Hordijk Date: Fri, 17 May 2024 16:44:09 +0200 Subject: [PATCH 2/5] Printing id --- src/tcutility/slurm.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/tcutility/slurm.py b/src/tcutility/slurm.py index fda0a646..920b904f 100644 --- a/src/tcutility/slurm.py +++ b/src/tcutility/slurm.py @@ -106,6 +106,7 @@ def sbatch(runfile: str, **options: dict) -> results.Result: if 'Submitted batch job' in line: # set the slurm job id for this calculation, we use this in order to set dependencies between jobs. ret.id = line.strip().split()[-1] + print(ret.id) break return ret From 804eeafde6deb8a8bf7a307e2dcb41c3a018cb0b Mon Sep 17 00:00:00 2001 From: Yuman Hordijk Date: Fri, 17 May 2024 16:53:04 +0200 Subject: [PATCH 3/5] can_skip and in_queue are now properties --- src/tcutility/job/generic.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/tcutility/job/generic.py b/src/tcutility/job/generic.py index 35d02ae7..b39ef291 100644 --- a/src/tcutility/job/generic.py +++ b/src/tcutility/job/generic.py @@ -75,6 +75,7 @@ def __exit__(self, exc_type, exc_value, exc_tb): return True self.run() + @property def can_skip(self): ''' Check whether the job can be skipped. We check this by loading the calculation and checking if the job status was fatal. @@ -89,6 +90,15 @@ def can_skip(self): res = results.read(self.workdir) return not res.status.fatal + @property + def in_queue(self): + ''' + Check whether the job is currently managed by slurm. + We check this by loading the calculation and checking if the job status is 'RUNNING', 'COMPLETING', 'CONFIGURING' or 'PENDING'. + ''' + res = results.read(self.workdir) + return res.status.name in ['RUNNING', 'COMPLETING', 'CONFIGURING', 'PENDING'] + def __repr__(self): return f'{type(self)}(name={self.name}, rundir={self.rundir})' @@ -224,7 +234,8 @@ def dependency(self, otherjob: 'Job'): Set a dependency between this job and otherjob. This means that this job will run after the other job is finished running succesfully. ''' - if otherjob.can_skip: + print(otherjob, otherjob.slurm_job_id, otherjob.can_skip, otherjob.in_queue) + if otherjob.can_skip and not otherjob.in_queue: return if hasattr(otherjob, 'slurm_job_id'): From 15790b6e7f8fb2adce18121c09826e830041e2d0 Mon Sep 17 00:00:00 2001 From: Yuman Hordijk Date: Fri, 17 May 2024 16:54:12 +0200 Subject: [PATCH 4/5] can_skip and in_queue are now methods --- src/tcutility/job/generic.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/tcutility/job/generic.py b/src/tcutility/job/generic.py index b39ef291..15f12362 100644 --- a/src/tcutility/job/generic.py +++ b/src/tcutility/job/generic.py @@ -75,7 +75,6 @@ def __exit__(self, exc_type, exc_value, exc_tb): return True self.run() - @property def can_skip(self): ''' Check whether the job can be skipped. We check this by loading the calculation and checking if the job status was fatal. @@ -90,7 +89,6 @@ def can_skip(self): res = results.read(self.workdir) return not res.status.fatal - @property def in_queue(self): ''' Check whether the job is currently managed by slurm. @@ -234,8 +232,8 @@ def dependency(self, otherjob: 'Job'): Set a dependency between this job and otherjob. This means that this job will run after the other job is finished running succesfully. ''' - print(otherjob, otherjob.slurm_job_id, otherjob.can_skip, otherjob.in_queue) - if otherjob.can_skip and not otherjob.in_queue: + print(otherjob, otherjob.slurm_job_id, otherjob.can_skip(), otherjob.in_queue()) + if otherjob.can_skip() and not otherjob.in_queue(): return if hasattr(otherjob, 'slurm_job_id'): From 8e652dc0e5bfe61a33e8efab2a47470d262e32b2 Mon Sep 17 00:00:00 2001 From: Yuman Hordijk Date: Fri, 17 May 2024 16:57:41 +0200 Subject: [PATCH 5/5] Removed some print statements --- src/tcutility/job/generic.py | 1 - src/tcutility/slurm.py | 2 -- 2 files changed, 3 deletions(-) diff --git a/src/tcutility/job/generic.py b/src/tcutility/job/generic.py index 15f12362..71ddf19a 100644 --- a/src/tcutility/job/generic.py +++ b/src/tcutility/job/generic.py @@ -232,7 +232,6 @@ def dependency(self, otherjob: 'Job'): Set a dependency between this job and otherjob. This means that this job will run after the other job is finished running succesfully. ''' - print(otherjob, otherjob.slurm_job_id, otherjob.can_skip(), otherjob.in_queue()) if otherjob.can_skip() and not otherjob.in_queue(): return diff --git a/src/tcutility/slurm.py b/src/tcutility/slurm.py index 920b904f..9599a250 100644 --- a/src/tcutility/slurm.py +++ b/src/tcutility/slurm.py @@ -102,11 +102,9 @@ def sbatch(runfile: str, **options: dict) -> results.Result: sbatch_out = sp.check_output(cmd.split(), stderr=sp.STDOUT).decode() # get the slurm job id from the output for line in sbatch_out.splitlines(): - print(line) if 'Submitted batch job' in line: # set the slurm job id for this calculation, we use this in order to set dependencies between jobs. ret.id = line.strip().split()[-1] - print(ret.id) break return ret