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

Open jobs #740

Merged
merged 10 commits into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
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
spirali marked this conversation as resolved.
Show resolved Hide resolved
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 ...
spirali marked this conversation as resolved.
Show resolved Hide resolved
```

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
Loading