nbviewer icon indicating copy to clipboard operation
nbviewer copied to clipboard

nbviewer only shows first display_data element in output

Open wstomv opened this issue 6 years ago • 11 comments

When I use nbviewer (as used in GitLab Community Edition 9.5.4) on a notebook that has an output cell with multiple display_data elements (see below), only the first display_data element shows up in the generated html.

These display_data elements were generated by creating multiple plots of a Pandas DataFrame in a single code cell:

df.plot(kind='hist');
df.plot(kind='hist', bins=30);
df.plot(kind='density');

In the notebook editor, and with nbconvert to html, these plots are shown one below the other.

This is what nbshow tells me about that code cell in my notebook:

code cell 24:
  execution_count: 7
  source:
    df_tel.plot(kind='hist')
    df_tel.plot(kind='hist', bins=30)
    df_tel.plot(kind='density');
  outputs:
    output 0:
      output_type: display_data
      data:
        image/png: iVBORw0K...<snip base64, md5=f63cee36824ae850...>
        text/plain: <matplotlib.figure.Figure at 0x11249f748>
      metadata (unknown keys):
        image/png:
          height: 465
          width: 939
    output 1:
      output_type: display_data
      data:
        image/png: iVBORw0K...<snip base64, md5=0767abf45de34cb3...>
        text/plain: <matplotlib.figure.Figure at 0x1158c4dd8>
      metadata (unknown keys):
        image/png:
          height: 465
          width: 939
    output 2:
      output_type: display_data
      data:
        image/png: iVBORw0K...<snip base64, md5=fc9c15197cc4e8e7...>
        text/plain: <matplotlib.figure.Figure at 0x11249f518>
      metadata (unknown keys):
        image/png:
          height: 465
          width: 953

By the way, also not shown properly are:

  • embedded LaTeX formulas,
  • markdown cell attachments,
  • explicit html in markdown cells, including the Table of Contents generated by the toc extension.

wstomv avatar Sep 27 '17 09:09 wstomv

That sounds like a GitLab bug. Can you point to where GitLab integrates nbviewer?

minrk avatar Oct 03 '17 14:10 minrk

I have no idea. I browsed the GitLab source code repository at https://gitlab.com/groups/gitlab-org

But I could not easily locate where nbviewer is integrated. I am only a user of GitLab.

wstomv avatar Oct 03 '17 14:10 wstomv

XRef: https://gitlab.com/gitlab-org/gitlab-ce/issues/31910

parente avatar Jul 08 '18 22:07 parente

I have the same issue when using nbviewer directly like: https://nbviewer.jupyter.org/github/alshan/jupyter-examples/blob/...

Doesn't look like GitLab problem to me.

alshan avatar Nov 08 '19 20:11 alshan

@alshan When I go to that link I get a 404

krinsman avatar Nov 08 '19 23:11 krinsman

@krinsman sorry, it was just to give a general idea. https://nbviewer.jupyter.org/github/alshan/jupyter-examples/blob/master/notebooks/quickstart.ipynb

alshan avatar Nov 08 '19 23:11 alshan

@alshan Could you attach a screenshot or something similar of what it's supposed to look like?

Seeing the ggplot2 command it looks like there is supposed to be some sort of plot there.

How do we know it's an issue with NBViewer and not with either the IR kernel or NBConvert?

Running the notebook locally, does the plot still show up if we save the notebook as PDF or HTML?

(If it does, then it would seem to be an issue with NBViewer and not NBConvert, if it doesn't then probably the opposite would be true.)

Right now this is the only guess I have to what might be going on, I'm really not sure at this point.

krinsman avatar Nov 08 '19 23:11 krinsman

@krinsman Running this notebook locally fails due to another unrelated issue. But this is what I found:

quickstart.ipynb clearly has two outputs

   "outputs": [
    {
     "data": {
      "text/html": [
       "                <script type=\"text/javascript\" src=\"http://dl.bintray.com/jetbrains/datalore-plot/datalore-plot-0.0.1rc2.min.js\"/>\n",
       "            "
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "\n",
       "            <div id=\"plot_output_ZOO0qP\"></div>\n",
       "            <script type=\"text/javascript\">\n",
       "                var plotSpec={\n",

but in nbviewer html I can only see just one output_area - corresponding to the 1-st output.

However, the second output JS is likely to result in Uncaught ReferenceError. However, the 2nd output_area must be present anyways. At least this is how it is in Jupyter.

Unless nbviewer purges faulty outputs.

alshan avatar Nov 09 '19 02:11 alshan

It seems like this might be an issue with nbconvert?

https://github.com/jupyter/nbconvert

Inside of Jupyter Notebook, if you save the notebook as an HTML file, and then open the HTML file in your browser, what happens?

krinsman avatar Nov 12 '19 22:11 krinsman

As far as I remember from before the weekend the situation with HTML file was similar - no second output. And it seemed that this happens when the first script tag is like:

<script type="text/javascript" src="..url.."/>

but if the first script tag (1st output) is like:

<script type="text/javascript" src="..url.."></script>

then the 2nd output shows up.

alshan avatar Nov 13 '19 01:11 alshan

@alshan If the situation with the HTML file is similar, then this is almost certainly an issue with NBConvert, since NBConvert is responsible both for creating that HTML file as well as the HTML files which NBViewer then renders. I recommend opening this issue with the NBConvert repository.

https://github.com/jupyter/nbconvert

krinsman avatar Nov 13 '19 19:11 krinsman