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

New json file at `QUARTO_EXECUTE_INFO` (as per Quarto 1.8.19) not being written

Open remlapmot opened this issue 4 months ago • 6 comments

Thanks for this fantastic engine.

I think the following is a QuartoNotebookRunner.jl issue - but if it's actually something the Quarto CLI should do, do correct me.

I don't whether you've seen that as of Quarto 1.8.19 (in PR https://github.com/quarto-dev/quarto-cli/pull/13171) Quarto writes a json file at the location of the new environment variable QUARTO_EXECUTE_INFO.

This works for engine: knitr, and all of the jupyter: engines I've tried including jupyter: julia-1.11. However, it seems that engine: julia currently fails to write this file.

You can see this with the following simple qmd file.

---
format:
  html:
    embed-resources: true
engine: julia
---

```{julia}
println(ENV["QUARTO_EXECUTE_INFO"])

println(isfile(ENV["QUARTO_EXECUTE_INFO"]))

if isfile(ENV["QUARTO_EXECUTE_INFO"]) 
  import Pkg; Pkg.add("JSON")
  using JSON
  json_string = JSON.parsefile(ENV["QUARTO_EXECUTE_INFO"])
  JSON.print(json_string, 2)
else
  println("The file didn't exist")
end
```

which generates

Image

Compared with say jupyter: julia-1.11 which does write the file.

---
format:
  html:
    embed-resources: true
jupyter: julia-1.11
---
  
```{julia}
println(ENV["QUARTO_EXECUTE_INFO"])

println(isfile(ENV["QUARTO_EXECUTE_INFO"]))

if isfile(ENV["QUARTO_EXECUTE_INFO"]) 
  import Pkg; Pkg.add("JSON")
  using JSON
  json_string = JSON.parsefile(ENV["QUARTO_EXECUTE_INFO"])
  JSON.print(json_string, 2)
end
```

which produces

Image

remlapmot avatar Sep 03 '25 08:09 remlapmot

My intuition is that this is about how QuartoNotebookRunner currently handles environment variables. Check my recent comment here https://github.com/PumasAI/QuartoNotebookRunner.jl/issues/331#issuecomment-3236590910

Maybe the env variable you're reading is old because it's from when the server was starting up. So when you read it later, it's not the one that has been created for this specific run. This would be fixed with https://github.com/PumasAI/QuartoNotebookRunner.jl/pull/306

jkrumbiegel avatar Sep 03 '25 08:09 jkrumbiegel

I think you are correct. Feel free to close this if you prefer. (I might try a run under your PR later.)

remlapmot avatar Sep 03 '25 09:09 remlapmot

We'll leave it open and close once #306 is merged. Thanks for the report.

MichaelHatherly avatar Sep 03 '25 09:09 MichaelHatherly

(just checking in here and saying hi! in case there's something you'd like us to fix for 1.8, since we're in the release candidate stage)

cscheid avatar Sep 03 '25 14:09 cscheid

https://github.com/PumasAI/QuartoNotebookRunner.jl/pull/306 likely can only fix this if https://github.com/quarto-dev/quarto-cli/pull/12621 is merged as well from what I can tell so far since the value of QUARTO_EXECUTE_INFO appears to change on each render call as far as I can tell and the QNR Julia processes gets a "frozen" set of values on initial launch. (#306 itself is ready to go and I'll merge it shortly.)

MichaelHatherly avatar Sep 03 '25 15:09 MichaelHatherly

Ok, that one is too scary to merge in 1.8, but I promise to look it over early in 1.9 (work on which will begin 2-3 weeks from now).

cscheid avatar Sep 03 '25 16:09 cscheid