So I have attached a figurewidget to a tab and plotting data based on a dropdown selection. The flow is → I select an item from dropdown → click “plot” and it erases the previous traces and plots the new trace". The error that I am facing is that sometimes the change event is caught by _handler_js2py_pointsCallback method when I change the dropdown selection. This occurs randomly (sometimes after 4 selections, sometime it occurs after 20 times). Can we have the name checked when the change dictionary is processed inside _handler_js2py_pointsCallback method, such that it only handles change[‘name’] == ‘_js2py_pointsCallback’ (I’m assuming that all change dictionary pertaining to FigureWidget has this name)
The following is the stack trace that I get:
KeyError Traceback (most recent call last)
/gpfs/apps/team_name/stacks/3/condaenv/kernel/1.0/conda/lib/python3.7/site-packages/ipywidgets/widgets/widget.py in _handle_msg(self, msg)
674 if ‘buffer_paths’ in data:
675 _put_buffers(state, data[‘buffer_paths’], msg[‘buffers’])
→ 676 self.set_state(state)
677
678 # Handle a state request.
/gpfs/apps/team_name/stacks/3/condaenv/kernel/1.0/conda/lib/python3.7/site-packages/ipywidgets/widgets/widget.py in set_state(self, sync_data)
543 from_json = self.trait_metadata(name, ‘from_json’,
544 self._trait_from_json)
→ 545 self.set_trait(name, from_json(sync_data[name], self))
546
547 def send(self, content, buffers=None):
/gpfs/apps/team_name/stacks/3/condaenv/kernel/1.0/conda/lib/python3.7/contextlib.py in exit(self, type, value, traceback)
117 if type is None:
118 try:
→ 119 next(self.gen)
120 except StopIteration:
121 return False
/gpfs/apps/team_name/stacks/3/condaenv/kernel/1.0/conda/lib/python3.7/site-packages/traitlets/traitlets.py in hold_trait_notifications(self)
1212 for changes in cache.values():
1213 for change in changes:
→ 1214 self.notify_change(change)
1215
1216 def _notify_trait(self, name, old_value, new_value):
/gpfs/apps/team_name/stacks/3/condaenv/kernel/1.0/conda/lib/python3.7/site-packages/ipywidgets/widgets/widget.py in notify_change(self, change)
604 # Send new state to front-end
605 self.send_state(key=name)
→ 606 super(Widget, self).notify_change(change)
607
608 def repr(self):
/gpfs/apps/team_name/stacks/3/condaenv/kernel/1.0/conda/lib/python3.7/site-packages/traitlets/traitlets.py in notify_change(self, change)
1225 def notify_change(self, change):
1226 “”“Notify observers of a change event”""
→ 1227 return self._notify_observers(change)
1228
1229 def _notify_observers(self, event):
/gpfs/apps/team_name/stacks/3/condaenv/kernel/1.0/conda/lib/python3.7/site-packages/traitlets/traitlets.py in _notify_observers(self, event)
1262 c = getattr(self, c.name)
1263
→ 1264 c(event)
1265
1266 def _add_notifiers(self, handler, name, type):
/gpfs/apps/team_name/stacks/3/condaenv/kernel/1.0/conda/lib/python3.7/site-packages/plotly/basewidget.py in _handler_js2py_pointsCallback(self, change)
708 ):
709
→ 710 trace_dict = trace_points[trace_ind]
711 trace_dict[“xs”].append(x)
712 trace_dict[“ys”].append(y)
KeyError: 1
Can anybody help me with this?