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

warning: false seems to be ignored

Open dmbates opened this issue 1 year ago • 6 comments

I'm not sure if this is related to QuartoNotebookRunner.jl or occurs downstream. Please let me know if I should report this at https://github.com/quarto-dev/quarto-cli instead.

Rendering the enclosed with Quarto v1.5.31 shows the warning produced by the last code block.

---
engine: julia
---

Define a function that sends a warning

```{julia}
function foo(i::Integer)
    if iszero(i)
        return i
    elseif isone(i)
        @warn "i is one"
        return i
    else
        error("Received i = $i")
    end
    return 0
end
```

```{julia}
#| warning: false
foo(0)
```


```{julia}
#| warning: false
foo(true)
```

The .ipynb file produced is

{
    "metadata": {
        "kernelspec": {
            "display_name": "Julia 1.10.2",
            "language": "julia",
            "name": "julia-1.10.2"
        },
        "kernel_info": {
            "name": "julia"
        },
        "language_info": {
            "name": "julia",
            "version": "1.10.2",
            "codemirror_mode": "julia"
        }
    },
    "nbformat": 4,
    "nbformat_minor": 5,
    "cells": [
        {
            "id": "1",
            "cell_type": "markdown",
            "metadata": {
            },
            "source": [
                "---\n",
                "engine: julia\n",
                "---\n",
                "\n",
                "Define a function that sends a warning"
            ]
        },
        {
            "id": "2",
            "cell_type": "code",
            "metadata": {
            },
            "source": [
                "function foo(i::Integer)\n",
                "    if iszero(i)\n",
                "        return i\n",
                "    elseif isone(i)\n",
                "        @warn \"i is one\"\n",
                "        return i\n",
                "    else\n",
                "        error(\"Received i = $i\")\n",
                "    end\n",
                "    return 0\n",
                "end"
            ],
            "outputs": [
                {
                    "output_type": "execute_result",
                    "execution_count": 1,
                    "data": {
                        "text/plain": "foo (generic function with 1 method)"
                    },
                    "metadata": {
                    }
                }
            ],
            "execution_count": 1
        },
        {
            "id": "3",
            "cell_type": "markdown",
            "metadata": {
            },
            "source": [
            ]
        },
        {
            "id": "4",
            "cell_type": "code",
            "metadata": {
            },
            "source": [
                "#| warning: false\n",
                "foo(0)"
            ],
            "outputs": [
                {
                    "output_type": "execute_result",
                    "execution_count": 1,
                    "data": {
                        "text/plain": "0"
                    },
                    "metadata": {
                    }
                }
            ],
            "execution_count": 1
        },
        {
            "id": "5",
            "cell_type": "markdown",
            "metadata": {
            },
            "source": [
                ""
            ]
        },
        {
            "id": "6",
            "cell_type": "code",
            "metadata": {
            },
            "source": [
                "#| warning: false\n",
                "foo(true)"
            ],
            "outputs": [
                {
                    "output_type": "stream",
                    "name": "stdout",
                    "text": "\u001b[33m\u001b[1m┌ \u001b[22m\u001b[39m\u001b[33m\u001b[1mWarning: \u001b[22m\u001b[39mi is one\n\u001b[33m\u001b[1m└ \u001b[22m\u001b[39m\u001b[90m@ Main.Notebook ~/git/scMixedModels/notebooks/warning/warning.qmd:12\u001b[39m\n"
                },
                {
                    "output_type": "execute_result",
                    "execution_count": 1,
                    "data": {
                        "text/plain": "true"
                    },
                    "metadata": {
                    }
                }
            ],
            "execution_count": 1
        }
    ]
}

dmbates avatar Apr 25 '24 20:04 dmbates

We've not, from what I recall, actually implemented any handling of warning yet. If you run that notebook via the Jupyter backend what's the output you get compared to what this backend is generating?

MichaelHatherly avatar Apr 26 '24 07:04 MichaelHatherly

If I use the Jupyter backend then the warning does not appear in the HTML file, whereas it does when using QuartoNotebookRunner. Do you want me to attach the .html file or the .ipynb file from

quarto convert warning.qmd

dmbates avatar Apr 26 '24 13:04 dmbates

Do you want me to attach the .html file or the .ipynb file from

Yes, that'll likely be useful, thanks.

MichaelHatherly avatar Apr 26 '24 13:04 MichaelHatherly

How would like the files to be made available? It seems that I can't add .html or .ipynb file to a comment. Should I create a repository or a gist or add the files as .txt or ...?

dmbates avatar Apr 26 '24 13:04 dmbates

A gist would probably be simplest.

MichaelHatherly avatar Apr 26 '24 13:04 MichaelHatherly

Apparently I haven't understood the gist of creating gists because it is far from simple for me. I created https://gist.github.com/dmbates/1dbddf22124f839fcfb33785174c066c but it is a mess. Just look at the comment at the bottom. If you put jupyter: julia-1.10 in the yaml header of warning.qmd you don't get the warning in the output of the third code block. If you leave the yaml header as execute: julia the warning shows up in the output of the third code block. In both cases the HTML is produced by

quarto render warning.qmd --to html

using version 1.5.31 of quarto.

I'll try to find some documentation on creating gists. It can't be as unwieldy for others as I find it. The purpose is to provide files of various sorts with explanations but you can't add files other than text files.

dmbates avatar Apr 26 '24 15:04 dmbates

Thanks for addressing this.

dmbates avatar Jul 25 '24 14:07 dmbates