Jupyter uses the terminado
package to provide terminal access in the GUI. We use its JSON API
to provide terminal access via ssh - this way, we can provide terminal
access to any JupyterHub, without depending on implementation details
like kubernetes or container requirements.
jupyterhub_ssh/terminado.py is a class that's a client for
terminado. This should be able to talk to any terminado server,
running in a plain Jupyter Notebook. We should write simple tests
that:
Start a jupyter notebook
Talk to the terminado endpoint there
Verify that things work as they should!
Things we should test:
Authorization works via token, fails without
Sending stdin works fine. We can do this by sending something like
touch <random-generated-id>\n to the shell, and verifying that the
file was created.
Fetching stdout works fine. We could do this by sending a commend
via stdin like echo <random-generated-id>\n and testing that we
see that in stdout.
Setting size on the terminal (via set_size) is reflected fine in
the backend. This reflects the row and column size used by TUI
applications - like emacs, vim, top, etc. Once set_size is sent,
you can validate the new size by running tput cols and tput lines.
Terminal servers are started when needed, and whenever disconnects /
issues happen, they are cleaned up properly. We shouldn't leave
random terminado servers running. We can test this by hitting the
notebook API ourselves and testing.
Would be nice to document the protocol too - I don't think there's
public documentation of this JSON protocol.
Jupyter uses the terminado package to provide terminal access in the GUI. We use its JSON API to provide terminal access via ssh - this way, we can provide terminal access to any JupyterHub, without depending on implementation details
jupyterhub_ssh/terminado.py
is a class that's a client for terminado. This should be able to talk to any terminado server, running in a plain Jupyter Notebook. We should write simple tests that:Things we should test:
touch <random-generated-id>\n
to the shell, and verifying that the file was created.echo <random-generated-id>\n
and testing that we see that in stdout.set_size
) is reflected fine in the backend. This reflects the row and column size used by TUI applications - like emacs, vim, top, etc. Onceset_size
is sent, you can validate the new size by runningtput cols
andtput lines
.Would be nice to document the protocol too - I don't think there's public documentation of this JSON protocol.