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

Unit test PBS directives formatter #3356

Merged
merged 1 commit into from
Sep 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 5 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,11 @@ Changed the `suite.rc` schema:
restarts, and reloads). Impact of the speedup is most noticeable when dealing
with suite configurations that contain tasks with many task outputs.

[#3356](https://github.com/cylc/cylc-flow/pull/3356) - default job name length
maximum for PBS is now 236 characters (i.e. assuming PBS 13 or newer). If you
are still using PBS 12 or older, you should add a site configuration to
restrict it to 15 characters.

### Fixes

[#3308](https://github.com/cylc/cylc-flow/pull/3308) - fix a long-standing bug
Expand Down
6 changes: 3 additions & 3 deletions cylc/flow/batch_sys_handlers/pbs.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ class PBSHandler(object):
# [[the-name-of-my-pbs-host]]
# [[[batch systems]]]
# [[[[pbs]]]]
# # E.g.: PBS 13
# job name length maximum = 236
JOB_NAME_LEN_MAX = 15
# # E.g.: PBS 11
# job name length maximum = 15
JOB_NAME_LEN_MAX = 236
KILL_CMD_TMPL = "qdel '%(job_id)s'"
# N.B. The "qstat JOB_ID" command returns 1 if JOB_ID is no longer in the
# system, so there is no need to filter its output.
Expand Down
85 changes: 85 additions & 0 deletions cylc/flow/tests/batch_sys_handlers/test_pbs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
#!/usr/bin/env python3

# THIS FILE IS PART OF THE CYLC SUITE ENGINE.
# Copyright (C) 2008-2019 NIWA & British Crown (Met Office) & Contributors.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

import pytest

from cylc.flow.batch_sys_handlers.pbs import BATCH_SYS_HANDLER


@pytest.mark.parametrize(
'job_conf,lines',
[
( # basic
{
'batch_system_conf': {},
'directives': {},
'execution_time_limit': 180,
'job_file_path': '$HOME/cylc-run/chop/log/job/1/axe/01/job',
'suite_name': 'chop',
'task_id': 'axe.1',
},
[
'#PBS -N axe.1.chop',
'#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',
],
),
( # super short job name length maximum
{
'batch_system_conf': {'job name length maximum': 6},
'directives': {},
'execution_time_limit': 180,
'job_file_path': '$HOME/cylc-run/chop/log/job/1/axe/01/job',
'suite_name': 'chop',
'task_id': 'axe.1',
},
[
'#PBS -N axe.1.',
'#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',
],
),
( # some useful directives
{
'batch_system_conf': {},
'directives': {
'-q': 'forever',
'-V': '',
'-l mem': '256gb',
},
'execution_time_limit': 180,
'job_file_path': '$HOME/cylc-run/chop/log/job/1/axe/01/job',
'suite_name': 'chop',
'task_id': 'axe.1',
},
[
'#PBS -N axe.1.chop',
'#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',
'#PBS -q forever',
'#PBS -V',
'#PBS -l mem=256gb',
],
),
],
)
def test_format_directives(job_conf: dict, lines: list):
assert BATCH_SYS_HANDLER.format_directives(job_conf) == lines