Skip to content
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

Implement %pdb support in notebooks #6374

Closed
Tracked by #1652
rchiodo opened this issue Jun 24, 2021 · 10 comments
Closed
Tracked by #1652

Implement %pdb support in notebooks #6374

rchiodo opened this issue Jun 24, 2021 · 10 comments
Assignees
Labels
feature-request Request for new features or functionality notebook-debugging

Comments

@rchiodo
Copy link
Contributor

rchiodo commented Jun 24, 2021

Assuming we have debugging working can %pdb also work? Not sure what this does at the moment, but user's have been asking for this.

@e13h
Copy link

e13h commented Jun 25, 2021

The %pdb magic command automatically calls the interactive debugger when an exception is raised.

Source: https://ipython.readthedocs.io/en/stable/interactive/magics.html#magic-pdb

@greazer greazer added the bug Issue identified by VS Code Team member as probable bug label Jul 8, 2021
@DavidKutu DavidKutu added this to the September 2021 milestone Aug 31, 2021
@DavidKutu DavidKutu added enhancement and removed bug Issue identified by VS Code Team member as probable bug labels Sep 21, 2021
@greazer greazer modified the milestones: September 2021, October 2021 Sep 21, 2021
@greazer greazer removed this from the October 2021 milestone Oct 7, 2021
@DonJayamanne
Copy link
Contributor

@int19h Does Python extension support %pdb for debugging? If yes, then I guess we can somehow try to get this working here as well.

@int19h
Copy link
Contributor

int19h commented Oct 18, 2021

debugpy doesn't have an interactive command mode like pdb does. Also, I think this command is hardcoded in the notebooks to specifically invoke pdb? If it's actually a hook that can invoke an arbitrary function, then having it invoke breakpoint() while running with debugpy attached should do the trick.

However, this particular scenario (breaking on exception) could be handled simply by running under debugger with User-uncaught Exceptions set to true.

@greazer greazer added feature-request Request for new features or functionality and removed enhancement labels May 4, 2022
@roblourens
Copy link
Member

This is actually supported, via quick input

@rchiodo
Copy link
Contributor Author

rchiodo commented Dec 8, 2022

This is actually supported, via quick input

Do you have more details? %pdb is supposed to trap exceptions and show them in the debugger. At least I think that's how it works.

@roblourens
Copy link
Member

When an exception occurs, I see a quick input show up which lets me enter pdb commands. In Jupyter lab, an input box appears below the cell for pdb commands. So it seems to work as well as Jupyter lab. I don't expect it to integrate with the vscode debugger or anything like that.

@micimize
Copy link

It seems unlikely to me that dropping into the full vscode from %pdb makes sense or is feasible – it would be confusing for %pdb not to invoke/work like pdb.

However, it might make sense to open a new issue to discuss/investigate a "drop into vscode debugger from running notebook" feature more thoroughly if that doesn't currently exist (or maybe better document how to set it up if it does).

@roblourens
Copy link
Member

Can you explain more about what you're looking for? Debugging notebooks does exist with the "Debug cell" command

@micimize
Copy link

Ahh, ok – no that is perfect. For some reason it wasn't clear to me that Debug Cell used the existing notebook kernel.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature-request Request for new features or functionality notebook-debugging
Projects
None yet
Development

No branches or pull requests

9 participants