Skip to content

Commit

Permalink
Merge pull request #6557 from cylc/8.4.x-sync
Browse files Browse the repository at this point in the history
🤖 Merge 8.4.x-sync into master
  • Loading branch information
wxtim authored Jan 15, 2025
2 parents 931092b + 0d204cc commit bbe7599
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
1 change: 1 addition & 0 deletions changes.d/6551.fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix bug in `cylc lint` S014 where it warned about use of legitimate `-W` directive for PBS.
25 changes: 20 additions & 5 deletions cylc/flow/scripts/lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,15 +189,20 @@ def get_wallclock_directives():
'TIME_LIMIT_DIRECTIVE',
None
)
if directive:
directives[module.name] = directive
if directive and directive == '-W':
# LSF directive -W needs to have a particular form to
# avoid matching PBS directive -W:
directives[module.name] = re.compile(
r'^-W\s*=?\s*(\d+:)?\d+[^/]*$')
elif directive:
directives[module.name] = re.compile(rf'^{directive}.*')
return directives


WALLCLOCK_DIRECTIVES = get_wallclock_directives()


def check_wallclock_directives(line: str) -> Union[Dict[str, str], bool]:
def check_wallclock_directives(line: str) -> Dict[str, str]:
"""Check for job runner specific directives
equivalent to exection time limit.
Expand All @@ -209,11 +214,21 @@ def check_wallclock_directives(line: str) -> Union[Dict[str, str], bool]:
>>> this = check_wallclock_directives
>>> this(' -W 42:22')
{'directive': '-W 42:22'}
>>> this(' -W 42:22/hostname') # Legit LSF use case
{}
>>> this(' -W 422')
{'directive': '-W 422'}
>>> this(' -W foo=42') # Legit PBS use case.
{}
>>> this(' -W foo="Hello World"') # Legit PBS use case.
{}
>>> this(' -l walltime whatever')
{'directive': '-l walltime whatever'}
"""
for directive in set(WALLCLOCK_DIRECTIVES.values()):
if line.strip().startswith(directive):
if directive.findall(line.strip()):
return {'directive': line.strip()}
return False
return {}


def check_jinja2_no_shebang(
Expand Down

0 comments on commit bbe7599

Please sign in to comment.