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

Handle Inputs in Jupyter Notebooks #2

Closed
wants to merge 1 commit into from
Closed

Handle Inputs in Jupyter Notebooks #2

wants to merge 1 commit into from

Conversation

zph
Copy link
Owner

@zph zph commented Apr 28, 2024

TODO

  • Remove debug logging
  • Add tests
  • Code review for style

cli/js/40_jupyter.js Outdated Show resolved Hide resolved
Supports `confirm` and `prompt` with custom versions used when inside a
Jupyter Notebook with Deno kernel.

The desired behavior (per python reference and docs):
* confirm or prompt will trigger kernel to request the frontend to get
  user's input and return it to backend for processing

We accomplish this by creating custom versions of confirm and prompt
that call into an op_jupyter_input rust function with access to the
stdin_socket.

`confirm` and `prompt` are instantiated in the jupyter specific TS
interface, so they only override the standard functions in jupyter
context.

Jupyter requires us to clone zmq_identities for this "input_request"
message as documented in comments:

```
* Using with_identities() because of jupyter client docs instruction
* Requires cloning identities per :
* https://jupyter-client.readthedocs.io/en/latest/messaging.html#messages-on-the-stdin-router-dealer-channel
* The stdin socket of the client is required to have the
*  same zmq IDENTITY as the client’s shell socket.
*  Because of this, the input_request must be sent with the same IDENTITY
*  routing prefix as the execute_reply in order for the frontend to receive the message.
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant