notablemind / jupyter-nodejs

A node.js kernel for jupyter/ipython
http://nbviewer.ipython.org/gist/jaredly/404a36306fdee6a1737a
MIT License
682 stars 70 forks source link

Implement responding to `is_complete_request` message, to handle terminal usage #42

Closed shreevatsa closed 7 years ago

shreevatsa commented 7 years ago

After installing jupyter-nodejs and trying it from the console, I see the following behaviour: for every command (after the first one), I have to hit Enter three times (instead of once), for the input to be accepted:

~/jupyter% jupyter console --kernel nodejs
Jupyter console 5.1.0

NodeJS For your Jupyter experience!

In [1]: x = 42Unknown message type:  is_complete_request
[0]: 9ff67a12-0b598b50bbd4c394427b35bb
[1]: <IDS|MSG>
[2]: 4ede77abe5b937111cb357d63fb45a9d7f70cef79bc65a7befcdcc7649f67e7b
[3]: {"username":"srajagopalan","msg_type":"is_complete_request","msg_id":"3b028612-846c6b527ad9ba25b16b5ed5","version":"5.0","session":"9ff67a12-0b598b50bbd4c394427b35bb","date":"2017-02-25T20:30:12.697983Z"}
[4]: {}
[5]: {}
[6]: {"code":"x = 42"}
/Users/srajagopalan/jupyter/lib/python2.7/site-packages/jupyter_console/ptshell.py:599: UserWarning: The kernel did not respond to an is_complete_request. Setting `use_kernel_is_complete` to False.
  warn('The kernel did not respond to an is_complete_request. '
In [1]: x = 42
Out[1]: 42

In [2]: x = 7
      : 
      : 
Out[2]: 7

In [3]:                                                                                                                                                                                                                                       
Do you really want to exit ([y]/n)? 
Shutting down kernel

It appears that jupyter sends an is_complete message to determine whether the input (like x = 7 above) is complete (because it may be incomplete, like f = function() {). And this kernel (jupyter-nodejs) does not support responding to the is_complete message.

shreevatsa commented 7 years ago

Note: I have also filed a bug against jupyter_console, to see if there's a possibility of improving their handling of cases where the kernel does not support the is_complete message. But the best solution would be for this kernel to implement it.

jaredly commented 7 years ago

+1 is_complete_request is now supported in 2.0.0