Plotly.py: jsonschema.SchemaError when a figure is validated

Created on 12 Feb 2017  路  15Comments  路  Source: plotly/plotly.py

Here is a minimal example that reproduces the bug: http://nbviewer.jupyter.org/gist/empet/cf922d7c7f4269d6f63432ec67a5d020

The notebook runs OK (with plotly 2.0.1) when I call plot(fig). iplot(fig) generates the plot too, but an error box pops up whenever Jupyter tries to save the notebook. The box has the following content:

_The save operation succeeded, but the notebook does not appear to be valid. The validation error was:
Notebook Validation failed_:
u'data': [{u'colorscale': u'Viridis', u'z': [[2, 27, 105, 100], [87, 14, 121, 102], [26, 121, 73, 34], [44, 105, 111, 127]], u'type': u'heatmap', u'zsmooth': u'best'}], u'layout': {u'width': 400, u'height': 400}} _is not valid under any of the given schemas_:

{ "data": [ { "colorscale": "Viridis", "z": [ [ 2, 27, 105, 100 ], [ 87, 14, 121, 102 ], [ 26, 121, 73, 34 ], [ 44, 105, 111, 127 ] ], "type": "heatmap", "zsmooth": "best" } ], "layout": { "width": 400, "height": 400 } }

Initially I formulated this issue only for heatmaps, but meanwhile I realized that this behaviour manifests for any type of plot.

Most helpful comment

I'm running this locally on my mac, and am still seeing the issue after updating nbformat. Any ideas?

All 15 comments

cc @chriddyp

screen shot 2017-02-20 at 2 27 11 pm

yikes, I suspect that this was introduced with adding the Nteract plugin. @theengineear @rgbkrk , does that sound right? Any thoughts on how to get around this issue?

Upgrade nbformat, either with pip install --upgrade nbformat or conda update nbformat.

I've updated nbformat (to 4.2.0) and am still seeing this issue. I had not seen it until I upgraded to plotly 2.x (I have tried 2.0.1 and 2.0.2).

One thing to note - nbformat has to be upgraded for the Python your notebook server is running with (and server restarted). /cc @minrk

I'm running this locally on my mac, and am still seeing the issue after updating nbformat. Any ideas?

@malindho You should update to nbformat 4.3.0

For some reason conda update nbformat was not enough for me in my conda installation. However pip did the trick.

Hi I updated nbformat to 4.3.0 and it still raises the same "validation failed" issue...

[E 13:42:38.458 NotebookApp] Notebook JSON is invalid: {'data': [{'type': 'scatter', 'y': [1, 2, 3]}], 'layout': {}} is not valid under any of the given schemas

    Failed validating 'oneOf' in schema['properties']['data']['patternProperties']['^(?!application/json$)[a-zA-Z0-9]+/[a-zA-Z0-9\\-\\+\\.]+$']:
        {'oneOf': [{'type': 'string'},
                   {'items': {'type': 'string'}, 'type': 'array'}]}

    On instance['data']['application/vnd.plotly.v1+json']:
        {'data': [{'type': 'scatter', 'y': [1, 2, 3]}], 'layout': {}}

I've updated nbformat (to 4.2.0) and am still seeing this issue.

@malindho @antvig
I upgrade my jupyter at the same time and the problem is solved:
pip install --upgrade jupyter

@chriddyp I'm still seeing this issue, even with up-to-date packages and a clean installation. Steps to reproduce with conda:

# 1. Create environment
conda create -n plotly_test python=3.8 plotly numpy notebook
conda activate plotly_test

# 2. Download the Jupyter notebook from the first post in this thread:
# https://gist.githubusercontent.com/empet/cf922d7c7f4269d6f63432ec67a5d020/raw/79e1fb7d16b372cb7156a9c423bede0023127af0/iplot-bug

# 3. Start Jupyter Notebook, open the notebook, clear and run all,
# then try to save it. A validation error appears.
jupyter notebook

Output of pip freeze:

appnope==0.1.0
attrs==19.3.0
backcall==0.1.0
bleach==3.1.0
certifi==2019.11.28
decorator==4.4.1
defusedxml==0.6.0
entrypoints==0.3
importlib-metadata==1.5.0
ipykernel==5.1.4
ipython==7.12.0
ipython-genutils==0.2.0
jedi==0.16.0
Jinja2==2.11.1
jsonschema==3.2.0
jupyter-client==5.3.4
jupyter-core==4.6.1
MarkupSafe==1.1.1
mistune==0.8.4
mkl-fft==1.0.15
mkl-service==2.3.0
nbconvert==5.6.1
nbformat==5.0.4
notebook==6.0.3
numpy==1.18.1
pandocfilters==1.4.2
parso==0.6.1
pexpect==4.8.0
pickleshare==0.7.5
plotly==4.5.0
prometheus-client==0.7.1
prompt-toolkit==3.0.3
ptyprocess==0.6.0
Pygments==2.5.2
pyrsistent==0.15.7
python-dateutil==2.8.1
pyzmq==18.1.1
retrying==1.3.3
Send2Trash==1.5.0
six==1.14.0
terminado==0.8.3
testpath==0.4.4
tornado==6.0.3
traitlets==4.3.3
wcwidth==0.1.8
webencodings==0.5.1
zipp==2.2.0

Update 2018-02-14:
Using nbformat 4.x, rather than 5.x, seems to resolve the issue. Should this be registered as a bug with nbformat, or is this a plotly issue?

Although this is from many years ago, I am having the same issue here. Maybe it is a problem when using MacOS, as it is my case as well.

Although this is from many years ago, I am having the same issue here. Maybe it is a problem when using MacOS, as it is my case as well.

I have the same problem.

nbformat==5.0.4
plotly==4.6.0

+1

Was this page helpful?
0 / 5 - 0 ratings