Skip to content
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

IPython.display.JSON doesn't render #10938

Open
multimeric opened this issue Oct 1, 2024 · 4 comments
Open

IPython.display.JSON doesn't render #10938

multimeric opened this issue Oct 1, 2024 · 4 comments
Labels
enhancement New feature or request jupyter
Milestone

Comments

@multimeric
Copy link

Bug description

No response

Steps to reproduce

---
engine: jupyter
---

```{python}
from IPython.display import Markdown, display, JSON

display(JSON({
  "first_name": "John",
  "last_name": "Smith",
  "is_alive": True,
  "age": 27,
  "address": {
    "street_address": "21 2nd Street",
    "city": "New York",
    "state": "NY",
    "postal_code": "10021-3100"
  },
  "phone_numbers": [
    {
      "type": "home",
      "number": "212 555-1234"
    },
    {
      "type": "office",
      "number": "646 555-4567"
    }
  ],
  "children": [
    "Catherine",
    "Thomas",
    "Trevor"
  ],
  "spouse": None
}, expanded = False))
```

Expected behavior

JSON() should result in an interactive JSON widget

Actual behavior

Prints:

<IPython.core.display.JSON object>

Your environment

No response

Quarto check output

Quarto 1.4.554
[✓] Checking versions of quarto binary dependencies...
      Pandoc version 3.1.11: OK
      Dart Sass version 1.69.5: OK
      Deno version 1.37.2: OK
[✓] Checking versions of quarto dependencies......OK
[✓] Checking Quarto installation......OK
      Version: 1.4.554
      Path: /Users/milton.m/Applications/quarto/bin

[✓] Checking tools....................OK
      TinyTeX: v2023.09
      Chromium: (not installed)

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

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

[✓] Checking Python 3 installation....OK
      Version: 3.9.16 (Conda)
      Path: /opt/anaconda3/bin/python
      Jupyter: 4.11.1
      Kernels: bash, python3

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

[✓] Checking R installation...........OK
      Version: 4.4.1
      Path: /opt/homebrew/Cellar/r/4.4.1/lib/R
      LibPaths:
        - /opt/homebrew/lib/R/4.4/site-library
        - /opt/homebrew/Cellar/r/4.4.1/lib/R/library
      knitr: 1.48
      rmarkdown: 2.28

[✓] Checking Knitr engine render......OK
@multimeric multimeric added the bug Something isn't working label Oct 1, 2024
@mcanouil
Copy link
Collaborator

mcanouil commented Oct 1, 2024

Could you upgrade to the latest stable version of Quarto (or possibly the latest pre-release)?
And more generally, ensure your libraries are up to date.

@multimeric
Copy link
Author

Sure. I updated everything and the issue remains:

Quarto 1.5.57
[✓] 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.57
      Path: /Users/milton.m/Applications/quarto/bin

[✓] Checking tools....................OK
      TinyTeX: v2023.09
      Chromium: (not installed)

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

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

[✓] Checking Python 3 installation....OK
      Version: 3.12.5
      Path: /private/var/folders/q5/fvpyppm924525yl9m3xpgjm400031g/T/tmp.5ztZLMyyQn/venv/bin/python3
      Jupyter: 5.7.2
      Kernels: python3, bash

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

[✓] Checking R installation...........OK
      Version: 4.4.1
      Path: /opt/homebrew/Cellar/r/4.4.1/lib/R
      LibPaths:
        - /opt/homebrew/lib/R/4.4/site-library
        - /opt/homebrew/Cellar/r/4.4.1/lib/R/library
      knitr: 1.48
      rmarkdown: 2.28

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

@cderv
Copy link
Collaborator

cderv commented Oct 1, 2024

Thanks for the report.

JSON() should result in an interactive JSON widget

To illustrate this, this is what we can see in Jupyter Lab
Arc_aRgqtIzSbS

And in Jupyter notebook, it seems we get the same
image

despite an issue on this reported upstream

Inside VSCODE, with Jupyter support, it does not seem to be supported either but at least it is seen as a JSON string
image

Rendering this .ipynb file with computed results gets us
image

So Quarto, through nbconvert, does not know yet how to handle this IPython.display.JSON. We would need to come up with a specific support.

This is a feature request IMO that we need to investigate to decide what could be done. We could at least print as a JSON string (minify or prettify)

@cderv cderv added enhancement New feature or request jupyter and removed bug Something isn't working labels Oct 1, 2024
@cderv cderv added this to the Future milestone Oct 1, 2024
@cderv
Copy link
Collaborator

cderv commented Oct 1, 2024

I believe the rendering is done through the JSON extension made available in Jupyter Lab
This extension:

Maybe this can be leveraged in quarto 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request jupyter
Projects
None yet
Development

No branches or pull requests

3 participants