jupytext icon indicating copy to clipboard operation
jupytext copied to clipboard

writing a qmd in IPython or jupyterlab prints a validation error

Open machow opened this issue 3 years ago • 1 comments

Hello, when I open a qmd paired with a ipynb in jupyter lab, and then attempt to save it, I get this error:

    Failed validating 'additionalProperties' in code_cell:

    On instance['cells'][1]:
    {'cell_type': 'code',
     'execution_count': None,
     'id': 'd5614329',
     'metadata': {},
     'outputs': ['...0 outputs...'],
     'source': '#| output: true\n1 + 1'}

It looks like some validation process run by nbformat (?) is logging an error for v4.4 notebooks. For example, if I run this code in IPython it works, but prints the same error as above (note that no error message occurs in the regular python repl):

from jupytext import reads, writes

nb = reads("""
---
title: Some title
jupyter:
  jupytext:
    formats: 'qmd:quarto,ipynb'
    text_representation:
      extension: .qmd
      format_name: quarto
      format_version: '1.0'
      jupytext_version: 1.14.1
  kernelspec:
    display_name: Python 3 (ipykernel)
    language: python
    name: python3
---

```{python}
#| output: true
1 + 1
```
""")

writes(nb, fmt="qmd")

I noticed that quarto convert by default doesn't use v4.5, but it can with a --with-ids flag (code here). I wonder if one way to avoid this printed error is if (for quarto versions that support it) we use the flag to save notebooks as v4.5?

I tested with a few different versions of nbformat (including down to 5.1.3), but wasn't able to get rid of the message.

machow avatar Oct 14 '22 16:10 machow

Hi @machow , thank you for reporting this.

Well I am seeing a similar issue on our CI at #1002. I think we have two options here:

  1. You could downgrade the version of nbformat. To make sure that you're using the version you think you are, I would suggest that you print nbformat.__version__ in the same Python env where you are able to reproduce the issue. Then you'll need to do the same in your Jupyter environment.
  2. You could also report the issue at https://github.com/quarto-dev/quarto-cli/, where the actual qmd to ipynb converter is maintained.

mwouts avatar Oct 29 '22 16:10 mwouts