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

Support Python server extension #1149

Open
fcollonval opened this issue Sep 14, 2023 · 3 comments
Open

Support Python server extension #1149

fcollonval opened this issue Sep 14, 2023 · 3 comments
Labels
enhancement New feature or request extension idea Would make a great extension

Comments

@fcollonval
Copy link
Contributor

Problem

Some existing Jupyter extensions have a Python server part. It will be nice to have a story to integrate them in JupyterLite.

From technical point of view, here are some challenges

  • JupyterLite has a server side in JavaScript that can not execute Python code by default
  • As all code must be executed in the client, the HTTP requests define by the Jupyter extensions must be converted to regular JavaScript call between the client code and the server code.
  • For performance reason, the server code must not block the main web browser thread
  • The server code should be asynchronous

Proposed Solution

The proposed solution (WIP) would be to have a Python interpreter using Pyodide running as a service worker to execute the Python server code.

The final goal would be for that service worker to be a singleton shareable by multiple extensions. This will mimic the current server app behavior and avoid multiplying Pyodide instances.

flowchart TB
    C[Client] --- S[JupyterLiteServer]
    S ---|Proxy request| W 
    subgraph Mocked ServerApp
    W[Pyodide Service worker] --- E[Jupyter Server Extension]
    end
Loading

One idea to ease the maintenance of the two interfaces (for JupyterServerApp and JupyterLiteServer), would be to provide tooling base on an OpenAPI spec.

Additional context

@fcollonval fcollonval added the enhancement New feature or request label Sep 14, 2023
@jtpio
Copy link
Member

jtpio commented Sep 14, 2023

must be converted to regular JavaScript call between the client code and the server code.

Would it have to? Currently fetch is already overriden in JupyterLite which allows for the frontend to not be modified, but still be able to "talk" to the /api/sessions, /api/settings... endpoints. So we could imagine having the same for this Jupyter Server extension compat layer.

Also linking to relevant discussions about using Jupyverse as a server (although different in scope):

@jtpio
Copy link
Member

jtpio commented Sep 14, 2023

Also this could be implemented and experimented with in a separate extension first (for example under the jupyterlite organization), instead of having it in core lite.

@jtpio jtpio added the extension idea Would make a great extension label Sep 14, 2023
@fcollonval
Copy link
Contributor Author

Currently fetch is already overriden in JupyterLite which allows for the frontend to not be modified, but still be able to "talk" to the /api/sessions, /api/settings... endpoints. So we could imagine having the same for this Jupyter Server extension compat layer.

That makes a lot of sense

Also this could be implemented and experimented with in a separate extension first (for example under the jupyterlite organization), instead of having it in core lite.

Yes - I'm even guessing that on the long run this should stay as an separate official extension to allow for light version and only bring it if some packages are needing it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request extension idea Would make a great extension
Projects
None yet
Development

No branches or pull requests

2 participants