You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Error when export_directory or export_notebook fails #73
Is there a way to know if some cells failed while running export_notebook or export_directory?
When running PlutoSliderServer.jl on CI, it would be good to know if the build worked or not
Reacted by Wen Wei Tseng, Misha Mikhasenko, Remco de Boer, Fons van der Plas, Guillaume Dalle and Filippos Christou
For what it's worth I have written my own small printing function that shows which notebooks failed and with which errors:
"""Given a selection of notebooks, check individually for each notebook if there are any cells that errored.If it is the case print out, for each notebook, the content of the failing cellsand the output messages."""functioncheck_for_failed_notebooks(result::NamedTuple)
failed_notebooks =Dict{String, Vector}()
# notebook session is a `NotebookSession` from PlutoSliderServer.jl.for notebook_session in result.notebook_sessions
# Check for every notebook that no cell errored.# State is a large JSON style `Dict` containing all the informations about the ran notebook.# You can find the definition in Pluto.jl/src/webserver/Dynamic.jl/notebook_to_js.
state = notebook_session.run.original_state
errored_cells =findall(cell -> cell["errored"], state["cell_results"])
isempty(errored_cells) &&continue
failed_notebooks[notebook_session.path] = [
(input = state["cell_inputs"][id]["code"], output = state["cell_results"][id]["output"]["body"][:msg]) for
id insort(errored_cells; by = id ->findfirst(==(id), state["cell_order"]))
]
endif!isempty(failed_notebooks)
io =IOBuffer()
for (key, cells) inpairs(failed_notebooks)
printstyled(IOContext(io, :color=>true), "$key:\n"; bold =true, color =:green, underline =true)
for (input, output) in cells
printstyled(IOContext(io, :color=>true), "• $input"; color =:blue)
print(io, " => ")
printstyled(IOContext(io, :color=>true), "$output\n"; color =:red)
endprintln(io)
end
error_msgs =String(take!(io))
error(
"The following Pluto notebook",
length(failed_notebooks) >1?"s":"",
" failed to run successfully: $(keys(failed_notebooks))\n\n",
error_msgs,
)
endend
This is to be passed to export_directory as the on_ready kwarg.
I made the package from my last comment to allow more granular checking (allow some cells to error), and to check for more things like broken URLs.
But maybe we can also add a simple throw_on_cell_error option to PSS that just crashes everything once a single cell has an error? And then PlutoNotebookComparison can be used for more options? WDYT?
But maybe we can also add a simple throw_on_cell_error option to PSS that just crashes everything once a single cell has an error? And then PlutoNotebookComparison can be used for more options? WDYT?
Problem here is that when the failure happens on CI it is not necessarily easy to reproduce locally. It would already be good to report what the failure was.
Activity
filchristou commentedon Sep 20, 2023
btw PlutoStaticHTML.jl already support this. I am not sure how easily the same solution can be integrated here though..
theogf commentedon Mar 12, 2024
For what it's worth I have written my own small printing function that shows which notebooks failed and with which errors:
This is to be passed to
export_directoryas theon_readykwarg.fonsp commentedon Mar 7, 2025
I started working on this in https://github.com/JuliaPluto/PlutoNotebookComparison.jl :)
This PR is using the new package: bmlip/course#20
fonsp commentedon Mar 17, 2026
I made the package from my last comment to allow more granular checking (allow some cells to error), and to check for more things like broken URLs.
But maybe we can also add a simple
throw_on_cell_erroroption to PSS that just crashes everything once a single cell has an error? And then PlutoNotebookComparison can be used for more options? WDYT?theogf commentedon Mar 17, 2026
Problem here is that when the failure happens on CI it is not necessarily easy to reproduce locally. It would already be good to report what the failure was.