Skip to content

Commit

Permalink
[batch] Ignore empty command strings when constructing shell scripts
Browse files Browse the repository at this point in the history
Using job.command('') (or more likely something more complex
that sometimes evaluates to an empty string) led to shell snippets
containing `... { } ...`, which is a shell syntax error. Prevent
this by not adding such strings to self._command and warning.
  • Loading branch information
jmarshall committed Sep 30, 2024
1 parent 13a9aee commit 747b87d
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions hail/python/hailtop/batch/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -859,6 +859,11 @@ def command(self, command: str) -> 'BashJob':
Same job object with command appended.
"""

if command.strip() == '':
job_name = f'job {self.name!r}' if self.name else 'unnamed job'
warnings.warn(f'Ignoring empty command specified for {job_name}.')
return self

command = self._interpolate_command(command)
self._command.append(command)
return self
Expand Down

0 comments on commit 747b87d

Please sign in to comment.