Pluto.jl icon indicating copy to clipboard operation
Pluto.jl copied to clipboard

Abbreviated stack traces

Open cstjean opened this issue 1 year ago โ€ข 4 comments

Julia 1.10 introduced abbreviated stack traces at the REPL, where some of type information is omitted (printed as ...), eg.

image

This is critical for working with parametric-type-enthusiastic packages, like ModelingToolkit.jl. I frequently get stack traces which are over a hundred pages long in Pluto, whereas at the REPL it is a few pages at most. The above renders as

image

(though this is not a great example of the problem, sorry).

Is there a way to get REPL-like abbreviated stack traces in Pluto?

Note: I'm on Pluto 1.19.42, apologies if this has been fixed since.

cstjean avatar Aug 20 '24 01:08 cstjean

Thanks @cstjean! Let's implement it in Pluto!

The first step here is to figure out how this is done in the REPL. Maybe you can find it by searching the Julia source code for the ยท (middle dot) character, or you could find the Pull Request in julialang/julia that added this feature. Comment on this issue to report your findings.

The second step is to add it to Pluto! We need to modify the function pretty_stackcall in this file: https://github.com/fonsp/Pluto.jl/blob/main/src/runner/PlutoRunner/src/display/Exception.jl

Check out https://github.com/fonsp/Pluto.jl/tree/main/src/runner/PlutoRunner#development-tip when working on this issue!

fonsp avatar Aug 24 '24 17:08 fonsp

I'm 99% sure the PR and relevant function is in https://github.com/JuliaLang/julia/pull/49795/files#diff-c616894fef3ba781d1e1cf77a08e69f366ffd9e5b1cfe1220e7bdae85377e0b2R2537. Given that it merely parses the stacktrace's String and returns a String, it should be straight-forward. The main issue might be Some type information was truncated. Use show(err) to see complete types. This works fine at the REPL, but it's not very Pluto-esque. Ideally, it'd be nice to be able to click on an stacktrace line to see the full parametric type (as in the tree-viewer), but that's maybe a lot of work.

I unfortunately cannot contribute to open-source given my present employment, but it may change in the future...

cstjean avatar Aug 27 '24 02:08 cstjean

Clicking to see more is definitely possible! Not too hard to implement.

We can start by showing just the truncated stack frame.

Later, we can implement clicking-to-see-more by adding both versions (:call and :call_full) to this dictionary. In the frontend, it's a simple mechanism to handle the click.

fonsp avatar Aug 27 '24 08:08 fonsp

@cstjean Could you also post a snippet of code that generates a very long stack trace?

EDIT this one is used by the Julia tests, check the difference between Pluto and REPL:

# โ•”โ•โ•ก 6ed41642-644b-11ef-1190-8ddd8aa72d7c
begin
	
	struct F49231{a,b,c,d,e,f,g} end
	(::F49231)(a,b,c) = error("oops")
end

# โ•”โ•โ•ก ffe76e2f-60b1-4da9-a165-a40d14364db2
F49231{Vector,Val{'}'},Vector{Vector{Vector{Vector}}},Tuple{Int,Int,Int,Int,Int,Int,Int},Int,Int,Int}()(1,2,3)

fonsp avatar Aug 27 '24 08:08 fonsp

@cstjean If you have more ideas please let us know!

fonsp avatar Oct 04 '24 15:10 fonsp