4.1.5 • Published 3 days ago

@jupyterlab/debugger v4.1.5

Weekly downloads
12,878
License
BSD-3-Clause
Repository
github
Last release
3 days ago

@jupyterlab/debugger

Github Actions Status Binder npm

A JupyterLab debugger UI extension. This extension is under active development.

screencast

Prerequisites

  • JupyterLab 2.0+
  • xeus-python 0.8.0+
  • notebook 6+

Installation

A kernel with support for debugging is required to be able to use the debugger.

It is generally recommended to create a new conda environment to install the dependencies:

conda create -n jupyterlab-debugger -c conda-forge xeus-python=0.8.6 notebook=6 jupyterlab=2 ptvsd nodejs
conda activate jupyterlab-debugger

Then, run the following command to install the extension:

jupyter labextension install @jupyterlab/debugger

Usage

For now xeus-python is the only Jupyter kernel that supports debugging. xeus-python can be selected from the JupyterLab launcher:

xpython-launcher

Alternatively, it is also possible to switch to the xpython kernel using the kernel selection dialog:

xpython-dialog

Enable the debugger, set breakpoints and step into the code:

xpython-step

Development

# Create a new conda environment
conda create -n jupyterlab-debugger -c conda-forge nodejs xeus-python=0.8.6 ptvsd jupyterlab=2

# Activate the conda environment
conda activate jupyterlab-debugger

# Install dependencies
jlpm

# Build TypeScript source
jlpm build

# Link your development version of the extension with JupyterLab
jupyter labextension link .

# Rebuild TypeScript source after making changes
jlpm build

# Rebuild JupyterLab after making any changes
jupyter lab build

# Start JupyterLab with the kernel logs enabled and watch mode enabled
XEUS_LOG=1 jupyter lab --no-browser --watch

Tests

To run the tests:

# [Optional] to enable the logs for xeus-python
export XEUS_LOG=1

jlpm run test

To run tests for a specific test suite name:

jlpm run test --testNamePattern=<regex>

To run tests for a specific test module name:

jlpm run test --testPathPattern=<regex>

Inspecting debug messages

The kernelspy extension for JupyterLab can be used to inspect the debug messages sent between the debugger UI and the kernel.

To install it:

jupyter labextension install jupyterlab-kernelspy

Debug Protocol Overview

The following diagram illustrates the types of messages sent between the JupyterLab extension and the kernel.

Diagram

debug-protocol

References

Source

Generated using: https://bramp.github.io/js-sequence-diagrams/

JupyterLab->JupyterLab: check 'debugger' key\nin the kernel spec

JupyterLab->user: show toggle button\nif 'debugger'

user->JupyterLab: enable debugging

JupyterLab->kernel: debugInfo request

kernel->JupyterLab: debugInfo response

user->JupyterLab: start debugger

JupyterLab->kernel: initialize request

kernel->JupyterLab: initialize response

JupyterLab->kernel: attach request

kernel->JupyterLab: attach response

Note right of kernel: debugger started

user->JupyterLab: add breakpoints\n(click on gutters)

JupyterLab->kernel: dumpCell request

kernel->JupyterLab: dumpCell response

JupyterLab->kernel: setBreakpoints request

kernel->JupyterLab: breakpoints response

JupyterLab->kernel: configurationDone request

kernel->JupyterLab: configurationDone response

user->JupyterLab: execute cell\n(Ctrl-Enter)

JupyterLab->kernel: requestExecute

kernel->kernel: execute code

kernel->kernel: hit breakpoint

kernel-->JupyterLab: stopped event

JupyterLab->kernel: stackTrace request

kernel->JupyterLab: stackTrace response

JupyterLab->user: show current line

JupyterLab->kernel: scopes request

kernel->JupyterLab: scopes response

JupyterLab->kernel: variables request

kernel->JupyterLab: variables response

JupyterLab->user: show variables

user->JupyterLab: step in deleted cell code

JupyterLab->kernel: stepIn request

kernel-->JupyterLab: stopped event

JupyterLab->JupyterLab: search for code matching\nsource path

JupyterLab->kernel: source request

kernel->JupyterLab: source response

JupyterLab->user: show source for current path

Note right of kernel: debug session

user->JupyterLab: disable debugging

JupyterLab->kernel: disconnect request

Note right of kernel: debugger stopped

kernel->JupyterLab: disconnect response

JupyterLab->JupyterLab: clear debugger UI for\nthe notebook

Inspecting Debug Messages in VS Code

Inspecting the debug messages in VS Code can be useful to understand when debug requests are made (for example triggered by a UI action), and to compare the behavior of the JupyterLab debugger with the Python debugger in VS Code.

Create launch.json

The first step is to create a test file and a debug configuration:

image

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Python: Current File",
      "type": "python",
      "request": "launch",
      "program": "${file}",
      "console": "integratedTerminal",
      "env": { "DEBUGPY_LOG_DIR": "/path/to/logs/folder" }
    }
  ]
}

Start the debugger

image

Open the logs

The content of the log file look like this:

...

