-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Jupyter Widgets support #17
Comments
Not sure what you mean by "it".
Better option than what? So not sure what you are asking, but if the question is, if we will add widget support to this kernel, then the answer is "Probably yes". Greetings |
Widget is developed in TypeScript/JavaScript for IPython. |
Any potential widget will still be implemented in the usual way. The fact that the language of the kernel itself if is Javascript will not change that much |
Got it. |
For reference, Anywidget can run on Deno, another JavaScript/TypeScript kernel. (https://github.com/manzt/anywidget/tree/main/packages/deno) |
thanks for the hint, but as for most of these issues, it is not a lack of knowledge, but rather a lack of time/funding for such work |
I have a branch where I started to work on widget support, but not sure when I have time to continue on it |
with the current main one can try experiment with with comms. I have not managed to get smth working. function display_widget(data){
const protocol_version_major = 2
const protocol_version_minor = 1
const target_name = "jupyter.widget"
const metadata = {
version: `${protocol_version_major}.${protocol_version_minor}.0`
}
comm = new Module.Comm(target_name, data, metadata, [],{})
console.log(comm.comm_id())
const widget_json = {
version_major: protocol_version_major,
version_minor: protocol_version_minor,
model_id: comm.comm_id()
}
const mime_bundle = {
"application/vnd.jupyter.widget-view+json": widget_json
}
// display via com id
Module.interpreter.display_data(mime_bundle, {}, [])
}
const anywidget_version = "0.9.2"
const data = {
state: {
_model_module: "anywidget",
_model_name: "AnyModel",
_model_module_version: anywidget_version,
_view_module: "anywidget",
_view_name: "AnyView",
_view_module_version: anywidget_version,
_view_count: null,
},
}
display_widget(data) So far this still fails with
( of course, anywidget is installed, I also tried with ipywidgets, but also no success so far) |
I tried to migrate the working widget demo of Deno (https://github.com/manzt/anywidget/tree/main/packages/deno). But I failed for the same error of "Error displaying widget: model not found". You may check my tried code at https://github.com/MRYingLEE/xeus-javascript/blob/main/notebooks/widget_js_xeus.ipynb . |
Some progress. function display_widget(data){
const protocol_version_major = 2
const protocol_version_minor = 1
const target_name = "jupyter.widget"
const metadata = {
version: `${protocol_version_major}.${protocol_version_minor}.0`
}
// comm = new Module.Comm(target_name, data, metadata, [],{})
const uuid=crypto.randomUUID();
comm = new Module.Comm(target_name,{comm_id: uuid});
console.log(comm.comm_id())
const widget_json = {
version_major: protocol_version_major,
version_minor: protocol_version_minor,
model_id: comm.comm_id()
}
const mime_bundle = {
"application/vnd.jupyter.widget-view+json": widget_json
}
console.log(`"application/vnd.jupyter.widget-view+json": ${JSON.stringify(widget_json)}`);
// display via com id
Module.interpreter.display_data(Module.get_request_context(),mime_bundle, {}, [])
comm.open(Module.get_request_context().header(), data, metadata, []); // No message is triggered!
}
const anywidget_version = "0.9.3"
const data = {
state: {
_model_module: "anywidget",
_model_name: "AnyModel",
_model_module_version: anywidget_version,
_view_module: "anywidget",
_view_name: "AnyView",
_view_module_version: anywidget_version,
_view_count: null,
},
}
display_widget(data) No more errors. The UI shows "Loading widget...". Then I tried to enable the communication by comm.open(Module.get_request_context().header(), data, metadata, []); But no any kernel message is triggered. |
Thanks for the experimentation and progress! |
My code runs in a notebook, https://github.com/MRYingLEE/xeus-javascript/blob/main/notebooks/display_widget.ipynb. To avoid version conflicts, I use the same version (0.9.3) of anywidget for Deno. |
Jupyter Widgets are an impressive part of Jupyter ecosystem.
For Widgets are developed in TypeScript / Javascript. At the same time, HTML along with javascript can be displayed directly.
Is it needed to support it with this kernel? Or we may have a better option? If it is needed, do you have a plan to do so?
Please clarify.
Thanks,
The text was updated successfully, but these errors were encountered: