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

Place the --output-mode in front of job scritp #28

Merged
merged 2 commits into from
Jul 19, 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
6 changes: 3 additions & 3 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
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
Loading