Skip to content

Add Container.console, a shell in a notebook cell - #102

Draft
msherman64 wants to merge 1 commit into
masterfrom
feat/console
Draft

msherman64 wants to merge 1 commit into
masterfrom
feat/console

Conversation

@msherman64

Copy link
Copy Markdown
Contributor

Adds Container.console(), which opens an interactive shell in a CHI@Edge container inside a notebook cell. Until now the only way to get a shell was to run openstack appcontainer exec --interactive in a separate terminal.

container.get_container("my-container").console()   # or .console("bash")

The kernel holds the exec session, through python-zunclient's execute_interactive(), recv(), send() and resize(). The cell shows the session with xterm.js, as an anywidget. It doesn't use the openstack CLI or Jupyter's terminals, so it works in JupyterLab and in VS Code notebooks. When the command exits, the cell shows its exit status.

Needs a python-zunclient with those methods. They're in mike-personal-org/python-zunclient#20 and aren't in ChameleonCloud/python-zunclient yet. It also needs anywidget in the Jupyter image.

Note: the shell has a tty, so stderr arrives mixed into stdout, as in a terminal.

Not handled yet, most harmful first:

  • In a VS Code notebook, an early prototype received each key five times, so Enter ran a command five times. The cause isn't known yet.
  • You can't type in the console while another cell is running. The kernel handles keys only when it's idle.
  • With an older python-zunclient, console() fails with an AttributeError, not a clear message.
  • xterm.js loads from cdn.jsdelivr.net, so the console doesn't work where that's blocked.
  • Closing the browser tab leaves the shell running until the kernel stops.
  • Nothing keeps a quiet session alive. HAProxy may cut it after an hour (not checked).

🤖 Generated with Claude Code

Notebook users had no way to get an interactive shell in a CHI@Edge
container from python-chi. The only way was running
`openstack appcontainer exec --interactive` in a separate terminal.

Container.console() starts the command with stdin and a tty through
python-zunclient's execute_interactive(), and shows it in the cell with
xterm.js, as an anywidget. A thread in the kernel passes the session's
output to the cell, and keys and the terminal size go back through
send() and resize(). When the command exits, the cell shows its exit
status.

It needs a python-zunclient with execute_interactive(), recv(), send()
and resize().

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant