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

Open files directly from tracebacks #13277

Closed
divyansshhh opened this issue Oct 20, 2022 · 4 comments · Fixed by #13390
Closed

Open files directly from tracebacks #13277

divyansshhh opened this issue Oct 20, 2022 · 4 comments · Fixed by #13390

Comments

@divyansshhh
Copy link
Contributor

Problem

Google Colab has a handy feature which allows the user to jump to the file which caused an error directly from the traceback. Here's how this looks -
image
I find this really useful and I think it should also be supported in JupyterLab.

Proposed Solution

It should be possible to modify the renderText (or create a new method altogether) method to have an ILinkHandler and ISanitizer. The sanitizer can take care of wrapping the paths in anchors and the linkHandler can handle opening of the file in a sidepanel.

@jupyterlab-probot jupyterlab-probot bot added the status:Needs Triage Applied to new issues that need triage label Oct 20, 2022
@divyansshhh
Copy link
Contributor Author

I'm happy to hear thoughts on this and also raise a PR for this.

@krassowski
Copy link
Member

This would be a great UX improvement. Some things to consider:

  • the path returned in tracebacks from remote kernels will differ from local path (the debugger avoids this issue by having the kernel serve the files via DAP source request)
  • files outside of the project should probably be opened in read-only mode (already implemented in the debugger)
  • not all tracebacks are the same: different versions of IPython, and kernels for other languages (IJulia, IRkernel) will have different formatting for tracebacks; if the file path is to be retrieved by regex, it would be worth checking how it behaves against the three kernels at a minimum (Julia adds line number after colon, R also does a variant of that but rarely shows the path to file, mostly for parsing errors)
  • personally, I would prefer to have the file opened in the main area, possibly to the right of the current area over opening it in the sidebar as that allows to drag the source file around
  • minor: some users import from notebooks using nbimport; not sure how it shows up in the traceback, but worth testing at review phase and therefore the document manager/factory should probably be used rather than operating on plain file

@krassowski
Copy link
Member

The sanitizer can take care of wrapping the paths in anchors

Not sure why sanitizer would be responsible for this? One option is to extend autolink as used in:

const linkedNodes = autolink(preTextContent);

Or to make a second function (autolinkPaths?).

Using ILinkHandler here sounds like a good idea at first glance.

@krassowski
Copy link
Member

modify the renderText (or create a new method altogether)

We could have a new renderError method which would only be used for outputs with MIME type application/vnd.jupyter.stderr. It is probably a good idea, otherwise we may see a slowdown when rendering non-traceback text outputs as there would be an extra penalty for searching large outputs for presence of things which look like path references.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants