I would like to control my Jupyter actions via the command line on a remote JupyterHub instance. Specifically, I need to upload a notebook, launch a notebook, and stop a notebook.
I had considered using Jupyter Server for this purpose. However, when I try to restart a kernel using the REST API, it interrupts the kernel but does not restart it.
Do you have any suggestions on why this might be happening? Additionally, if you have any documentation, videos, or other resources that could assist me in this process, I would greatly appreciate it.
JupyterHub only starts/stops your singleuser server, i.e. jupyter-server/lab/notebook. Once it’s started you then interact with jupyter-server directly (all JupyterHub does is proxy your requests).
Thanks for the clarification and help. I actually not interested in controlling the hub but the singleuser server. I want restart a kernel that is already running on the server for example.
Since I want just use just 3 simple action, if I could be able to solve the issue and using directly the rest api I would prefer so to avoid a new dependency. But thanks you very much for the reference I will try to give a look since could make me better understand how to communicate with the server.
Can you share the request you are using to restart the kernel? It should be POST /api/kernels/{kernel_id}/restart. And also please share the logs from the server when you are making the request.
restarting the kernel only restarts the kernel process. Executing code (the “Run All” in “Restart & Run All”) is separate, and requires sending execute requests for each cell of the notebook after restart has completed. Restart and Run All is a JupyterLab/notebook client feature, not part of the Server’s REST API.