Add `backend.ai exec` command to execute a shell command in a running session
- Dominant language
- Python
- Stars
- 670
- Forks
- 183
- Avg merge
- 14h 15m
- Merged PRs (30d)
- 335
Description
Currently `backend.ai run` command requires to specify a file to execute a shell command, due to a prior parsing limitation of Click with mixing required positional arguments and a zero-or-more positional argument.This makes unnecessary confusion for new users and we feel also difficult to explain to them.
Let's make a new command, just like `docker exec`:
- `backend.ai [root-options] exec {session-id-or-name} {cmdargs...`}\* Following the new CLI command hierarchy (lablup/backend.ai-client-py#163), `backend.ai exec` should be an alias of `backend.ai session exec`.
- The session ID or name may be a partial prefix of session ID or names, like in `backend.ai rm`.
- This command does not create the session but raises an explicit error if it does not exist.
- All the rest of arguments are passed as-is.
Considerations for implementing this feature in various client environments:| Client Env | Command/Function | Implementation detail || ------------- | ------------- | ------------------- || CLI | `backend.ai run --exec "" ` | session create API + kernel file upload API + batch-mode execution API || CLI | `backend.ai app ` | stream proxy API || CLI | `backend.ai ssh ` | kernel file download API (to get ssh key) + alias of `app` command + wrapper of OpenSSH client || CLI | `backend.ai exec ` | alias of `ssh` command || Browser | Running a shell command in session | batch-mode execution API |
The advantage of making `exec` to be an alias of `ssh` is that it supports the full terminal and interactive stdin support through the SSH session. But in the web browsers we don't have the SSH client available for Javascript codes, so we need to fallback to use the batch-mode execution API.
JIRA Issue: BA-291
Contributor guide
Assessment
This issue has not been assessed yet.