Flux plugin splits trainer arguments that contain spaces
What happened?
The Flux plugin joins the trainer command and args into one string (getOriginalCommand), and entrypoint.sh runs it as flux run ${flags} ${command} without quotes. So any argument with a space in it gets split.
For example, a TrainJob with
command: ["python", "-c", "print('hello world')"]
ends up running python, -c, print('hello, world'). Same for bash -c "<script>" commands.
The same two lines the entrypoint uses show it:
set -- "python -c print('hello world')"
command="$@"
printf '[%s] ' ${command}
# [python] [-c] [print('hello] [world')]
What did you expect to happen?
Each argument should reach flux run as given. Passing the command and args to entrypoint.sh as separate arguments and running flux run ${flags} "$@" would do that.
One thing to check first: the "command and args with extra spaces" case in TestGetOriginalCommand expects padded values like " python " to get trimmed, which only works because of the splitting. Is that worth keeping? Happy to send a PR either way.
Environment
Found by reading the code on master (847e3d2), not on a cluster.
Kubernetes version: n/a Kubeflow Trainer version: master (847e3d2) Kubeflow Python SDK version: n/a
Impacted by this bug?
Give it a 👍 We prioritize the issues with most 👍
🎉 Welcome to the Kubeflow Trainer! 🎉
Thanks for opening your first issue! We're happy to have you as part of our community 🚀
Here's what happens next:
- Our team will review your issue soon! cc @kubeflow/kubeflow-trainer-team
- If you'd like to contribute to this issue, check out our Contributing Guide for repo-specific guidelines and the Kubeflow Contributor Guide for general community standards.
Join the community:
- Slack: Join our #kubeflow-trainer Slack channel.
- Meetings: Attend the Kubeflow AutoML and Training Working Group bi-weekly meetings.
Feel free to ask questions in the comments if you need any help or clarification! Thanks again for contributing to Kubeflow! 🙏
I'd like to work on this.
I'll keep the change focused on preserving the trainer command and args as separate arguments through the Flux entrypoint, so values containing spaces aren't split by the shell. I'll also add regression coverage for arguments such as python -c "print('hello world')" and check the existing whitespace-trimming behavior before changing it.