microsoft / vscode-jupyter

VS Code Jupyter extension
https://marketplace.visualstudio.com/items?itemName=ms-toolsai.jupyter
MIT License
1.3k stars 293 forks source link

Altair (vegalite beneath the hood, I think?) plots not appearing in native interactive window #7377

Closed nickeubank closed 3 years ago

nickeubank commented 3 years ago

Environment data

Expected behaviour

Altair chart to appear in interactive window

Actual behaviour

Doesn't appear. If you switch the Mimetype to text/plain then back to text/HTML, it does appear. Works fine in notebook.

Steps to reproduce:

Run this code:


import pandas as pd

# Download World Development Indicators
wdi = pd.read_csv(
    "https://media.githubusercontent.com/media/nickeubank/"
    "MIDS_Data/master/World_Development_Indicators/wdi_small_tidy_2015.csv"
)

# Plot
import altair as alt

my_chart = (
    alt.Chart(wdi)
    .mark_circle(size=50)
    .encode(
        x="GDP per capita (constant 2010 US$)",
        y="Mortality rate, under-5 (per 1,000 live births)",
        tooltip=["Country Name"],
    )
    .interactive()
)
my_chart

interactive_plot_failure_mwe.py.zip

interactive_no_plot

Logs

Output for Jupyter in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Jupyter)

