JupyterLabSession#
- class rubin.nublado.client.JupyterLabSession(*, username, session_id, socket, logger)#
Bases:
objectOpen WebSocket session to a JupyterLab.
Objects of this type should be created via the
JupyterLabSessionManagercontext manager.- Parameters:
username (
str) – User the session is for.session_id (
str) – Session ID of the JupyterLab session.socket (
ClientConnection) – Open WebSocket connection.logger (
BoundLogger) – Logger to use.
Methods Summary
run_python(code[, context])Run a block of Python code in a Jupyter lab kernel.
Methods Documentation
- async run_python(code, context=None)#
Run a block of Python code in a Jupyter lab kernel.
- Parameters:
code (
str) – Code to run.- Returns:
Output from the kernel.
- Return type:
- Raises:
NubladoDiscoveryError – Raised if Nublado is missing from service discovery.
NubladoExecutionError – Raised if an error was reported by the Jupyter lab kernel.
NubladoRedirectError – Raised if the URL is outside of Nublado’s URL space.
NubladoWebSocketError – Raised if there was a WebSocket protocol error while running code or waiting for the response.
rubin.repertoire.RepertoireError – Raised if there was an error talking to service discovery.
RuntimeError – Raised if called before entering the context and thus before creating the WebSocket session.
Notes
The output returned is only what the cell prints (its standard output). When run inside Jupyter, the cell will display the result of the last Python code line run. This parser ignores that information (the
execute_resultmessage).display_datais also ignored. This is the message type sent for other types of output, such as when you ask Bokeh to show a figure. It’s a bunch of Javascript that will be interpreted by your browser.See the JupyterLab wire protocol for the full protocol. What we use is half a layer above that. We care what some messages on the various channels are, but not about the low-level implementation details of how those channels are established over ZMQ, for instance.
- Parameters:
context (
CodeContext|None, default:None)