Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lint S014: Only warn about -W when used for LSF #6551

Merged
merged 6 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changes.d/6551.fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Lint: Fix bug where lint warned about use of legitimate -W directive for PBS.
wxtim marked this conversation as resolved.
Show resolved Hide resolved
18 changes: 15 additions & 3 deletions cylc/flow/scripts/lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,12 @@ 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+(\d+:)?\d+$')
wxtim marked this conversation as resolved.
Show resolved Hide resolved
wxtim marked this conversation as resolved.
Show resolved Hide resolved
elif directive:
directives[module.name] = re.compile(rf'^{directive}')
return directives


Expand All @@ -209,9 +213,17 @@ 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
oliver-sanders marked this conversation as resolved.
Show resolved Hide resolved
False
>>> this(' -W 422')
{'directive': '-W 422'}
>>> this(' -W foo=42') # Legit PBS use case.
False
>>> this(' -W foo="Hello World"') # Legit PBS use case.
False
"""
for directive in set(WALLCLOCK_DIRECTIVES.values()):
if line.strip().startswith(directive):
if directive.findall(line.strip()):
return {'directive': line.strip()}
return False

Expand Down
Loading