"could not find model" due to outputs:[{text/plain}] truncated at 111 bytes


I have a notebook containing:

  • Nested HBox and VBox to create a table of ipywidget.HTML snippets
  • Vega charts produced via Python code and passed to display({‘application/vnd.vega.v4+json’: …my_string…}, raw=True)

When I start JupyterLab 0.35.4 the content is not restored, it says “could not find model” until I execute the first code cell. I gather this means the ipynb file did not contain saved images/renderings/etc, which is not surprising I suppose given the custom Vega charts.

I’m willing to put in some effort to try to fix this and have my notebook open to a useable state more quickly, but I’m not sure even where to begin. Do I need to write a jupyterlab extension? Do I need to make changes in the backend? Is it simpler than that, is there some option I can pass to display(raw=True) which I’m missing?

1 Like


Looking at my ipynb file, the text is truncated after 111 characters and an ellipse. Admittedly the nested VBox+HBox statements and the Vega code would be many tens of kilobytes, but if it were saved without truncation I think it would work.

Truncating the field makes it seem like it is probably not an issue of needing an extension, it is more likely a limit within Jupyter which is being hit. 111 bytes seems very small, I know I’ve seen larger blocks of HTML saved in an ipynb file than that.

   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "c7e179805f494ec6b9b772c705593059",
       "version_major": 2,
       "version_minor": 0
      "text/plain": [
       "HBox(children=(VBox(children=(HBox(children=(HTML(value='<div style=\"font-size:large; background-color:white;p…"
     "metadata": {},
     "output_type": "display_data"
   "source": [
    "import os.path\n",
    "import ipywidgets\n",
    "from IPython.display import display, HTML, SVG\n",
    "import pandas as pd\n",
    "import numpy as np\n",


I dug around in the nbformat v3 and v4 code looking for a length limit of about 111 bytes, but didn’t see anything likely. I imagine the truncation happens earlier, prior to calling nbformat to write out the file.



Since I know that something, somewhere is replacing the bulk of the ‘text/plain’ field with an ellipse character ‘…’ I searched the jupyter github repositories for occurrences of that character in decimal and hex code as well the the unicode symbol, but didn’t find it.



So you have your vega inside of the ipywidgets?

I think the issue here is possibly that we don’t have ipywidgets state into the notebook, see https://github.com/jupyterlab/jupyterlab/issues/5235

We just added more complete support for managing notebook metadata like widget state here: https://github.com/jupyterlab/jupyterlab/pull/5968

You might be more of a response on the ipywidgets issue tracker. That is where the jupyter lab extension lives for rendering widgets.

1 Like


We revamp our ipywidgets support for JupyterLab in https://github.com/jupyter-widgets/ipywidgets/pull/2265. We’re very close to merging that and releasing a new version of the ipywidgets jupyterlab manager.