Skip to content

Commit ea95e4a

Browse files
committed
merge from main
2 parents 9fc83ba + 672ebb5 commit ea95e4a

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 typechecked
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

@@ -14,17 +18,19 @@ class JobAttributes(object):
1418

1519
@typechecked
1620
def __init__(self, duration: timedelta = timedelta(minutes=10),
17-
queue_name: Optional[str] = None, project_name: Optional[str] = None,
21+
queue_name: Optional[str] = None, account: Optional[str] = None,
1822
reservation_id: Optional[str] = None,
19-
custom_attributes: Optional[Dict[str, object]] = None) -> None:
23+
custom_attributes: Optional[Dict[str, object]] = None,
24+
project_name: Optional[str] = None) -> None:
2025
"""
2126
:param duration: Specifies the duration (walltime) of the job. A job whose execution
2227
exceeds its walltime can be terminated forcefully.
2328
:param queue_name: If a backend supports multiple queues, this parameter can be used to
2429
instruct the backend to send this job to a particular queue.
25-
:param project_name: If a backend supports multiple projects for billing purposes, setting
26-
this attribute instructs the backend to bill the indicated project for the resources
27-
consumed by this job.
30+
:param account: An account to use for billing purposes. Please note that the executor
31+
implementation (or batch scheduler) may use a different term for the option used for
32+
accounting/billing purposes, such as `project`. However, scheduler must map this
33+
attribute to the accounting/billing option in the underlying execution mechanism.
2834
:param reservation_id: Allows specifying an advanced reservation ID. Advanced reservations
2935
enable the pre-allocation of a set of resources/compute nodes for a certain duration
3036
such that jobs can be run immediately, without waiting in the queue for resources to
@@ -40,9 +46,11 @@ def __init__(self, duration: timedelta = timedelta(minutes=10),
4046
`pbs.c`, `lsf.core_isolation`) and translate them into the corresponding batch
4147
scheduler directives (e.g., `#SLURM --constraint=...`, `#PBS -c ...`,
4248
`#BSUB -core_isolation ...`).
49+
:param project_name: Deprecated. Please use the `account` attribute.
4350
4451
All constructor parameters are accessible as properties.
4552
"""
53+
self.account = account
4654
self.duration = duration
4755
self.queue_name = queue_name
4856
self.project_name = project_name
@@ -85,8 +93,8 @@ def custom_attributes(self, attrs: Optional[Dict[str, object]]) -> None:
8593

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

92100
def __eq__(self, o: object) -> bool:
@@ -98,7 +106,7 @@ def __eq__(self, o: object) -> bool:
98106
if not isinstance(o, JobAttributes):
99107
return False
100108

101-
for prop_name in ['duration', 'queue_name', 'project_name', 'reservation_id',
109+
for prop_name in ['duration', 'queue_name', 'account', 'reservation_id',
102110
'custom_attributes']:
103111
if getattr(self, prop_name) != getattr(o, prop_name):
104112
return False
@@ -149,3 +157,14 @@ def parse_walltime(walltime: str) -> timedelta:
149157
elif unit == 's':
150158
return timedelta(seconds=val)
151159
raise ValueError(_WALLTIME_FMT_ERROR % walltime)
160+
161+
@property
162+
def project_name(self) -> Optional[str]:
163+
"""Deprecated. Please use the `account` attribute."""
164+
return self.account
165+
166+
@project_name.setter
167+
def project_name(self, project_name: Optional[str]) -> None:
168+
logger.warning('The "project_name" attribute is deprecated. Please use the "account" '
169+
'attribute instead.')
170+
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)