-
-
Notifications
You must be signed in to change notification settings - Fork 369
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implementation of the debugger #597
Conversation
fab5475
to
322883b
Compare
6638e96
to
c7ccfd0
Compare
248fcc2
to
f5fa005
Compare
It looks like we should drop support for Python 3.6 since IPython did it in version 7.17 and IPykernel depends on IPython 7.21 in this PR. |
cc @MSeal @captainsafia @rgbkrk @betatim You may be interested in this. |
f89cc8d
to
b94fa9f
Compare
Tests are passing! This is ready for review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fantastic!
Thanks for the ping @SylvainCorlay, this is great news! Thanks for all the work you and your team have put into this! I have one question about the implementation: is it necessary to use Debugpy as the debugger backend? The thing is we have our own debugger, which is tightly integrated with Spyder, so we couldn't switch easily to Debugpy. |
The front-end implementation in lab only requires that the kernel implements the Jupyter Debugger Procotol, which is essentially the DAP over the control channel. Xeus-python and xeus-robot both implement the protocol (in the case of xeus-robot, it is for the Robotframework language). In ipykernel, it uses debugpy (which is the successor of ptvsd). We could iterate on this to make it an extension point to another implementation. I think a difference with the spyder kernels is that the latter open a new websocket for debugger communication. |
Great! If that can be made configurable, we can certainly hook our debugger into it.
Right, but our idea is to switch to the control channel (now that it's threaded) to avoid having our own (non-standard) one. |
We really want to serve Spyder in addition to Jupyter frontends, so if you want to get together for a "blackboard" session on this, we are happy to make ourselves available. |
I cut a https://pypi.org/project/ipykernel/6.0.0a0/ so folks can try this out with |
Thanks @blink1073 ! If we move toward a 6.x I'd love to have to also remove ipython_genutils as a dependencies, as it's starting to lead to packaging issues in linux (indirectly because of nose), and we had a couple of request for removing it. Many use case are python 2/3 compat so should be easy; I've already send a PR with some removal but would appreciate some extra hands. |
Agreed! I added #600 to the 6.0 milestone |
hum, the alpha release seem to make the CI of jupyter_client fail. (also I've just push a commit to fix the version number that was |
That should be fixed. I think we can tag another pre-release as of the tip of the master branch. |
This PR is the initial implementation of the debugger in IPykernel, according to the recent changes in the Jupyter messaging protocol. Although the implementation is not complete, it already contains a minimal set of features that makes the debugger usable, and it is in an acceptable state for a review. @Carreau sorry to ping you so late, I wish I could open this PR sooner.
1. Requirements
IPython master (for Allow passing a custom CachingCompiler to the interactive shell ipython#12809, I will update this requirement when IPython is released)Murmurhash personal branch until this PR is mergedAlso this PR is based on #585. We can either rebase once it is merged, or close it and use this PR only.2. Main changes
3. Debugpy logic
Debugpy is started once by executing code on the
shell
thread. This is required by debugpy to be able to stop on breakpoints. This code is sent by the control thread to the shell socket the first time adebug request
wrapping theinitialize
command is received.Once debugpy runs, you start a debug session by connecting a client socket, and you end it by disconnecting the client socket. Notice that debugpy still runs in the background.
The initialization sequence of debugpy is different from that of ptvsd, which was used when implementing the frontend. In order to keep the frontend independent from this logic, the initialization sequence is totally handled by the kernel after it receives an
attach
command4. Future improvements
After stopping on a breakpoint, the callstack panel shows the whole callstack, including methods form ipykernel. We may want to filter that and keep the methods from the notebook cells only.Similarly, clicking on "next" does not show the next line in the current cell, since it executes the next python statement in ipykernel. We may improve that by looping on sendingnext
requests until we stop on a line from the current notebook cell.cc @SylvainCorlay @afshin @jasongrout @minrk @ellisonbg @blink1073 @jtpio @martinRenou