Package: callisto-jupyter-d1
jupyter_d1Jupiter Discovery One serverInfoInstallpip install git+https://github.com/OakCityLabs/jupyter_d1.git@branch_name#egg=jupyter_d1Once installed, install kernel definitions withjupyter_d1_install_kernelsStart Serverstart_jupyter_d1 --port=8000 --secret_token=user_provided_secret --root_dir=/path/to/working/directoryRun tests(Requires pytest, async-asgi-testclient)jupyter_d1_testHow Stuff WorksThe Jupyter D1 server sits between a REST client and a Jupyter Kernel.
Kernels don't understand notebooks.  They just execute commands they receive.
Jupyter D1 manages the state of the notebook, keeping track of which cell is being
executed and updating the cells results with the kernel finishes processing.In the traditional JavaScript Jupyter client, all of this state is held in the web app.
This makes it impossible to share that state with another client.In Jupyter D1, this state is held in the D1 server and a client can connect at any time
and ask for the current state.A client may also ask that new code is executed.  The D1 server relays that to the active kernel.
Kernel results are used to update the current model of the notebook in the D1 server and broadcast
to clients to update UIs.Clients should connect to the notebook websocket stream where they will receive a broadcast of all
the updates to the notebook cells.  Clients can send regular REST requests to initiate action, like
executing a cell or changing a cell's source code.  A websocket is also avaible for the raw stream
of kernel messages, but that's not intended for client consumption in the long term.  Kernel messages
are more of a debugging tool.See Makefile for convenience commandsmake save_env    save current development environment using conda to environment.yml
make load_env    create a development environment using conda from environment.yml (deletes current env definition)
make show_env    list available conda environments
make lint        run the linter
make test        run pytest
make ci_test     run the linter and then run pytest    
make run_debug   run the 'uvicorn' server in debug mode
make docs        open the docs in your browser (mac only, requires server running locally)
make redoc       open the alternate docs in your browser (mac only, requires server running locally)DocumentationRun the server withmake run_debugOpen the Swagger UI docs URL withmake docslinkOpen the ReDoc docs URL withmake docslinkStream listenersRun./ws_listener.pyto echo out messages from the websocket broadcast channels.  Two options are:./ws_listener.py --feed stream-- Listen to the stream of kernel messages direct from the Jupyter kernel./ws_listener.py --feed notebook-- List to the jupyter_d1 stream of updates to notebook cellsPawSee the included Paw filejupyter_d1.pawfor some examples.  A simple test sequence that might represent
what a client would do:Open the simple notebookExecute a cell by ID -- set xExecute a cell by ID -- increment xThis loads a notebook, executes a cell which assigns a value toxand then executes another cell that
increments the value ofx.  It's useful to have the stream listeners active to see the results.Testingmake testwill pytest and report coverageJust runningpytestfrom the top level directory will run all the testsCan specify a specific test withpytest tests/test_notebooks_websocket.py::TestNotebookWebSocket::test_notebookVS Code should understand the tests and run them from the editor, but sometimes that seems flakey.If VS Code has trouble finding tests, runpytest --collect-onlyat the cli to check for errors.WebDAV serverThe FastAPI app instantiates aWebDAV servermounted under/dav.Currently, this exposes/tmpon the local machine.Can be mounted via a WebDAVclient.Eventually, this will provide clients file level access to the Jupyter working directory.Current username isuserwith passwordpassword.There is a read-only user calledreadonly_userbut permission levels aren't implemented, so this user has full access.Static typingJupyter_D1 uses static typing for compatibility with FastAPIThe python runtime ignores type information at the moment.In VS Code, you should enable themypylinter to check typing.Mypy CheatsheetAuthenication with shared secretUse the shared secret from the server command line to get an access tokencurl -H "Authorization: <SHARED_SECRET>"http://127.0.0.1:<port_number>/login/access-tokenreturns {"token":{"access_token":"ACCESS_TOKEN","token_type":"bearer"}}Use the returned access token for subsequent requestscurl -H "Authorization: Bearer <ACCESS_TOKEN>"http://127.0.0.1:<port_number>/notebooks