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