Skip to content

Commit

Permalink
Restore default for PBS max job name len.
Browse files Browse the repository at this point in the history
This needs to be used if it is not set in the site config and
was mistakenly removed.
  • Loading branch information
wxtim committed Mar 1, 2023
1 parent e0fb484 commit 7b300b4
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 4 deletions.
5 changes: 5 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ ones in. -->

### Fixes


[#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.

[#5349](https://github.com/cylc/cylc-flow/pull/5349) - Bugfix: `cylc vip --workflow-name`
only worked when used with a space, not an `=`.

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
31 changes: 28 additions & 3 deletions tests/unit/job_runner_handlers/test_pbs.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,13 @@
from cylc.flow.job_runner_handlers.pbs import JOB_RUNNER_HANDLER


VERY_LONG_STR = 'x'.join(['' for i in range(240)])


@pytest.mark.parametrize(
'job_conf,lines',
[
( # basic
pytest.param(
{
'directives': {},
'execution_time_limit': 180,
Expand All @@ -40,8 +43,28 @@
'#PBS -e cylc-run/chop/log/job/1/axe/01/job.err',
'#PBS -l walltime=180',
],
id='it sets basic directives'
),
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[:231]}',
'#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='it handles job name len max unset in config'
),
( # super short job name length maximum
pytest.param(
{
'directives': {},
'execution_time_limit': 180,
Expand All @@ -59,8 +82,9 @@
'#PBS -e cylc-run/chop/log/job/1/axe/01/job.err',
'#PBS -l walltime=180',
],
id='it truncates a long job name'
),
( # some useful directives
pytest.param(
{
'directives': {
'-q': 'forever',
Expand All @@ -85,6 +109,7 @@
'#PBS -V',
'#PBS -l mem=256gb',
],
id='it adds custom directives'
),
],
)
Expand Down

0 comments on commit 7b300b4

Please sign in to comment.