Skip to content

Commit

Permalink
Opts --job cannot be used together with --name/--max-fails
Browse files Browse the repository at this point in the history
  • Loading branch information
spirali authored and Kobzol committed Aug 23, 2024
1 parent ffe4be7 commit f810c75
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 7 deletions.
14 changes: 11 additions & 3 deletions crates/hyperqueue/src/client/commands/submit/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -583,11 +583,19 @@ pub async fn submit_computation(
None
};

if opts.opts.directives == DirectivesMode::Stdin && stdin.is_none() {
let opts = handle_directives(opts, stdin.as_deref())?;

if opts.directives == DirectivesMode::Stdin && stdin.is_none() {
bail!("You have to use `--stdin` when you specify `--directives=stdin`.");
}

let opts = handle_directives(opts, stdin.as_deref())?;
if opts.job.is_some() {
if opts.conf.job_conf.name.is_some() {
bail!("Parameter --name is not allowed when submitting to an open job.");
}
if opts.conf.job_conf.max_fails.is_some() {
bail!("Parameter --max-fails is not allowed when submitting to an open job.");
}
}

let resources = opts.resource_request()?;
let (ids, entries) = get_ids_and_entries(&opts)?;
Expand Down
5 changes: 3 additions & 2 deletions docs/jobs/openjobs.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,14 @@ $ hq submit --job <JOB_ID> --array 0-12 -- hostname
## Job name and `--max-fails`

Job's name and configuration open `--max-fails` are the property of the job. They can be set when job is opened and they
cannot be later changed. Submits options `--name` and `--max-fails` are ignored if you are submitting into an open job.
cannot be later changed. Submits options `--name` and `--max-fails` cannot be used if you are submitting into an open
job.

```commandline
# Configuring jobs's name and max fails
$ hq job open --name=MyOpenJob --max-fails=10
# Option --max-fails is ignored here
# Submit fails becase --max-fails cannot be used together with --job
$ hq submit --job <JOB_ID> --max-fails=5 ...
```

Expand Down
14 changes: 12 additions & 2 deletions tests/test_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -893,8 +893,8 @@ def test_job_submit_program_not_found(hq_env: HqEnv):

table = hq_env.command(["task", "list", "1", "-v"], as_table=True)
assert (
'Error: Cannot execute "foo --bar --baz=5": No such file or directory (os error 2)\n'
"The program that you have tried to execute (`foo`) was not found." == table.get_column_value("Error")[0]
'Error: Cannot execute "foo --bar --baz=5": No such file or directory (os error 2)\n'
"The program that you have tried to execute (`foo`) was not found." == table.get_column_value("Error")[0]
)


Expand Down Expand Up @@ -1291,6 +1291,16 @@ def test_job_wait_for_close(hq_env: HqEnv):
assert r == 0


def test_submit_job_opts_to_open_job(hq_env: HqEnv):
hq_env.start_server()
hq_env.command(["job", "open"])

hq_env.command(["submit", "--job=1", "--name=Abc", "--", "hostname"],
expect_fail="Parameter --name is not allowed when submitting to an open job.")
hq_env.command(["submit", "--job=1", "--max-fails=12", "--", "hostname"],
expect_fail="Parameter --max-fails is not allowed when submitting to an open job.")


def test_job_wait_for_open_job_without_close(hq_env: HqEnv):
hq_env.start_server()
hq_env.command(["job", "open"])
Expand Down

0 comments on commit f810c75

Please sign in to comment.