Open Seally opened 10 months ago
Same issue here. Looking at the dev tools I see these errors
VS Code: 1.85.1 OS: Ubuntu 20.04.1
@DonJayamanne since i've been pointed here, may i ask pointers on where to look for in order to fix this issue? I'm interested in opening a PR.
bumping this. It seems like it's using an unmaintained package for handling the datatype.
@DonJayamanne Could we just drop support for this mimetype and let vscode-jupyter fall back to text/html
Hello, I'm not sure if my comment will be helpful. I recently discovered Azure Data Studio, which is based on Microsoft's VS Code, and used it for a day. I noticed that the Notebook feature in Azure Data Studio outputs SQL query results in a grid format. When I open the resulting .ipynb file in VS Code, the vscode-notebook-renderers extension is set to render the application/vnd.dataresource+json mimetype. If I use the built-in notebook output renderer in VS Code to display it as text/html, it renders correctly. However, it doesn't look as nice as it does in Azure Data Studio.
in VS Code
in Azure Data Studio
So, I would like to see support for the application/vnd.dataresource+json mimetype in VS Code, similar to Azure Data Studio.
Thank you!
So, I would like to see support for the application/vnd.dataresource+json mimetype in VS Code, similar to Azure Data Studio.
@soonbro Technically, vscode-notebook-renderers
claims to support application/vnd.dataresource+json
on this line:
The problem is that it doesn't work (last I checked). The fact that it lists this at all is why we're getting the blank output. Otherwise, rendering it wouldn't even be an option and only the text/html
render will be listed.
I haven't looked too deeply into why it doesn't work. I know this plugin uses some ancient libraries which are no longer maintained. Some aren't even the latest versions of those libraries. Many of the libraries come from the nteract
project. In this case, the package with the issue is @nteract/transform-dataresource
. I will also add @nteract/data-explorer
exists, which seems to be its replacement. It too looks abandoned, but it's still 3 years newer. Also, if I recall correctly, the renderer for application/vnd.dataresource+json
in the nteract desktop application does work, which I assume is using data-explorer
since the project has it as a dependency and imports it here:
For Deno I use the following workaround display function:
// Strip `application/vnd.dataresource+json` from Jupyter display bundle.
// Workaround for: https://github.com/microsoft/vscode-notebook-renderers/issues/189
export const vscd = async (
obj: unknown,
options: { raw: boolean; update: boolean; display_id?: string } = { raw: false, update: false }
): Promise<void> => {
const bundle = (await (obj as any)[Symbol.for('Jupyter.display')]?.()) ?? {};
const { 'application/vnd.dataresource+json': _json, ...strippedBundle } = bundle;
const message_type = options.update ? 'update_display_data' : 'display_data';
const transient = options.display_id ? { display_id: options.display_id } : {};
Deno.jupyter.broadcast(message_type, { data: strippedBundle, metadata: {}, transient });
return;
};
and then wrap the object I want to display in vscd(obj)
. e.g. using nodejs-polars
this will then output the HTML table instead.
I guess the same workaround can be done with other kernels as well.
I first discovered this issue while trying to use
nodejs-polars
in a Deno Jupyter kernel. Here's the example code for a notebook cell in Python:Using the
text/html
presentation works fine. But theapplication/vnd.dataresource+json
presentation does not, and produces basically nothing:VS Code version: 1.85.1 Extension version: 1.0.17 OS: Windows 10