Skip to content

Commit d2c9083

Browse files
committed
Docs + remove buffer hack
I removed the buffer hack. This shouldn't be required anymore since the removal of json_clean in ipykernel. We should also see if we can improve performances in jupyter-server.
1 parent b6f6dbc commit d2c9083

File tree

4 files changed

+20
-7
lines changed

4 files changed

+20
-7
lines changed

ipywidgets/_version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
__version__ = '%s.%s.%s%s'%(version_info[0], version_info[1], version_info[2],
99
'' if version_info[3]=='final' else _specifier_[version_info[3]]+str(version_info[4]))
1010

11-
__protocol_version__ = '2.0.0'
11+
__protocol_version__ = '2.1.0'
1212

1313
# These are *protocol* versions for each package, *not* npm versions. To check, look at each package's src/version.ts file for the protocol version the package implements.
1414
__jupyter_widgets_base_version__ = '1.2.0'

ipywidgets/widgets/widget.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,10 @@ def _call_widget_constructed(widget):
319319

320320
@classmethod
321321
def handle_comm_opened_control(cls, comm, msg):
322+
version = msg.get('metadata', {}).get('version', '')
323+
if version.split('.')[0] != PROTOCOL_VERSION_MAJOR:
324+
raise ValueError("Incompatible widget protocol versions: received version %r, expected version %r"%(version, __protocol_version__))
325+
322326
cls.get_manager_state()
323327
widgets = Widget.widgets.values()
324328
# build a single dict with the full widget state
@@ -332,10 +336,7 @@ def handle_comm_opened_control(cls, comm, msg):
332336
'state': widget.get_state(drop_defaults=drop_defaults),
333337
}
334338
full_state, buffer_paths, buffers = _remove_buffers(full_state)
335-
# the message is also send as buffer, so it does not get handled by jupyter_server
336-
msg = jsondumps([full_state, buffer_paths]).encode('utf8')
337-
buffers.insert(0, msg)
338-
comm.send(buffers=buffers)
339+
comm.send([full_state, buffer_paths], buffers=buffers)
339340

340341
@staticmethod
341342
def handle_comm_opened(comm, msg):

packages/base/src/version.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,4 @@ export
55
const JUPYTER_WIDGETS_VERSION = '1.2.0';
66

77
export
8-
const PROTOCOL_VERSION = '2.0.0';
9-
8+
const PROTOCOL_VERSION = '2.1.0';

packages/schema/messages.md

+13
Original file line numberDiff line numberDiff line change
@@ -338,3 +338,16 @@ To display a widget, the kernel sends a Jupyter [iopub `display_data` message](h
338338
}
339339
}
340340
```
341+
342+
343+
344+
345+
# Widget messaging protocol, version 2.1
346+
347+
This is implemented in ipywidgets 7.7.
348+
349+
## Changes from version 2
350+
351+
### The `jupyter.widget.control` comm target
352+
353+
A kernel-side Jupyter widgets library registers a `jupyter.widget.control` comm target that is used for fetching all widgets states through a "one shot" comm message (one for all widget instances). The kernel-side widgets library must answer to the "comm-open" message with a comm message containing the full state of all widget instances.

0 commit comments

Comments
 (0)