Skip to content

Commit 889e70e

Browse files
committed
Added account job attribute to use for accounting/billing.
Deprecate the `project` attribute and re-direct it to `account`.
1 parent 811e93b commit 889e70e

File tree

17 files changed

+77
-39
lines changed

17 files changed

+77
-39
lines changed

QuickStart.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def make_job():
5858
spec.arguments = ['HELLO WORLD!']
5959

6060
# set project name if no default is specified
61-
# spec.attributes.project_name = <PROJECT_NAME>
61+
# spec.attributes.account = <PROJECT_NAME>
6262

6363
# set queue if no default is specified
6464
# spec.attributes.queue_name = <QUEUE_NAME>

docs/_static/extras.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ function detectAll(selectorType) {
8686
else if (text == "queue_name") {
8787
$(this).text("QUEUE_NAME");
8888
}
89-
else if (text == "project_name") {
90-
$(this).text("PROJECT_NAME");
89+
else if (text == "account") {
90+
$(this).text("ACCOUNT");
9191
}
9292
}
9393
if (text == '_get_executor_instance') {

docs/user_guide.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ and an instance of the
335335
:lines: 10-18,21-22
336336

337337
where `QUEUE_NAME` is the LRM queue where the job should be sent and
338-
`PROJECT_NAME` is a project/account that may need to be specified for
338+
`ACCOUNT` is a project/account that may need to be specified for
339339
accounting purposes. These values generally depend on the system and allocation
340340
being used.
341341

src/psij/executors/batch/cobalt/cobalt.mustache

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@
2525
{{#reservation_id}}
2626
#COBALT --queue={{.}}
2727
{{/reservation_id}}
28-
{{#project_name}}
28+
{{#account}}
2929
#COBALT --project={{.}}
30-
{{/project_name}}
30+
{{/account}}
3131
{{/job.spec.attributes}}
3232

3333
{{#custom_attributes}}

src/psij/executors/batch/lsf/lsf.mustache

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@
4444
#BSUB -q "{{.}}"
4545
{{/queue_name}}
4646

47-
{{#project_name}}
47+
{{#account}}
4848
#BSUB -G "{{.}}"
4949
#BSUB -P "{{.}}"
50-
{{/project_name}}
50+
{{/account}}
5151

5252
{{#reservation_id}}
5353
#BSUB -U "{{.}}"

src/psij/executors/batch/pbs/pbs_classic.mustache

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121
{{/formatted_job_duration}}
2222

2323
{{#job.spec.attributes}}
24-
{{#project_name}}
25-
#PBS -P {{.}}
26-
{{/project_name}}
24+
{{#account}}
25+
#PBS -A {{.}}
26+
{{/account}}
2727
{{#queue_name}}
2828
#PBS -q {{.}}
2929
{{/queue_name}}

src/psij/executors/batch/pbs/pbspro.mustache

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@
2424
{{/formatted_job_duration}}
2525

2626
{{#job.spec.attributes}}
27-
{{#project_name}}
28-
#PBS -P {{.}}
29-
{{/project_name}}
27+
{{#account}}
28+
#PBS -A {{.}}
29+
{{/account}}
3030
{{#queue_name}}
3131
#PBS -q {{.}}
3232
{{/queue_name}}

src/psij/executors/batch/slurm/slurm.mustache

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@
4848
#SBATCH --partition="{{.}}"
4949
{{/queue_name}}
5050

51-
{{#project_name}}
51+
{{#account}}
5252
#SBATCH --account="{{.}}"
53-
{{/project_name}}
53+
{{/account}}
5454

5555
{{#reservation_id}}
5656
#SBATCH --reservation="{{.}}"

src/psij/job_attributes.py

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1+
import logging
12
import re
23
from datetime import timedelta
34
from typing import Optional, Dict
45

56
from typeguard import check_argument_types
67

78

9+
logger = logging.getLogger(__name__)
10+
11+
812
_WALLTIME_FMT_ERROR = 'Unknown walltime format: %s. Accepted formats are hh:mm:ss, ' \
913
'hh:mm, mm, or n\\s*[h|m|s].'
1014

@@ -13,17 +17,19 @@ class JobAttributes(object):
1317
"""A class containing ancillary job information that describes how a job is to be run."""
1418

1519
def __init__(self, duration: timedelta = timedelta(minutes=10),
16-
queue_name: Optional[str] = None, project_name: Optional[str] = None,
20+
queue_name: Optional[str] = None, account: Optional[str] = None,
1721
reservation_id: Optional[str] = None,
18-
custom_attributes: Optional[Dict[str, object]] = None) -> None:
22+
custom_attributes: Optional[Dict[str, object]] = None,
23+
project_name: Optional[str] = None) -> None:
1924
"""
2025
:param duration: Specifies the duration (walltime) of the job. A job whose execution
2126
exceeds its walltime can be terminated forcefully.
2227
:param queue_name: If a backend supports multiple queues, this parameter can be used to
2328
instruct the backend to send this job to a particular queue.
24-
:param project_name: If a backend supports multiple projects for billing purposes, setting
25-
this attribute instructs the backend to bill the indicated project for the resources
26-
consumed by this job.
29+
:param account: An account to use for billing purposes. Please note that the executor
30+
implementation (or batch scheduler) may use a different term for the option used for
31+
accounting/billing purposes, such as `project`. However, scheduler must map this
32+
attribute to the accounting/billing option in the underlying execution mechanism.
2733
:param reservation_id: Allows specifying an advanced reservation ID. Advanced reservations
2834
enable the pre-allocation of a set of resources/compute nodes for a certain duration
2935
such that jobs can be run immediately, without waiting in the queue for resources to
@@ -39,11 +45,13 @@ def __init__(self, duration: timedelta = timedelta(minutes=10),
3945
`pbs.c`, `lsf.core_isolation`) and translate them into the corresponding batch
4046
scheduler directives (e.g., `#SLURM --constraint=...`, `#PBS -c ...`,
4147
`#BSUB -core_isolation ...`).
48+
:param project_name: Deprecated. Please use the `account` attribute.
4249
4350
All constructor parameters are accessible as properties.
4451
"""
4552
assert check_argument_types()
4653

54+
self.account = account
4755
self.duration = duration
4856
self.queue_name = queue_name
4957
self.project_name = project_name
@@ -86,8 +94,8 @@ def custom_attributes(self, attrs: Optional[Dict[str, object]]) -> None:
8694

8795
def __repr__(self) -> str:
8896
"""Returns a string representation of this object."""
89-
return 'JobAttributes(duration={}, queue_name={}, project_name={}, reservation_id={}, ' \
90-
'custom_attributes={})'.format(self.duration, self.queue_name, self.project_name,
97+
return 'JobAttributes(duration={}, queue_name={}, account={}, reservation_id={}, ' \
98+
'custom_attributes={})'.format(self.duration, self.queue_name, self.account,
9199
self.reservation_id, self._custom_attributes)
92100

93101
def __eq__(self, o: object) -> bool:
@@ -99,7 +107,7 @@ def __eq__(self, o: object) -> bool:
99107
if not isinstance(o, JobAttributes):
100108
return False
101109

102-
for prop_name in ['duration', 'queue_name', 'project_name', 'reservation_id',
110+
for prop_name in ['duration', 'queue_name', 'account', 'reservation_id',
103111
'custom_attributes']:
104112
if getattr(self, prop_name) != getattr(o, prop_name):
105113
return False
@@ -150,3 +158,14 @@ def parse_walltime(walltime: str) -> timedelta:
150158
elif unit == 's':
151159
return timedelta(seconds=val)
152160
raise ValueError(_WALLTIME_FMT_ERROR % walltime)
161+
162+
@property
163+
def project_name(self) -> Optional[str]:
164+
"""Deprecated. Please use the `account` attribute."""
165+
return self.account
166+
167+
@project_name.setter
168+
def project_name(self, project_name: Optional[str]) -> None:
169+
logger.warning('The "project_name" attribute is deprecated. Please use the "account" '
170+
'attribute instead.')
171+
self.account = project_name

testing.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ queue_name =
119119
# If you need a project/account for billing purposes, enter it here.
120120
#
121121

122-
project_name =
122+
account =
123123

124124

125125

0 commit comments

Comments
 (0)