Opened 3 years ago

Last modified 3 weeks ago

#27752 new defect

Jupyter textual interact input does not wait to be evaluated

Reported by: kcrisman Owned by:
Priority: critical Milestone: sage-9.7
Component: notebook Keywords: interact, jupyter
Cc: jdemeyer, slelievre, vklein, zerline Merged in:
Authors: Reviewers:
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges

Description (last modified by kcrisman)

In #27735 it was discovered that, unlike sagenb or Sage cell, text input in @interacts in Jupyter apparently immediately re-evaluate even before 'enter' is pressed. jdemeyer explains:

It's a general "problem" (arguable, since one could call it a feature) with all interacts that have some kind of textual input which is evaluated.

However, because this is different from the behavior of other interact implementations (does anyone know about .sagews CoCalc sheets?), probably this should be fixed. Among other things, if the interact involves significant computation time (> 1 ms, especially a problem with anything involving graphics), it can slow down usage of interacts dramatically, which sort of defeats the purpose of @interacts.

Change History (13)

comment:1 Changed 3 years ago by kcrisman

  • Description modified (diff)

comment:2 in reply to: ↑ description ; follow-up: Changed 3 years ago by jdemeyer

I should note that the implementation of @interact itself is really done by upstream. Three packages (all under the Jupyter umbrella) play an important role:

  1. ipywidgets: Python package dealing with widgets and where the actual interact object is defined.
  2. widgetsnbextension: JavaScript code for working with widgets in the browser.
  3. traitlets: low-level Python library dealing with the callback mechanism (changing the value of a widget triggers evaluation of the interact function).

There are Sage customizations to the standard @interact (see src/sage/repl/ipython_kernel/interact.py), but those do not fundamentally change the way how interacts work.

So either we need to fix something upstream, or we add a workaround in Sage, or we become happy with the status-quo.

Last edited 3 years ago by jdemeyer (previous) (diff)

comment:3 in reply to: ↑ 2 ; follow-up: Changed 3 years ago by kcrisman

  1. ipywidgets: Python package dealing with widgets and where the actual interact object is defined.
  2. widgetsnbextension: JavaScript code for working with widgets in the browser.
  3. traitlets: low-level Python library dealing with the callback mechanism (changing the value of a widget triggers evaluation of the interact function).

Which of these is the one that is most likely to be causing the immediate change with regard to the text boxes? I think the real problem is that different implementations work differently, and it surprises me that there is such immediate response in Jupyter - you'd think it would be "easier" not to poll the Sage kernel with more computation so often, but of course I don't know much about the specific technicalities.

comment:4 in reply to: ↑ 3 Changed 3 years ago by jdemeyer

Replying to kcrisman:

Which of these is the one that is most likely to be causing the immediate change with regard to the text boxes?

It's really a combination, that's why I mentioned the various packages: whenever the user types something in a text box, widgetsnbextension sends an event to the Jupyter kernel. ipywidgets then changes the .value attribute of the text box. traitlets notices that this attribute has changed and calls a callback function for the interact (implemented by ipywidgets). This callback then updates the interact.

comment:5 Changed 3 years ago by slelievre

  • Cc slelievre zerline added
  • Keywords interact jupyter added

comment:6 Changed 3 years ago by embray

  • Milestone changed from sage-8.8 to sage-8.9

Moving open critical and blocker issues to the next release milestone (optimistically).

comment:7 Changed 2 years ago by embray

  • Milestone changed from sage-8.9 to sage-9.1

Ticket retargeted after milestone closed

comment:8 Changed 2 years ago by mkoeppe

  • Milestone changed from sage-9.1 to sage-9.2

comment:9 Changed 19 months ago by mkoeppe

  • Milestone changed from sage-9.2 to sage-9.3

comment:10 Changed 13 months ago by mkoeppe

  • Milestone changed from sage-9.3 to sage-9.4

Moving to 9.4, as 9.3 has been released.

comment:11 Changed 9 months ago by mkoeppe

  • Milestone changed from sage-9.4 to sage-9.5

comment:12 Changed 4 months ago by mkoeppe

  • Milestone changed from sage-9.5 to sage-9.6

comment:13 Changed 3 weeks ago by mkoeppe

  • Milestone changed from sage-9.6 to sage-9.7
Note: See TracTickets for help on using tickets.