Edit this page on our live server and create a PR by running command !create-pr in the console panel

Using the console panel

  • Difficulty level: easy
  • Time need to lean: 10 minutes or less
  • Key points:
    • Use Ctrl-Shift-Enter to send current line or selected text to console panel

Classic Jupyter interface

Console panel

SoS provides a side panel that can be toggled by a cube icon on the toolbar. The side panel contains a special cell at the bottom that

  1. Serves as a sratch cell that allows you to evaluate any expression and check its results.
  2. Executes and displays text sent from the main notebook through run-in-console action (see below for details)

Because this cell is not part of the main notebook, its output will not be saved with the notebook. This allows you to test commands, check values of variables and content of files without affecting the content of the notebook.

Run current statement or selection in console panel

Shortcut Ctrl-Shift-Enter sends current statement or selected text to the console cell for evaluation. This effectively allows you to evaluate content of a cell step by step. This shortcut works for all kernels. The console cell will switch to the kernel of the sending cell if the sending cell is in a different kernel.

For example, using C-S-Enter twice on the following cell with send two statements to console

In [1]:
Out[1]:
[1, 2]

Screen%20Shot%202019-12-20%20at%209.42.24%20AM.png

Shortcut to toggle output in generated reports

Shortcut Ctrl-Shift-O (output) toggles a code cell tag show_output and marks the output with a gray bar to the right of the output area, or toggle a markdown cell tag hide_output. The tags will be used to direct the generation of HTML report when you are using templates sos-report and sos-report-toc. More specifically, code without the show_output tag will be hidden initially, and be displayed only with show code is selected. Please check generate HTML report for details.

Note that the use of this mechanism is discouraged due to the fact that the JupyterLab version has switch to another set of templates that makes use of the folding status of cells for the same purposes. It is kept because the current jupyter interface does not offer a way to fold cell inputs.

Other usage hints

  1. Drag and drop figures: You can drag a picture and drop it to a markdown cell of the Jupyter notebook.
  2. Tab completion: You can use tab to complete keyword, magics (enter % and press TAB to get a list of magics), variable name, function name, file name etc.
  3. Inspect name: You can place your cursor inside a keyword, function name, magic etc, and press CTRL-TAB to inspect it. SoS will show variable name, help message etc depending on the keyword that is being inspected.

Jupyter Lab interface

To use SoS Notebook for JupyterLab, you will need to install the jupyterlab-sos extension. Which can be installed from command line, or through the extension manager inside JupyterLab. JupyterLab is a newer generation of Jupyter interface that offers much more features than classic jupyter. It offers many features that SoS Notebook brings to classic jupyter. In particular,

  • JupterLab has its own console panel. To open a console panel, right-click a notebook and select "New console for notebook".

  • JupyterLab supports action run-in-console which sends the current statement or selected text to console panel for execution. This feature is contributed by SoS Notebook but it does not have a default shortcut. To assign a shortcut to this action, you can go to Settings -> Keyboard Shortcut Editor, search for Run in console and add one.

  • JupyterLab supports folding of input and output so the use of cell tags to determine display of cells in exported HTML report is no longer recommended. To use this feature, simply hide the input or output of cells and use templates sos-report-v2 or sos-report-toc-v2.