-
Notifications
You must be signed in to change notification settings - Fork 244
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
[batch] Omit empty command strings when constructing shell scripts #14700
base: main
Are you sure you want to change the base?
Conversation
We recently encountered jobs that failed due to syntax errors in the shell script generated by Hail, stemming from code such as job.command('touch before')
job.command('\n'.join(f'echo {shlex.quote(msg)}' for msg in messages))
job.command('touch after') Occasionally
Shell compound commands like Empty commands could be rewritten to generate e.g. …
{
:
}
… but it seems easier and probably less surprising to just omit them. |
(We've added |
@jmarshall another way to do this might be to ignore/do nothing during the initial call of I do like the idea of fixing this in the hail library, but you could also consider altering your upstream code so that it never makes an invalid " job.command('touch before')
for msg in messages:
job.command(f'echo {shlex.quote(msg)})
job.command('touch after') (assuming it doesn't matter to you whether the messages are handled in the same section of the resulting command or not) What do you think? |
As I said, we have already worked around the particular instance of this. But I've raised it here so that we or other Hail users won't need to do so in future.
🤷 I'm not sure that the presence of empty items in |
@jmarshall it sounded when we caught up in person like you agreed that skipping empty command strings at source (and emitting a warning) during the original |
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.
dd323c6
to
747b87d
Compare
I've updated the PR accordingly — feel free to wordsmith the warning message. |
@jmarshall, thanks doing this - would you mind adding a simple unit test to lock down the behaviour? |
I am unfamiliar with Hail's test infrastructure so it would be more time efficient for the maintainers to add a test themselves. |
@jmarshall - PR populationgenomics#349 for your consideration |
Thanks, added with one tweak. Sadly I don't know how to convince your code analyser that using Feel free to push to PR branches directly, or just to add things while merging. You folks are the Hail maintainers after all! |
Me neither 🤷
I don't have write access to the |
TIL “Allow edits from maintainers” applies only to PRs from personal forks, not organisation forks. Annoying! |
No description provided.