From 6330a4e68e1d4c181af9b6aaa16eb710bfe6e7e6 Mon Sep 17 00:00:00 2001 From: Abdur Rahman Hatim <45071819+hat-im@users.noreply.github.com> Date: Mon, 16 Nov 2026 23:42:54 +0530 Subject: [PATCH] Batch templates take the job name from the job's spec The slurm, pbs, pbs_classic, lsf and cobalt templates read job.name, but Job has no name attribute (JobSpec does), so no job name ever reached the scheduler. Read job.spec.name, as the nqsv template already does. test_submit_script_generation now checks the name, and the batch-test template emits it. --- src/psij/executors/batch/cobalt/cobalt.mustache | 4 ++-- src/psij/executors/batch/lsf/lsf.mustache | 4 ++-- src/psij/executors/batch/pbs/pbs_classic.mustache | 4 ++-- src/psij/executors/batch/pbs/pbspro.mustache | 4 ++-- src/psij/executors/batch/slurm/slurm.mustache | 4 ++-- tests/plugins1/_batch_test/test/test.mustache | 4 ++++ tests/test_executor.py | 2 +- 7 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/psij/executors/batch/cobalt/cobalt.mustache b/src/psij/executors/batch/cobalt/cobalt.mustache index 444de0aed..20ef241f6 100644 --- a/src/psij/executors/batch/cobalt/cobalt.mustache +++ b/src/psij/executors/batch/cobalt/cobalt.mustache @@ -1,7 +1,7 @@ #!/bin/bash -{{#job.name}} +{{#job.spec.name}} #COBALT --jobname={{.}} -{{/job.name}} +{{/job.spec.name}} {{#job.spec.directory}} #COBALT --cwd={{.}} {{/job.spec.directory}} diff --git a/src/psij/executors/batch/lsf/lsf.mustache b/src/psij/executors/batch/lsf/lsf.mustache index 19c4cb804..71957268b 100644 --- a/src/psij/executors/batch/lsf/lsf.mustache +++ b/src/psij/executors/batch/lsf/lsf.mustache @@ -1,8 +1,8 @@ #!/bin/bash -{{#job.name}} +{{#job.spec.name}} #BSUB -J "{{.}}" -{{/job.name}} +{{/job.spec.name}} {{#job.spec.directory}} #BSUB -cwd "{{.}}" diff --git a/src/psij/executors/batch/pbs/pbs_classic.mustache b/src/psij/executors/batch/pbs/pbs_classic.mustache index a987dfb21..15466969f 100644 --- a/src/psij/executors/batch/pbs/pbs_classic.mustache +++ b/src/psij/executors/batch/pbs/pbs_classic.mustache @@ -1,9 +1,9 @@ #!/bin/bash -{{#job.name}} +{{#job.spec.name}} #PBS -N="{{.}}" -{{/job.name}} +{{/job.spec.name}} {{#job.spec.inherit_environment}} #PBS -V diff --git a/src/psij/executors/batch/pbs/pbspro.mustache b/src/psij/executors/batch/pbs/pbspro.mustache index a70b2b705..399cd3959 100644 --- a/src/psij/executors/batch/pbs/pbspro.mustache +++ b/src/psij/executors/batch/pbs/pbspro.mustache @@ -1,9 +1,9 @@ #!/bin/bash -{{#job.name}} +{{#job.spec.name}} #PBS -N="{{.}}" -{{/job.name}} +{{/job.spec.name}} {{#job.spec.inherit_environment}} #PBS -V diff --git a/src/psij/executors/batch/slurm/slurm.mustache b/src/psij/executors/batch/slurm/slurm.mustache index 8d943d406..b6c7ee9eb 100644 --- a/src/psij/executors/batch/slurm/slurm.mustache +++ b/src/psij/executors/batch/slurm/slurm.mustache @@ -1,9 +1,9 @@ #!/bin/bash -{{#job.name}} +{{#job.spec.name}} #SBATCH --job-name="{{.}}" -{{/job.name}} +{{/job.spec.name}} {{#job.spec.directory}} #SBATCH --chdir="{{.}}" diff --git a/tests/plugins1/_batch_test/test/test.mustache b/tests/plugins1/_batch_test/test/test.mustache index 5fc00bfe0..8c9633396 100644 --- a/tests/plugins1/_batch_test/test/test.mustache +++ b/tests/plugins1/_batch_test/test/test.mustache @@ -4,6 +4,10 @@ exec &> "{{psij.script_dir}}/$PSIJ_BATCH_TEST_JOB_ID.out" {{> batch_lib}} +{{#job.spec.name}} +# job name: {{.}} +{{/job.spec.name}} + {{#job.spec.directory}} cd "{{.}}" {{/job.spec.directory}} diff --git a/tests/test_executor.py b/tests/test_executor.py index 83090ecc0..04cddd484 100644 --- a/tests/test_executor.py +++ b/tests/test_executor.py @@ -236,7 +236,7 @@ def test_submit_script_generation(exec_name: str) -> None: job = Job(spec=spec) prefix = _get_attr_prefix(exec_name) - _check_str_attrs(ex, job, ['executable', 'directory'], + _check_str_attrs(ex, job, ['executable', 'directory', 'name'], lambda k, v: setattr(spec, k, v)) _check_str_attrs(ex, job, ['queue_name', 'account', 'reservation_id'], lambda k, v: setattr(attrs, k, v))