Skip to content

Commit

Permalink
Merge branch 'main' into unkcpz-patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
unkcpz authored Jul 22, 2024
2 parents fa1203f + 40ac153 commit c6de03f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
10 changes: 6 additions & 4 deletions aiida_hyperqueue/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def _get_submit_command(self, submit_script: str) -> str:
submit_script: the path of the submit script relative to the working
directory.
"""
submit_command = f"hq submit {submit_script} --output-mode=json"
submit_command = f"hq submit --output-mode=json {submit_script}"

self.logger.info(f"Submitting with: {submit_command}")

Expand Down Expand Up @@ -178,10 +178,10 @@ def _parse_submit_output(self, retval: int, stdout: str, stderr: str) -> str:
f"in _parse_submit_output{transport_string}: there was some text in stderr: {stderr}"
)

hq_job_dict = json.loads(stdout)
try:
hq_job_dict = json.loads(stdout)
return str(hq_job_dict["id"])
except KeyError:
except Exception:
# If no valid line is found, log and raise an error
self.logger.error(
f"in _parse_submit_output{transport_string}: unable to find the job id: {stdout}"
Expand Down Expand Up @@ -228,7 +228,9 @@ def _parse_joblist_output(self, retval: int, stdout: str, stderr: str) -> list:
job_info_list = []
for hq_job_dict in hq_job_info_list:
job_info = JobInfo()
job_info.job_id = hq_job_dict["id"]
job_info.job_id = str(
hq_job_dict["id"]
) # must be str, if it is a int job will not waiting
job_info.title = hq_job_dict["name"]
stats: t.List[str] = [
stat for stat, v in hq_job_dict["task_stats"].items() if v > 0
Expand Down
9 changes: 7 additions & 2 deletions tests/test_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ def test_submit_command():
"""Test submit command"""
scheduler = HyperQueueScheduler()

assert "hq submit job.sh" in scheduler._get_submit_command("job.sh")
assert "hq submit --output-mode=json job.sh" == scheduler._get_submit_command(
"job.sh"
)


def test_parse_submit_command_output(hq_env: HqEnv, valid_submit_script):
Expand All @@ -78,8 +80,11 @@ def test_parse_submit_command_output(hq_env: HqEnv, valid_submit_script):
hq_env.start_worker(cpus="1")
Path("_aiidasubmit.sh").write_text(valid_submit_script)

scheduler = HyperQueueScheduler()
args = scheduler._get_submit_command("_aiidasubmit.sh")
args = args.split(" ")[1:]
process = hq_env.command(
["submit", "--output-mode=json", "_aiidasubmit.sh"],
args,
wait=False,
ignore_stderr=True,
)
Expand Down

0 comments on commit c6de03f

Please sign in to comment.