D00000.032: IDE --> {
                "command": "initialize",
                "arguments": {
                    "clientID": "vscode",
                    "clientName": "Visual Studio Code",
                    "adapterID": "python",
                    "pathFormat": "path",
                    "linesStartAt1": true,
                    "columnsStartAt1": true,
                    "supportsVariableType": true,
                    "supportsVariablePaging": true,
                    "supportsRunInTerminalRequest": true,
                    "locale": "en-us"
                },
                "type": "request",
                "seq": 1
            }

...

With:

Overview

vscode-debug-logs

4.2.0-alpha.2

3 days ago

4.2.0-alpha.1

14 days ago

4.1.5

14 days ago

4.1.4

21 days ago

4.2.0-alpha.0

23 days ago

4.1.3

24 days ago

4.0.13

1 month ago

4.1.2

1 month ago

4.1.1

1 month ago

4.1.0

2 months ago

4.1.0-rc.1

2 months ago

4.0.12

2 months ago

4.1.0-rc.0

2 months ago

4.0.11

2 months ago

3.6.7

2 months ago

4.1.0-beta.2

2 months ago

4.1.0-beta.1

2 months ago

4.0.10

3 months ago

4.1.0-beta.0

3 months ago

4.0.5

8 months ago

4.0.4

8 months ago

4.0.7

6 months ago

4.0.6

7 months ago

4.0.3

9 months ago

4.0.9

4 months ago

4.0.8

5 months ago

3.6.6

6 months ago

4.1.0-alpha.4

4 months ago

4.1.0-alpha.1

7 months ago

4.1.0-alpha.3

5 months ago

4.1.0-alpha.2

6 months ago

3.6.5

9 months ago

4.0.1

10 months ago

4.0.0

11 months ago

4.0.2

10 months ago

3.6.4

10 months ago

4.0.0-rc.1

11 months ago

4.0.0-beta.2

11 months ago

4.0.0-beta.1

12 months ago

4.0.0-beta.0

1 year ago

4.0.0-alpha.19

1 year ago

4.0.0-alpha.18

1 year ago

3.6.2

1 year ago

3.6.1

1 year ago

3.6.0

1 year ago

3.6.3

12 months ago

4.0.0-alpha.20

1 year ago

4.0.0-alpha.22

1 year ago

4.0.0-alpha.21

1 year ago

4.0.0-rc.0

11 months ago

3.6.0-beta.0

1 year ago

3.6.0-rc.1

1 year ago

3.6.0-rc.0

1 year ago

4.0.0-alpha.17

1 year ago

4.0.0-alpha.16

1 year ago

3.6.0-alpha.5

1 year ago

3.6.0-alpha.4

1 year ago

3.6.0-alpha.3

1 year ago

3.5.3

1 year ago

3.5.2

1 year ago

3.5.1

1 year ago

4.0.0-alpha.15

1 year ago

4.0.0-alpha.14

1 year ago

3.5.0-rc.0

1 year ago

3.6.0-alpha.1

1 year ago

3.6.0-alpha.0

1 year ago

3.6.0-alpha.2

1 year ago

3.5.0

1 year ago

3.5.0-alpha.0

1 year ago

3.5.0-beta.0

1 year ago

3.4.8

1 year ago

4.0.0-alpha.13

2 years ago

3.4.7

2 years ago

3.4.6

2 years ago

4.0.0-alpha.12

2 years ago

3.4.4

2 years ago

3.4.5

2 years ago

4.0.0-alpha.11

2 years ago

4.0.0-alpha.10

2 years ago

3.4.0

2 years ago

3.4.3

2 years ago

3.4.2

2 years ago

3.4.1

2 years ago

4.0.0-alpha.9

2 years ago

4.0.0-alpha.8

2 years ago

3.4.0-alpha.0

2 years ago

3.4.0-beta.0

2 years ago

3.4.0-rc.0

2 years ago

3.3.4

2 years ago

3.3.3

2 years ago

4.0.0-alpha.7

2 years ago

4.0.0-alpha.6

2 years ago

3.3.1

2 years ago

3.3.0

2 years ago

3.3.2

2 years ago

3.3.0-beta.0

2 years ago

4.0.0-alpha.5

2 years ago

4.0.0-alpha.3

2 years ago

4.0.0-alpha.4

2 years ago

3.2.6

2 years ago

3.2.9

2 years ago

3.2.8

2 years ago

3.2.7

2 years ago

3.1.18

2 years ago

3.3.0-rc.0

2 years ago

3.3.0-alpha.16

2 years ago

3.3.0-alpha.17

2 years ago

3.3.0-alpha.18

2 years ago

4.0.0-alpha.1

2 years ago

4.0.0-alpha.2

2 years ago

3.2.5

2 years ago

3.2.4

2 years ago

3.2.3

2 years ago

3.3.0-alpha.15

2 years ago

3.2.2

2 years ago

3.2.1

2 years ago

3.2.0

2 years ago

3.1.17

2 years ago

3.3.0-alpha.12

2 years ago

3.3.0-alpha.13

2 years ago

3.3.0-alpha.14

2 years ago

