jupyter-widgets / ipywidgets

Interactive Widgets for the Jupyter Notebook
https://ipywidgets.readthedocs.io
BSD 3-Clause "New" or "Revised" License
3.13k stars 950 forks source link

Widget Messaging Protocol Schema #3220

Open daviddavo opened 3 years ago

daviddavo commented 3 years ago

Problem

I'm doing an implementation of jupyter-widgets for the IHaskell kernel, and I'm using messages.md as a reference. I can't seem to understand what version_major and version_minor are on the display_data message.

Are they the widget messaging protocol version, as specified in the comm_open message? Are they the widgets' view module version? Or these numbers come from a completely different thing.

Suggested Improvement

Specifying where these numbers come from

daviddavo commented 3 years ago

Okay, so I think I clarified my doubts by reading the json schema.

But I still think that the documentation could be improved, saying that the version is optional

jasongrout commented 3 years ago

Great question. The version_major and version_minor in the display_data message are for the format of that specific message. In other words, if that display_data message ever changes its json format, we would increment that version.

Are they the widget messaging protocol version, as specified in the comm_open message?

Right now it is in sync(both are version 2.0).

I notice that the existing docs say "Widgets are displayed via display_data messages, which now include the version of the schema", which seems to imply to me that the two version numbers should stay in sync.

Are they the widgets' view module version?

No, that is transmitted in the widget model data, not in the display_data message.

daviddavo commented 3 years ago

Thank you very much!

bollwyvl commented 3 years ago

Thanks for bringing this up.

I'd love to see that core schema complemented (in another file) with a concrete schema of all the public widget models, and custom events. This nasty PR shows such a thing is possible, generating a TS backend for at least parts of ~60 of the ~80 core classes (including private classes and members)... but eventually, it seems like the Schema could become the source of truth, and could be used to test the public API of different implementation... especially if we warmed jupyter_kernel_test back up.

daviddavo commented 3 years ago

I have another question. I'm trying to implement the Output widget, but I can't make it work.

I've been "reverse-engineering" the messages exchanged when I use it on IPython and replicating it on my kernel, but I still can't make anything appear on the cell where I've displayed the output widget. Not even plain text.