``` Started kernel Python 3.9.6 64-bit ('base': conda) Info 2021-09-01 14:23:48: Initial setup for vscode-interactive:Interactive-1.interactive starting ... Info 2021-09-01 14:23:48: UpdateWorkingDirectoryAndPath Info 2021-09-01 14:23:48: Kernel switching to busy Info 2021-09-01 14:23:48: Kernel switching to idle Info 2021-09-01 14:23:48: Kernel switching to busy Info 2021-09-01 14:23:48: Kernel switching to idle Info 2021-09-01 14:23:48: Initial setup complete for vscode-interactive:Interactive-1.interactive Info 2021-09-01 14:23:48: Finished connecting 271e106e-2485-4f22-b0ea-3ffbe3081910 Info 2021-09-01 14:23:48: Widget Coordinator sent IPyWidgets_kernelOptions Info 2021-09-01 14:23:48: Posting message to Notebook UI Info 2021-09-01 14:23:48: Registering commtarget jupyter.widget Info 2021-09-01 14:23:48: IPyWidgetMessageDispatcher.initialize Info 2021-09-01 14:23:48: Widget Coordinator sent IPyWidgets_mirror_execute Info 2021-09-01 14:23:48: Posting message to Notebook UI Info 2021-09-01 14:23:48: IPyWidgetScriptSource.initialize Info 2021-09-01 14:23:48: IPyWidgetMessageDispatcher.initialize Info 2021-09-01 14:23:48: Widget Coordinator sent IPyWidgets_msg Info 2021-09-01 14:23:48: Posting message to Notebook UI Info 2021-09-01 14:23:48: Widget Coordinator sent IPyWidgets_msg Info 2021-09-01 14:23:48: Posting message to Notebook UI Info 2021-09-01 14:23:48: Kernel switching to busy Info 2021-09-01 14:23:48: Notebook Session status vscode-interactive:Interactive-1.interactive # Busy Info 2021-09-01 14:23:48: Widget Coordinator received IPyWidgets_registerCommTarget Info 2021-09-01 14:23:48: Widget Coordinator received IPyWidgets_registerCommTarget Info 2021-09-01 14:23:48: Widget Coordinator received IPyWidgets_msg_received Info 2021-09-01 14:23:48: IPyWidgetMessageDispatcher.initialize Info 2021-09-01 14:23:48: IPyWidgetMessageDispatcher.initialize Info 2021-09-01 14:23:48: Widget Coordinator sent IPyWidgets_msg Info 2021-09-01 14:23:48: Posting message to Notebook UI Info 2021-09-01 14:23:48: Kernel switching to idle Info 2021-09-01 14:23:48: Notebook Session status vscode-interactive:Interactive-1.interactive # Idle Info 2021-09-01 14:23:48: Widget Coordinator sent IPyWidgets_msg Info 2021-09-01 14:23:48: Posting message to Notebook UI Info 2021-09-01 14:23:48: UpdateWorkingDirectoryAndPath Info 2021-09-01 14:23:48: Widget Coordinator received IPyWidgets_msg_received Info 2021-09-01 14:23:48: Widget Coordinator received IPyWidgets_iopub_msg_handled Info 2021-09-01 14:23:48: Widget Coordinator received IPyWidgets_msg_received Info 2021-09-01 14:23:48: Widget Coordinator received IPyWidgets_iopub_msg_handled Info 2021-09-01 14:23:48: Widget Coordinator received IPyWidgets_msg_received Info 2021-09-01 14:23:48: Widget Coordinator received IPyWidgets_iopub_msg_handled Info 2021-09-01 14:23:48: Widget Coordinator received IPyWidgets_msg_received Info 2021-09-01 14:23:48: changeDirectoryIfPossible Info 2021-09-01 14:23:48: Widget Coordinator sent IPyWidgets_mirror_execute Info 2021-09-01 14:23:48: Posting message to Notebook UI Info 2021-09-01 14:23:48: Widget Coordinator received IPyWidgets_msg_received Info 2021-09-01 14:23:48: Widget Coordinator sent IPyWidgets_msg Info 2021-09-01 14:23:48: Posting message to Notebook UI Info 2021-09-01 14:23:48: Kernel switching to busy Info 2021-09-01 14:23:48: Notebook Session status vscode-interactive:Interactive-1.interactive # Busy Info 2021-09-01 14:23:48: Widget Coordinator sent IPyWidgets_msg Info 2021-09-01 14:23:48: Posting message to Notebook UI Info 2021-09-01 14:23:48: Widget Coordinator sent IPyWidgets_msg Info 2021-09-01 14:23:48: Posting message to Notebook UI Info 2021-09-01 14:23:48: Widget Coordinator received IPyWidgets_msg_received Info 2021-09-01 14:23:48: Widget Coordinator received IPyWidgets_iopub_msg_handled Info 2021-09-01 14:23:48: Widget Coordinator received IPyWidgets_msg_received Info 2021-09-01 14:23:48: Widget Coordinator received IPyWidgets_iopub_msg_handled Info 2021-09-01 14:23:48: Widget Coordinator sent IPyWidgets_msg Info 2021-09-01 14:23:48: Posting message to Notebook UI Info 2021-09-01 14:23:48: Kernel switching to idle Info 2021-09-01 14:23:48: Notebook Session status vscode-interactive:Interactive-1.interactive # Idle Info 2021-09-01 14:23:48: Widget Coordinator sent IPyWidgets_msg Info 2021-09-01 14:23:48: Posting message to Notebook UI Info 2021-09-01 14:23:48: Widget Coordinator sent IPyWidgets_mirror_execute Info 2021-09-01 14:23:48: Posting message to Notebook UI Info 2021-09-01 14:23:48: Widget Coordinator received IPyWidgets_msg_received Info 2021-09-01 14:23:48: Widget Coordinator received IPyWidgets_iopub_msg_handled Info 2021-09-01 14:23:48: Widget Coordinator received IPyWidgets_msg_received Info 2021-09-01 14:23:48: Widget Coordinator received IPyWidgets_iopub_msg_handled Info 2021-09-01 14:23:48: Widget Coordinator received IPyWidgets_msg_received Info 2021-09-01 14:23:48: Widget Coordinator received IPyWidgets_msg_received Info 2021-09-01 14:23:48: Widget Coordinator sent IPyWidgets_msg Info 2021-09-01 14:23:48: Posting message to Notebook UI Info 2021-09-01 14:23:48: Widget Coordinator sent IPyWidgets_msg Info 2021-09-01 14:23:48: Posting message to Notebook UI Info 2021-09-01 14:23:48: Kernel switching to busy Info 2021-09-01 14:23:48: Notebook Session status vscode-interactive:Interactive-1.interactive # Busy Info 2021-09-01 14:23:48: Widget Coordinator sent IPyWidgets_msg Info 2021-09-01 14:23:48: Posting message to Notebook UI Info 2021-09-01 14:23:48: Kernel switching to idle Info 2021-09-01 14:23:48: Notebook Session status vscode-interactive:Interactive-1.interactive # Idle Info 2021-09-01 14:23:48: Widget Coordinator sent IPyWidgets_msg Info 2021-09-01 14:23:48: Posting message to Notebook UI Info 2021-09-01 14:23:48: Widget Coordinator received IPyWidgets_msg_received Info 2021-09-01 14:23:48: Widget Coordinator received IPyWidgets_iopub_msg_handled Info 2021-09-01 14:23:48: Widget Coordinator received IPyWidgets_msg_received Info 2021-09-01 14:23:48: Widget Coordinator received IPyWidgets_iopub_msg_handled Info 2021-09-01 14:23:48: Widget Coordinator received IPyWidgets_msg_received Info 2021-09-01 14:23:48: Widget Coordinator received IPyWidgets_iopub_msg_handled Info 2021-09-01 14:23:48: Waiting for idle on (kernel): 426902a7-37f1-452e-a388-d2cce5767320 -> idle Info 2021-09-01 14:23:48: Finished waiting for idle on (kernel): 426902a7-37f1-452e-a388-d2cce5767320 -> idle Info 2021-09-01 14:23:49: Widget Coordinator received IPyWidgets_msg_received Info 2021-09-01 14:23:49: UpdateWorkingDirectoryAndPath Info 2021-09-01 14:23:49: Widget Coordinator sent IPyWidgets_mirror_execute Info 2021-09-01 14:23:49: Posting message to Notebook UI Info 2021-09-01 14:23:49: Widget Coordinator sent IPyWidgets_msg Info 2021-09-01 14:23:49: Posting message to Notebook UI Info 2021-09-01 14:23:49: Widget Coordinator sent IPyWidgets_msg Info 2021-09-01 14:23:49: Posting message to Notebook UI Info 2021-09-01 14:23:49: Kernel switching to busy Info 2021-09-01 14:23:49: Widget Coordinator sent IPyWidgets_msg Info 2021-09-01 14:23:49: Posting message to Notebook UI Info 2021-09-01 14:23:49: Notebook Session status vscode-interactive:Interactive-1.interactive # Busy Info 2021-09-01 14:23:49: Kernel switching to idle Info 2021-09-01 14:23:49: Notebook Session status vscode-interactive:Interactive-1.interactive # Idle Info 2021-09-01 14:23:49: Widget Coordinator sent IPyWidgets_msg Info 2021-09-01 14:23:49: Posting message to Notebook UI Info 2021-09-01 14:23:49: Adding hash for 1 = 9e88cef7578d with 23 lines Info 2021-09-01 14:23:49: Widget Coordinator sent IPyWidgets_mirror_execute Info 2021-09-01 14:23:49: Posting message to Notebook UI Info 2021-09-01 14:23:49: Widget Coordinator received IPyWidgets_msg_received Info 2021-09-01 14:23:49: Widget Coordinator sent IPyWidgets_msg Info 2021-09-01 14:23:49: Posting message to Notebook UI Info 2021-09-01 14:23:49: Widget Coordinator sent IPyWidgets_msg Info 2021-09-01 14:23:49: Posting message to Notebook UI Info 2021-09-01 14:23:49: Kernel switching to busy Info 2021-09-01 14:23:49: Notebook Session status vscode-interactive:Interactive-1.interactive # Busy Info 2021-09-01 14:23:49: Widget Coordinator received IPyWidgets_msg_received Info 2021-09-01 14:23:49: Widget Coordinator received IPyWidgets_iopub_msg_handled Info 2021-09-01 14:23:49: Widget Coordinator received IPyWidgets_msg_received Info 2021-09-01 14:23:49: Widget Coordinator received IPyWidgets_iopub_msg_handled Info 2021-09-01 14:23:49: Widget Coordinator received IPyWidgets_msg_received Info 2021-09-01 14:23:49: Widget Coordinator received IPyWidgets_iopub_msg_handled Info 2021-09-01 14:23:49: Widget Coordinator received IPyWidgets_msg_received Info 2021-09-01 14:23:49: Widget Coordinator received IPyWidgets_msg_received Info 2021-09-01 14:23:49: Widget Coordinator received IPyWidgets_msg_received Info 2021-09-01 14:23:49: Widget Coordinator received IPyWidgets_iopub_msg_handled Info 2021-09-01 14:23:49: Widget Coordinator received IPyWidgets_msg_received Info 2021-09-01 14:23:49: Widget Coordinator received IPyWidgets_iopub_msg_handled Info 2021-09-01 14:23:51: Widget Coordinator sent IPyWidgets_msg Info 2021-09-01 14:23:51: Posting message to Notebook UI Info 2021-09-01 14:23:51: Widget Coordinator sent IPyWidgets_msg Info 2021-09-01 14:23:51: Posting message to Notebook UI Info 2021-09-01 14:23:51: Kernel switching to idle Info 2021-09-01 14:23:51: Notebook Session status vscode-interactive:Interactive-1.interactive # Idle Info 2021-09-01 14:23:51: Widget Coordinator sent IPyWidgets_msg Info 2021-09-01 14:23:51: Posting message to Notebook UI Info 2021-09-01 14:23:51: Finished execution for 3caab3e6-7062-4834-b3df-0802006862f3 Info 2021-09-01 14:23:52: Widget Coordinator received IPyWidgets_msg_received Info 2021-09-01 14:23:52: Widget Coordinator received IPyWidgets_iopub_msg_handled Info 2021-09-01 14:23:52: Widget Coordinator received IPyWidgets_msg_received Info 2021-09-01 14:23:52: Widget Coordinator received IPyWidgets_iopub_msg_handled Info 2021-09-01 14:23:52: Widget Coordinator received IPyWidgets_msg_received ```

rchiodo commented 3 years ago

Thanks for the bug. This seems to work for me. Might be a timing issue with when we append output though.

nickeubank commented 3 years ago

Saw it with quite a few students in my class doing this as an exercise yesterday, so pretty confident it isn't just me, even if it is intermittent. :/

rchiodo commented 3 years ago

Oh actually this works for me in insiders. In stable VS code I repro the bug you have. This looks like it's been fixed in the last month.

nickeubank commented 3 years ago

Wonderful, thanks!

rchiodo commented 3 years ago

New stable VS code version is coming out today? Tomorrow maybe.