3.2.0-rc.0

2 years ago

3.1.16

2 years ago

3.1.15

2 years ago

3.0.14

2 years ago

3.2.0-beta.0

2 years ago

3.1.13

3 years ago

3.3.0-alpha.11

3 years ago

3.2.0-alpha.1

3 years ago

3.1.12

3 years ago

3.2.0-alpha.0

3 years ago

3.1.11

3 years ago

3.3.0-alpha.10

3 years ago

3.3.0-alpha.9

3 years ago

3.3.0-alpha.8

3 years ago

3.1.10

3 years ago

3.3.0-alpha.7

3 years ago

3.1.9

3 years ago

3.3.0-alpha.6

3 years ago

3.3.0-alpha.5

3 years ago

3.1.7

3 years ago

3.1.8

3 years ago

3.3.0-alpha.4

3 years ago

3.1.6

3 years ago

3.3.0-alpha.2

3 years ago

3.3.0-alpha.3

3 years ago

3.1.5

3 years ago

3.1.4

3 years ago

3.3.0-alpha.1

3 years ago

3.0.13

3 years ago

3.1.3

3 years ago

3.1.2

3 years ago

3.1.1

3 years ago

3.3.0-alpha.0

3 years ago

3.1.0

3 years ago

3.1.0-rc.2

3 years ago

3.1.0-rc.0

3 years ago

3.1.0-rc.1

3 years ago

3.1.0-beta.2

3 years ago

3.1.0-beta.1

3 years ago

3.1.0-beta.0

3 years ago

3.1.0-alpha.13

3 years ago

3.1.0-alpha.11

3 years ago

3.1.0-alpha.12

3 years ago

3.1.0-alpha.10

3 years ago

3.0.12

3 years ago

3.0.11

3 years ago

3.1.0-alpha.9

3 years ago

3.1.0-alpha.6

3 years ago

3.1.0-alpha.7

3 years ago

3.1.0-alpha.8

3 years ago

3.1.0-alpha.5

3 years ago

3.0.10

3 years ago

3.0.9

3 years ago

3.1.0-alpha.4

3 years ago

3.0.8

3 years ago

3.0.7

3 years ago

3.1.0-alpha.3

3 years ago

3.0.6

3 years ago

3.1.0-alpha.2

3 years ago

3.1.0-alpha.1

3 years ago

3.1.0-alpha.0

3 years ago

3.0.5

3 years ago

3.0.4

3 years ago

3.0.3

3 years ago

3.0.2

3 years ago

3.0.1

3 years ago

3.0.0

3 years ago

3.0.0-rc.15

3 years ago

3.0.0-rc.14

3 years ago

0.3.7

3 years ago

3.0.0-rc.13

3 years ago

3.0.0-rc.12

3 years ago

3.0.0-rc.11

3 years ago

0.3.6

3 years ago

0.3.5

3 years ago

3.0.0-rc.10

3 years ago

3.0.0-rc.9

3 years ago

3.0.0-rc.8

3 years ago

3.0.0-rc.7

3 years ago

3.0.0-rc.6

3 years ago

3.0.0-rc.5

3 years ago

0.3.4

3 years ago

3.0.0-rc.4

3 years ago

3.0.0-rc.3

3 years ago

3.0.0-rc.2

3 years ago

0.3.3

3 years ago

3.0.0-rc.1

4 years ago

3.0.0-rc.0

4 years ago

3.0.0-beta.8

4 years ago

3.0.0-beta.7

4 years ago

3.0.0-beta.6

4 years ago

3.0.0-beta.5

4 years ago

0.3.2

4 years ago

3.0.0-beta.4

4 years ago

3.0.0-beta.3

4 years ago

3.0.0-beta.2

4 years ago

3.0.0-beta.1

4 years ago

3.0.0-beta.0

4 years ago

3.0.0-alpha.14

4 years ago

3.0.0-alpha.13

4 years ago

3.0.0-alpha.12

4 years ago

3.0.0-alpha.11

4 years ago

3.0.0-alpha.10

4 years ago

3.0.0-alpha.9

4 years ago

3.0.0-alpha.8

4 years ago

3.0.0-alpha.7

4 years ago

3.0.0-alpha.6

4 years ago

0.3.1

4 years ago

3.0.0-alpha.5

4 years ago

0.3.0

4 years ago

0.3.0-beta.7

4 years ago

0.3.0-beta.6

4 years ago

0.3.0-beta.5

4 years ago

0.3.0-beta.4

4 years ago

0.3.0-beta.3

4 years ago

0.3.0-beta.2

4 years ago

0.3.0-beta.1

4 years ago

0.3.0-alpha.1

4 years ago

0.2.0

4 years ago

0.2.0-rc.1

4 years ago

0.2.0-beta.1

4 years ago

0.2.0-alpha.3

4 years ago

0.2.0-alpha.2

4 years ago

0.2.0-alpha.1

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago

0.1.0-rc.1

4 years ago

0.1.0-alpha.3

4 years ago

0.1.0-alpha.2

4 years ago

0.1.0-alpha.1

4 years ago