1+ import logging
12import re
23from datetime import timedelta
34from typing import Optional , Dict
45
56from 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
0 commit comments