From f810c7558fe88c037a40a41c296961b164c5aa0b Mon Sep 17 00:00:00 2001 From: Ada Bohm Date: Mon, 19 Aug 2024 19:36:52 +0200 Subject: [PATCH] Opts --job cannot be used together with --name/--max-fails --- .../src/client/commands/submit/command.rs | 14 +++++++++++--- docs/jobs/openjobs.md | 5 +++-- tests/test_job.py | 14 ++++++++++++-- 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/crates/hyperqueue/src/client/commands/submit/command.rs b/crates/hyperqueue/src/client/commands/submit/command.rs index 64c1bddd8..3747d1870 100644 --- a/crates/hyperqueue/src/client/commands/submit/command.rs +++ b/crates/hyperqueue/src/client/commands/submit/command.rs @@ -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)?; diff --git a/docs/jobs/openjobs.md b/docs/jobs/openjobs.md index c276cc509..c791d50c3 100644 --- a/docs/jobs/openjobs.md +++ b/docs/jobs/openjobs.md @@ -68,13 +68,14 @@ $ hq submit --job --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 --max-fails=5 ... ``` diff --git a/tests/test_job.py b/tests/test_job.py index 8cccc6ee4..220ed2ff9 100644 --- a/tests/test_job.py +++ b/tests/test_job.py @@ -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] ) @@ -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"])