Skip to content

Commit 408e788

Browse files
committed
pbs: honour walltime and account target options
PBS backend silently dropped walltime and account from TARGET_DEFAULTS, making long jobs hit cluster default walltimes and ignoring accounting on sites that require -A. - walltime: added to TARGET_DEFAULTS (default 01:00:00) and emitted as #PBS -l walltime={walltime}. - account: added to TARGET_DEFAULTS (default "") with conditional emission - the #PBS -A line is omitted when empty so sites that don't use accounting are unaffected.
1 parent 2d6ec82 commit 408e788

1 file changed

Lines changed: 19 additions & 1 deletion

File tree

src/gwf/backends/pbs.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,14 @@
1414
Number of cores allocated to this target (default: 1).
1515
* **memory (str):**
1616
Memory allocated to this target (default: 4GB).
17+
* **walltime (str):**
18+
Wall-clock time limit, ``HH:MM:SS`` (default: ``01:00:00``). Emitted as
19+
``#PBS -l walltime=...``.
1720
* **queue (str):**
1821
Queue to submit the target to (default: normal).
22+
* **account (str):**
23+
Accounting/group string for the job (default: unset). When set, emitted
24+
as ``#PBS -A <account>``; when empty the directive is omitted entirely.
1925
2026
"""
2127

@@ -32,10 +38,17 @@
3238

3339
logger = logging.getLogger(__name__)
3440

35-
TARGET_DEFAULTS = {"queue": "normal", "memory": "4GB", "cores": 1}
41+
TARGET_DEFAULTS = {
42+
"queue": "normal",
43+
"memory": "4GB",
44+
"cores": 1,
45+
"walltime": "01:00:00",
46+
"account": "",
47+
}
3648

3749
PBS_HEADER = """#PBS -l mem={memory}
3850
#PBS -l nodes=1:ppn={cores}
51+
#PBS -l walltime={walltime}
3952
#PBS -q {queue}
4053
#PBS -o {std_out}
4154
#PBS -e {std_err}
@@ -100,6 +113,11 @@ def compile_script(self, target):
100113
for name, value in target_options.items():
101114
header = header.replace(f"{{{name}}}", str(value))
102115
header = header.replace("{job_name}", target.name)
116+
# Optional accounting directive. PBS rejects an empty argument to -A,
117+
# so the line is appended only when an account is actually configured.
118+
account = str(target_options.get("account", "")).strip()
119+
if account:
120+
header += f"\n#PBS -A {account}"
103121
out = []
104122
out.append("#!/bin/bash")
105123
out.append(header)

0 commit comments

Comments
 (0)