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

Julia fails when saving an animation (Jupyer -> Markdown)

Open cpfiffer opened this issue 4 years ago • 14 comments

Julia essentially locks up when trying to render a Jupyter notebook with an animation through weave. I am also unable to send a SIGTERM with the keyboard, and I have to externally kill Julia. Here's a MWE:

Weave script:

using Weave

Weave.weave("fail_test.ipynb")

I've attached the notebook fail_test.ipynb in a zip file here: fail_test.zip

The contents of the notebook are probably easier to copy than to unzip from the file, so you can also just copy the code below into a Jupyter cell:

using Plots

animation = @gif for i in 1:100
    plot(i, i)
end

The console log:

[ Info: Weaving chunk 1 from line 0
┌ Info: Saved animation to
└   fn = "/tmp/jl_SZA4Ej.gif"
# Then we wait forever, cannot send

Environment, with Julia 1.3.1:

    Status `~/code/TuringTutorials/fail-test/Project.toml`
  [91a5bcdd] Plots v0.29.7
  [f3b207a7] StatsPlots v0.14.1
  [44d3d7a6] Weave v0.9.3

cpfiffer avatar Mar 14 '20 18:03 cpfiffer

I noticed I was using 0.9.3, not 0.9.4. Sorry for the noise, everyone.

cpfiffer avatar Mar 23 '20 14:03 cpfiffer

I'm re-opening this because it doesn't seem to be fixed with 0.9.4 in a consistent way.

Status

Status `~/code/TuringTutorials/fail-test/Project.toml`
  [91a5bcdd] Plots v0.29.8
  [44d3d7a6] Weave v0.9.4

Jupyter cell:

using Plots

animation = @gif for i in 1:10
    plot(i, i)
end

Code to weave everything:

using Weave

Weave.weave("fail_test.ipynb", mod=Main)

Any ideas?

cpfiffer avatar Mar 27 '20 00:03 cpfiffer

The issue also exists for standard figures when GR is the plotting backend.

Jupyter cell:

using Plots
plot(1:10, 1:10)

fails when weaved using:

using Weave
Weave.weave("fail_test.ipynb", mod=Main)

This fails on my computer running Julia-1.4 with:

(trying) pkg> st
Project trying v0.1.0
Status `/tmp/trying/Project.toml`
  [91a5bcdd] Plots v0.29.8
  [44d3d7a6] Weave v0.9.4

And it fails in such a way that it freezes on evaluating the cell, and then I see the CPU-usage for the julia process vanish :confused:

torfjelde avatar Mar 27 '20 01:03 torfjelde

Can you try using Plots before you weave ? Weave needs to load a specific script to handle these plot specific issues, it loads the script only when Plots is already loaded.

aviatesk avatar Mar 27 '20 01:03 aviatesk

Same issue if I load Plots first.

cpfiffer avatar Mar 27 '20 01:03 cpfiffer

Does this issue only happen whey you weaveing a notebook ? You can't reproduce it with the other formats like .jmd or such ?

aviatesk avatar Mar 27 '20 01:03 aviatesk

Seems to be fine if you weave from .jmd.

cpfiffer avatar Mar 27 '20 01:03 cpfiffer

I couldn't reproduce this issue on my environment. One possible cause would be that your OS may prevent making/removing a temporary directory that Weave creates for generating figures while weaveing. But 🤷‍♂

It would be helpful if you could tell me the exact timing when the freeze happens; before execution of chunks, during that, or after that ?

aviatesk avatar Mar 27 '20 09:03 aviatesk

During the chunk weaving. If I have multiple chunks and one has an animation, weaving stops at the chunk with the animation.

I'm running Pop_OS! (Ubuntu clone) and I don't think it's a temporary directory issue, as regular plots work fine for me.

cpfiffer avatar Mar 27 '20 13:03 cpfiffer

As a side note on your fix in #296, it's probably not going to help us much since Turing uses Weave to generate markdown files from our tutorial notebooks.

cpfiffer avatar Mar 27 '20 13:03 cpfiffer

okay fair enough. so even weave(yournotebook, doctype = "github") or weave(yournotebook, doctype = "md2html") doesn't work ?

aviatesk avatar Mar 27 '20 13:03 aviatesk

We currently use doctype="github", but I'll try md2html. Give me a second. For the record, here's the full call Turuing's tutorial builder uses:

                Weave.weave(full_path,
                    doctype = "github",
                    out_path = out_path,
                    mod = Main,
                    throw_errors = true)

cpfiffer avatar Mar 27 '20 13:03 cpfiffer

Yeah, md2html doesn't help either. Same issue.

cpfiffer avatar Mar 27 '20 13:03 cpfiffer

Cool, thanks for the report. Will take a look again on this when I have time, but welcome if anyone wants to help us fix this.

aviatesk avatar Mar 27 '20 14:03 aviatesk