@@ -189,15 +189,20 @@ def get_wallclock_directives():
189
189
'TIME_LIMIT_DIRECTIVE' ,
190
190
None
191
191
)
192
- if directive :
193
- directives [module .name ] = directive
192
+ if directive and directive == '-W' :
193
+ # LSF directive -W needs to have a particular form to
194
+ # avoid matching PBS directive -W:
195
+ directives [module .name ] = re .compile (
196
+ r'^-W\s*=?\s*(\d+:)?\d+[^/]*$' )
197
+ elif directive :
198
+ directives [module .name ] = re .compile (rf'^{ directive } .*' )
194
199
return directives
195
200
196
201
197
202
WALLCLOCK_DIRECTIVES = get_wallclock_directives ()
198
203
199
204
200
- def check_wallclock_directives (line : str ) -> Union [ Dict [str , str ], bool ]:
205
+ def check_wallclock_directives (line : str ) -> Dict [str , str ]:
201
206
"""Check for job runner specific directives
202
207
equivalent to exection time limit.
203
208
@@ -209,11 +214,21 @@ def check_wallclock_directives(line: str) -> Union[Dict[str, str], bool]:
209
214
>>> this = check_wallclock_directives
210
215
>>> this(' -W 42:22')
211
216
{'directive': '-W 42:22'}
217
+ >>> this(' -W 42:22/hostname') # Legit LSF use case
218
+ {}
219
+ >>> this(' -W 422')
220
+ {'directive': '-W 422'}
221
+ >>> this(' -W foo=42') # Legit PBS use case.
222
+ {}
223
+ >>> this(' -W foo="Hello World"') # Legit PBS use case.
224
+ {}
225
+ >>> this(' -l walltime whatever')
226
+ {'directive': '-l walltime whatever'}
212
227
"""
213
228
for directive in set (WALLCLOCK_DIRECTIVES .values ()):
214
- if line .strip (). startswith ( directive ):
229
+ if directive . findall ( line .strip ()):
215
230
return {'directive' : line .strip ()}
216
- return False
231
+ return {}
217
232
218
233
219
234
def check_jinja2_no_shebang (
0 commit comments