From 747b87d3ec82b787c26c7ad95975e787ab7e1a72 Mon Sep 17 00:00:00 2001 From: John Marshall Date: Wed, 25 Sep 2024 10:41:20 +1200 Subject: [PATCH] [batch] Ignore empty command strings when constructing shell scripts 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. --- hail/python/hailtop/batch/job.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hail/python/hailtop/batch/job.py b/hail/python/hailtop/batch/job.py index 97eb45be0d4..facf34f1e2c 100644 --- a/hail/python/hailtop/batch/job.py +++ b/hail/python/hailtop/batch/job.py @@ -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