-
Notifications
You must be signed in to change notification settings - Fork 331
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
include shortcode in computation code cell are not resolved for julia engine #10008
include shortcode in computation code cell are not resolved for julia engine #10008
Comments
I believe this is a cell source output backticks problem. Here is the intermediate outputs: ---
title: test
engine: julia
keep-md: true
format:
gfm: default
---
::: {.cell execution_count=0}
``` {.julia .cell-code}
"""
```python
1 + 1
```
"""
```
:::
We can see the the fenced code cell for source output does use only ```` backticks when initially it was 4. I guess not all engine handle nested backticks for code cells the same. I know knitr handles it for R by computing the number of backticks. No problem with and it seems for Jupyter engine we do handle it also as I can't reproduce with this ---
title: test
keep-md: true
format:
gfm: default
---
````{python}
#| eval: false
{{< include foo.jl >}}
````
So this is linked to new Julia engine that needs to do the same as with Jupyter engine. It may be Quarto and not |
Yes we do count backticks at quarto-cli/src/core/jupyter/jupyter.ts Lines 1422 to 1427 in 50b4cf1
|
It seems this issue does relate to shortcode because this has no issues ---
title: test
engine: julia
keep-md: true
format:
gfm: default
---
````{julia}
#| eval: false
"""
```python
1 + 1
```
"""
```` and produced correct intermediate md ---
title: test
engine: julia
keep-md: true
format:
gfm: default
---
::: {.cell execution_count=0}
```` {.julia .cell-code}
"""
```python
1 + 1
```
"""
````
:::
So just maybe something about timing for resolving shortcodes ... 🤔 |
Thank you for your investigation! |
OK so looking more into it, I do think this is not supported at the moment. @jkrumbiegel @cscheid as you were the one working on it in It seems that Julia engine will use the input source file quarto-cli/src/execute/julia.ts Lines 120 to 126 in 9b77dca
However, our internal processing does create a processed Markdown version of a .qmd file to resolve different things. And this includes shortcode. We resolves includes (more generally cell handler) in a pre-engine phase. quarto-cli/src/command/render/render-contexts.ts Lines 274 to 297 in 9b77dca
This transformed markdown is used in several places like engine resolution quarto-cli/src/execute/engine.ts Lines 167 to 187 in 9b77dca
and used in engine execution. For example for Jupyter engine, we create a .ipynb from a .qmd quarto-cli/src/execute/jupyter/jupyter.ts Lines 291 to 300 in 9b77dca
and we use this target.markdown.value and not the input .qmd filequarto-cli/src/execute/jupyter/jupyter.ts Lines 648 to 655 in 9b77dca
So I believe julia engine should also use this markdown value for its engine execution. It should somehow be passed to QuartoNotebookRunner.jl
I don't know if QuartoNotebookRunner.jl requires only a file a input, or could work also with a markdown passed a string. but the same logic would need to be added. Also I do think this would solve our embed support, which rely also on this transformed markdown content as it is in the handler category; Hope this helps know what to do exactly, either in Quarto code base, or in QuartoNotebookRunner.jl |
Probably I just didn't know that code for this had to be added, I built the julia engine code by copying and editing jupyter engine pieces until all that I needed worked. But I never tested shortcodes. QuartoNotebookRunner takes a filepath as input, so we'd have to write out a temporary file I think. |
I think that could be possible to write an intermediate file that would be removed after execution. Is this is strong requirement that QuartoNotebookRunner takes a file ? Asking because it could either be Quarto julia engine code writing it and removing it (like with Jupyter engine) , or otherwise this would be the QuartoNotebookRunner.jl side if we pass the information encoded as Json string (like with the knitr engine). It could even be base64 encode to be decode on Julia side for easier exchange of information. Not sure what is best. Do you want to work on this and send a PR for review ? Or should we add support for this (on the Quarto side in that case) ? |
Let me pull in @MichaelHatherly. We already get the full options JSON object sent over from quarto to QuartoNotebookRunner, and I think this even contains the complete source as a string if I remember correctly. I assume some string in that object would change if shortcodes were executed correctly, and then we could pick it up from there? |
Yeah, we could just parse from that string in the JSON blob if it's available, otherwise fallback to the file. |
Yes should have the
AFAIK |
@jkrumbiegel Thanks for the quick update, but I tried QuartoNotebookRunner 0.11.2 and it does not seem fixed. |
@eitsupi do you have an MWE? QuartoNotebookRunner just uses the preprocessed markdown from quarto now if it's available, so the question would be what side a possible bug would be on. |
@jkrumbiegel Thanks for your quick reply. What does "MWE" mean? |
MWE: Minimal Working Example |
This is the output I get from the first post here, on QNB 0.11.2, with the latest prerelease
|
Thanks for confirming! |
Could be that an old quarto Julia server process was still running and it picked up that one after updating, so you only thought you'd tested on the correct QNB version. This is something I still want to improve, ideally the server would restart when a new QNB version is detected. |
Closed by #10110 following update of QuartoNotebookRunner |
This indeed happens and is really hard to figure out.
|
Following up on #9984
Sorry, but I think I was confused by all the different things I tried.
Actually there seems to be a bug when using includes in the julia engine executable code block.
test.qmd
foo.jl
output:
If it is not an executable code block, it works fine.
So I suppose this is a bug of
QuartoNotebookRunner.jl
?(The fact that the number of backticks varies from engine to engine was quite an unexpected behavior for me, though.)
Originally posted by @eitsupi in #9984 (comment)
The text was updated successfully, but these errors were encountered: