quarto-dev / quarto-cli

Open-source scientific and technical publishing system built on Pandoc.
https://quarto.org
Other
3.81k stars 309 forks source link

Script files not picked up by julia engine #10034

Open jkrumbiegel opened 3 months ago

jkrumbiegel commented 3 months ago

Bug description

It appears that julia script files do not get sent to the julia engine even if specifying engine: julia in the frontmatter. Instead, they are run by the jupyter engine.

Steps to reproduce

I tried quarto render testfile.jl where testfile.jl had this content:

# %% [markdown]
# ---
# engine: julia
# ---

# %%
println("the result is $(1 + 1)")

Expected behavior

Julia engine would try to render this file

Actual behavior

Jupyter engine rendered the file.

Your environment

No response

Quarto check output

Quarto 1.5.40
[✓] Checking versions of quarto binary dependencies...
      Pandoc version 3.2.0: OK
      Dart Sass version 1.70.0: OK
      Deno version 1.41.0: OK
      Typst version 0.11.0: OK
[✓] Checking versions of quarto dependencies......OK
[✓] Checking Quarto installation......OK
      Version: 1.5.40
      Path: /Applications/quarto/bin

[✓] Checking tools....................OK
      TinyTeX: v2024.03
      Chromium: (not installed)

[✓] Checking LaTeX....................OK
      Using: TinyTex
      Path: /Users/krumbiegel/Library/TinyTeX/bin/universal-darwin
      Version: 2023

[✓] Checking basic markdown render....OK

[✓] Checking Python 3 installation....OK
      Version: 3.12.2 (Conda)
      Path: /Users/krumbiegel/miniconda3/bin/python
      Jupyter: 5.5.0
      Kernels: julia-1.10, julia-1.8, julia-1.7, python3

[✓] Checking Jupyter engine render....OK

[✓] Checking R installation...........OK
      Version: 4.3.2
      Path: /Library/Frameworks/R.framework/Resources
      LibPaths:
        - /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/library
      knitr: 1.45
      rmarkdown: 2.26

[✓] Checking Knitr engine render......OK
cderv commented 3 months ago

For the context, currently those files are claimed by Jupyter engine https://github.com/quarto-dev/quarto-cli/blob/d5edb79404188308630370617c8d7a3f14d2de33/src/execute/jupyter/jupyter.ts#L148-L151

and Julia claims no file https://github.com/quarto-dev/quarto-cli/blob/d5edb79404188308630370617c8d7a3f14d2de33/src/execute/julia.ts#L66

This is probably not clear in our doc, but as of now when using script as input to render, the engine option in those file is not used and this is too late - the file has already been claimed by an engine.

Does Julia engine support same Percent script syntax from Jupytext ? https://jupytext.readthedocs.io/en/latest/formats-scripts.html

Currently, we do detect .py and check if it has percent syntax. If so, Jupyter engine claims it.

If the same file could also be working for Julia engine, I think we should indeed parse the file header and detect the engine: julia specification t know which engine is claiming the file

jkrumbiegel commented 3 months ago

I did not add any claimsFile as the assumption was that the previous behavior with the jupyter backend should not be impacted. Otherwise I would've claimed normal julia codeblocks in a .qmd file as well.

Does Julia engine support same Percent script syntax from Jupytext

Yes, we do have support for that style

cderv commented 3 months ago

Thanks for the confirmation.

When we added Jupyter Percent Script support, we only associated it with the Jupyter engine, no matter is content.

So, we definitely need to adapt the claimFiles for Jupyter so that the Julia engine can also claim the .jl script. I would say

For comparaison, engine: knitr does not support the same syntax of percent script. So any .R file with Percent script syntax will be claimed by Jupyter and not knitr engine.

Thanks for the report !

jkrumbiegel commented 3 months ago

one question, when you process such a script file, what does target.markdown contain in the end? A markdown transformation or the original script? Or would that not be set at all in that case, because the source is not markdown

cderv commented 3 months ago

Yes it will contain a markdown transformation. We process the script in Quarto to create a Markdown version

It happens in this function https://github.com/quarto-dev/quarto-cli/blob/68cc8cb80d712022439e6460e81f31fe9c5be697/src/execute/jupyter/percent.ts#L33-L90

that we call in our jupyter engine functions producing markdown