Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed an issue where dependencies were not being set #238

Merged
merged 5 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/tcutility/job/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,14 @@ def can_skip(self):
res = results.read(self.workdir)
return not res.status.fatal

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})'

Expand Down Expand Up @@ -224,7 +232,7 @@ 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:
if otherjob.can_skip() and not otherjob.in_queue():
return

if hasattr(otherjob, 'slurm_job_id'):
Expand Down
2 changes: 1 addition & 1 deletion src/tcutility/slurm.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ 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'):
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
Expand Down
Loading