Skip to content

Commit

Permalink
Merge pull request #86 from saltball/for_pbs_torque
Browse files Browse the repository at this point in the history
Add `Torque` support.
  • Loading branch information
felix5572 committed Jul 5, 2021
2 parents f200f98 + 8c4fa05 commit 87e3ee8
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 2 deletions.
2 changes: 1 addition & 1 deletion doc/machine-auto.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ machine:
| type: ``str``
| argument path: ``machine/batch_type``
The batch job system type. Option: Slurm, PBS, LSF, Shell, DpCloudServer
The batch job system type. Option: Slurm, PBS (for OpenPBS only), Torque (for Torque version of pbs), LSF, Shell, DpCloudServer

context_type:
| type: ``str``
Expand Down
1 change: 1 addition & 0 deletions dpdispatcher/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
from .submission import Resources
from .slurm import Slurm
from .pbs import PBS
from .pbs import Torque
from .shell import Shell
from .lsf import LSF
from .dp_cloud_server import DpCloudServer
Expand Down
33 changes: 32 additions & 1 deletion dpdispatcher/pbs.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,35 @@ def check_finish_tag(self, job):
return self.context.check_file_exists(job_tag_finished)



class Torque(PBS):
def check_status(self, job):
job_id = job.job_id
if job_id == "" :
return JobStatus.unsubmitted
ret, stdin, stdout, stderr\
= self.context.block_call ("qstat -l " + job_id)
err_str = stderr.read().decode('utf-8')
if (ret != 0) :
if str("qstat: Unknown Job Id") in err_str or str("Job has finished") in err_str:
if self.check_finish_tag(job=job) :
return JobStatus.finished
else :
return JobStatus.terminated
else :
raise RuntimeError ("status command qstat fails to execute. erro info: %s return code %d"
% (err_str, ret))
status_line = stdout.read().decode('utf-8').split ('\n')[-2]
status_word = status_line.split ()[-2]
# dlog.info (status_word)
if status_word in ["Q","H"] :
return JobStatus.waiting
elif status_word in ["R"] :
return JobStatus.running
elif status_word in ["C", "E", "K", "F"] :
if self.check_finish_tag(job):
dlog.info(f"job: {job.job_hash} {job.job_id} finished")
return JobStatus.finished
else :
return JobStatus.terminated
else :
return JobStatus.unknown

0 comments on commit 87e3ee8

Please sign in to comment.