Skip to content
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

Add support for jupyter widgets #350

Merged
merged 1 commit into from
Oct 1, 2024
Merged

Conversation

matt-do-it
Copy link
Contributor

Currently it is not possible to display Jupyter widgets with an iruby kernel, as they require custom metadata on comm. This patch adds the ability to send metadata on open, send_msg, and close messages in a backward-compatible fashion.

As an example, you can now display an IntSlider with this example code, executed in a notebook. Please note the {:version => "2.1.0"} - this is metadata that has not been supported until now.

    comm = IRuby::Comm.new("jupyter.widget", comm_id = @id)

    comm.open({:version => "2.1.0"}, :state => {
    	:dom_classes => [],
    	:_model_module => "@jupyter-widgets/controls",
    	:_model_module_version => "2.0.0",
    	:_model_name => "IntSliderModel",
    	:_view_count => nil,
    	:_view_module => "@jupyter-widgets/controls",
    	:_view_name => "IntSliderView",
    	:_view_module_version => "2.0.0"
    })

Jupyter widgets require custom metadata in open, send_msg, and close. This patch adds the ability to send metadata in a backward-compatible way.
@kojix2
Copy link
Member

kojix2 commented Oct 1, 2024

Hi matt-do-it.
Thank you for your pull request for IRuby.
The IRuby project currently has no active developers.
If you find any issues with the code, please send me an additional pull request.

@kojix2 kojix2 merged commit ebebd95 into SciRuby:master Oct 1, 2024
6 of 8 checks passed
@kojix2
Copy link
Member

kojix2 commented Oct 1, 2024

Note: Currently, the tests are failing on Ruby 3.3 because warnings related to OpenStruct are being written to the standard error output. This is being captured by Open3.capture2e and then mistakenly parsed as JSON. Therefore, it seems unrelated to this pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants