Skip to content

Commit

Permalink
Restore default for PBS max job name len. (#5386)
Browse files Browse the repository at this point in the history
Restore default for PBS max job name len.

Co-authored-by: Oliver Sanders <oliver.sanders@metoffice.gov.uk>
Co-authored-by: Ronnie Dutta <61982285+MetRonnie@users.noreply.github.com>
  • Loading branch information
3 people authored Mar 8, 2023
1 parent 6b3b56b commit a92efae
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ ones in. -->
[#5384](https://github.com/cylc/cylc-flow/pull/5384) -
Fixes `cylc set-verbosity`.

[#5386](https://github.com/cylc/cylc-flow/pull/5386) Fix bug where
absence of `job name length maximum` in PBS platform settings would cause
Cylc to crash when preparing the job script.

-------------------------------------------------------------------------------
## __cylc-8.1.2 (<span actions:bind='release-date'>Released 2023-02-20</span>)__

Expand Down
5 changes: 4 additions & 1 deletion cylc/flow/job_runner_handlers/pbs.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,10 @@ def format_directives(self, job_conf):
f'{tokens["task"]}.{tokens["cycle"]}'
f".{job_conf['workflow_name'].replace('/', '-')}"
)
job_name_len_max = job_conf['platform']["job name length maximum"]
job_name_len_max = job_conf['platform'].get(
"job name length maximum",
self.JOB_NAME_LEN_MAX
)
if job_name_len_max:
directives["-N"] = directives["-N"][0:job_name_len_max]

Expand Down
36 changes: 32 additions & 4 deletions tests/unit/job_runner_handlers/test_pbs.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,19 @@

import pytest

from cylc.flow.job_runner_handlers.pbs import JOB_RUNNER_HANDLER
from cylc.flow.job_runner_handlers.pbs import (
JOB_RUNNER_HANDLER,
PBSHandler
)


VERY_LONG_STR = 'x' * 240


@pytest.mark.parametrize(
'job_conf,lines',
[
( # basic
pytest.param(
{
'directives': {},
'execution_time_limit': 180,
Expand All @@ -40,8 +46,28 @@
'#PBS -e cylc-run/chop/log/job/1/axe/01/job.err',
'#PBS -l walltime=180',
],
id='basic'
),
pytest.param(
{
'directives': {},
'execution_time_limit': 180,
'job_file_path': 'cylc-run/chop/log/job/1/axe/01/job',
'workflow_name': 'chop',
'task_id': VERY_LONG_STR,
'platform': {
'job runner': 'pbs',
}
},
[
f'#PBS -N None.{VERY_LONG_STR[:PBSHandler.JOB_NAME_LEN_MAX - 5]}',
'#PBS -o cylc-run/chop/log/job/1/axe/01/job.out',
'#PBS -e cylc-run/chop/log/job/1/axe/01/job.err',
'#PBS -l walltime=180',
],
id='long-job-name'
),
( # super short job name length maximum
pytest.param(
{
'directives': {},
'execution_time_limit': 180,
Expand All @@ -59,8 +85,9 @@
'#PBS -e cylc-run/chop/log/job/1/axe/01/job.err',
'#PBS -l walltime=180',
],
id='truncate-job-name'
),
( # some useful directives
pytest.param(
{
'directives': {
'-q': 'forever',
Expand All @@ -85,6 +112,7 @@
'#PBS -V',
'#PBS -l mem=256gb',
],
id='custom-directives'
),
],
)
Expand Down

0 comments on commit a92efae

Please sign in to comment.