Skip to content

Commit

Permalink
SGE updates
Browse files Browse the repository at this point in the history
  • Loading branch information
mike-jt79 committed Oct 15, 2021
1 parent 406b2a6 commit 3b4d171
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions mycluster/schedulers/sge.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ def create_submit(
tasks_per_node, self._min_tasks_per_node(queue_id)
)

template = load_template("sge.jinja")
template = self._load_template("sge.jinja")

script_str = template.render(
my_name=job_name,
Expand All @@ -312,13 +312,25 @@ def submit(
self, script_name, immediate=False, depends_on=None, depends_on_always_run=False
):
job_id = None
with os.popen("qsub -V -terse " + script_name) as f:

output = subprocess.run(
f"qsub -V -terse {script_name}",
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
shell=True,
)
if output.returncode == 0:
job_id = 0
out = output.stdout.decode("utf-8")
try:
job_id = int(f.readline().strip())
job_id = int(out.readline().strip())
return job_id
except:
raise SchedulerException("Error submitting job to SGE")
return job_id
else:
raise SchedulerException(
f"Error submitting job to SGE: {output.stderr.decode('utf-8')}"
)

def list_current_jobs(self):
jobs = []
Expand All @@ -330,6 +342,8 @@ def list_current_jobs(self):
)
if output.returncode == 0:
for line in output.stdout.decode("utf-8").splitlines():
if line.startswith("job-ID") or line.startswith("---"):
continue
job_info = re.sub(" +", " ", line.strip()).split(" ")
jobs.append(
{
Expand Down

0 comments on commit 3b4d171

Please sign in to comment.