How to run UI button commands from the script or command line?

Hi,
I am using jupyter server, I would like to write a script that opens up
.ipynb file (red rectangle on the pic) and runs command from the button (blue rectangle on the pic)

How do I run those commands from the command line, or from script (without clicking) ?

jyg is a little CLI and serverextension exposing a REST API and websocket for working with commands. Here’s the community call demo.

tl: dr;

pip install jyg # or conda/mamba -c conda-forge
# restart your server, reload the page
jyg run filebrowser:open --path Untitled.ipynb 
jyg run notebook:run-all-cells

The jyg list command can help get the command ids… but that’s about it.

Among the pointiest edges:

  • only works on the first jupyter_server running on the same machine
  • probably does crazy things if multiple browsers are open
  • the browser has to be open and fully loaded
  • a lot of commands pop confirmation dialogs, etc. which jyg doesn’t know what to do with
  • a lot of commands return non-JSON rubbish which can’t be serialized, so might report “errors” even if it works
    • even if they return something, there’s no guarantee it’s useful
  • complex inputs need to use an icky JSON format like {"some": {"nested": "args"}}}
3 Likes