Skip to content

Commit

Permalink
jupyter#751 adding widget metadata moved to separate method
Browse files Browse the repository at this point in the history
ipywidgets min version changed to 7
  • Loading branch information
Lukasz Mitusinski authored and maartenbreddels committed Mar 22, 2019
1 parent 672689b commit 1747634
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
17 changes: 17 additions & 0 deletions nbconvert/preprocessors/execute.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,23 @@ def preprocess(self, nb, resources, km=None):

return nb, resources

def set_widgets_metadata(self):
if self.widget_state:
self.nb.metadata.widgets = {
'application/vnd.jupyter.widget-state+json': {
'state': {
model_id: _serialize_widget_state(state)
for model_id, state in self.widget_state.items() if '_model_name' in state
},
'version_major': 2,
'version_minor': 0,
}
}
for key, widget in self.nb.metadata.widgets['application/vnd.jupyter.widget-state+json']['state'].items():
buffers = self.widget_buffers.get(key)
if buffers:
widget['buffers'] = buffers

def preprocess_cell(self, cell, resources, cell_index):
"""
Executes a single code cell. See base.py for details.
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ def run(self):
jupyter_client_req = 'jupyter_client>=4.2'

extra_requirements = {
(??) 'test': ['pytest', 'pytest-cov', 'ipykernel', 'jupyter_client>=4.2'],
'test': ['pytest', 'pytest-cov', 'ipykernel', 'jupyter_client>=4.2', 'ipywidgets>=7'],
'serve': ['tornado>=4.0'],
'execute': [jupyter_client_req],
'docs': ['sphinx>=1.5.1',
Expand Down

0 comments on commit 1747634

Please sign in to comment.