question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`import plotly` fails with `KeyError: 'metaKeys'`

See original GitHub issue

Right now, import plotly fails.

In [1]: import plotly
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
<ipython-input-1-c27a4132ad2e> in <module>()
----> 1 import plotly

/Users/chriddyp/Repos/venvpy27/lib/python2.7/site-packages/plotly/__init__.py in <module>()
     29 from __future__ import absolute_import
     30
---> 31 from plotly import (plotly, graph_objs, grid_objs, tools, utils, session,
     32                     offline)
     33 from plotly.version import __version__

/Users/chriddyp/Repos/venvpy27/lib/python2.7/site-packages/plotly/plotly/__init__.py in <module>()
      8
      9 """
---> 10 from . plotly import (
     11     sign_in,
     12     update_plot_options,

/Users/chriddyp/Repos/venvpy27/lib/python2.7/site-packages/plotly/plotly/plotly.py in <module>()
     29 from requests.auth import HTTPBasicAuth
     30
---> 31 from plotly import exceptions, tools, utils, version, files
     32 from plotly.plotly import chunked_requests
     33 from plotly.session import (sign_in, update_session_plot_options,

/Users/chriddyp/Repos/venvpy27/lib/python2.7/site-packages/plotly/tools.py in <module>()
     18 from plotly import utils
     19 from plotly import exceptions
---> 20 from plotly import graph_reference
     21 from plotly import session
     22 from plotly.files import (CONFIG_FILE, CREDENTIALS_FILE, FILE_CONTENT,

/Users/chriddyp/Repos/venvpy27/lib/python2.7/site-packages/plotly/graph_reference.py in <module>()
    521 TRACE_NAMES = list(GRAPH_REFERENCE['traces'].keys())
    522
--> 523 OBJECTS = _get_objects()
    524 _patch_objects()
    525 ARRAYS = _get_arrays()

/Users/chriddyp/Repos/venvpy27/lib/python2.7/site-packages/plotly/graph_reference.py in _get_objects()
    404     for node, path in utils.node_generator(GRAPH_REFERENCE):
    405
--> 406         if any([key in path for key in GRAPH_REFERENCE['defs']['metaKeys']]):
    407             continue  # objects don't exist under nested meta keys
    408         if node.get('role') != 'object':

KeyError: 'metaKeys'

Several pages on the API are failing intermittently right now with a 504 and so I suspect that this URL https://api.plot.ly/v2/plot-schema.json?sha1=%22%22 is failing with like a 504 behind the scenes too.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:10 (8 by maintainers)

github_iconTop GitHub Comments

4reactions
chriddypcommented, Nov 21, 2016

Thanks for reporting @fchevitarese! We are working on a fix right now

1reaction
chriddypcommented, Nov 21, 2016

@jlmcgehee21 100% agreed. Here’s a recap of what happened here:

  • import plotly downloads the latest plot-schema.json. The plot-schema.json contains all of the information about the available keys and chart types in plotly.graph_objs. This means that as new features are added to plotly.js, the python library automatically gets those updates.
  • Today, a typo caused plot-schmea.json to be malformed. Note that the API call technically “worked” (a 200 was returned) but the format of the plot-schema.json wasn’t right. Had the API call failed, the python library would have just used the cached version.
  • The typo in plot-schema.json caused a typo while creating the graph_objs. This caused import plotly to fail.

This library has fail-safes around the actual API calls - There is a 5 second timeout and a cached version of the plot-schema.json that gets included in the library: https://github.com/plotly/plotly.py/blob/master/plotly/graph_reference.py#L91-L107

but no fail safes around creating the graph_objs based off of that plot-schema: https://github.com/plotly/plotly.py/blob/master/plotly/graph_reference.py#L517-L532.

To make sure that this never happens again, we should either:

  • Extend the try / except around the construction of graph_objs off of the downloaded plot-schema.json and use the cached version if possible.
  • Remove the auto-downloading plot-schema on import and perform more frequent (weekly) releases of the python library in sync with the plotly.js version updates.
Read more comments on GitHub >

github_iconTop Results From Across the Web

KeyError: 'plotly_domain' - python - Stack Overflow
Based on this answer, try using py.plot instead of py.iplot . KeyError: 'plotly_domain' when using plotly to do scatter plot in python.
Read more >
[Solved] Import error when trying to test my component in ...
This KeyError: 'props' usually means that the metadata.json file isn't what dash expects it to be (dash could certainly fail more gracefully ...
Read more >
Key Error while grouping in Data Frame through Dropdown Input
However, I am getting the the error: KeyError: u'brand'. Following is the code: import dash import dash_core_components as dcc
Read more >
Help: Plotly graph Error 0 - Plotly Community Forum
I am trying to use Plotly to plot a scatter plot with linear ... I followed this guide: I ended up with the...
Read more >
Error in App an Key Error - Fixed it! (white space after column ...
Hi, Having issues getting my dashboard with multiple inputs to work. It will output a graph with no data and give me two...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found