-
Notifications
You must be signed in to change notification settings - Fork 147
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Entrypoints can be traitlets Configurable
This means a custom proxy can be installed, and configured using traitlets in a standard jupyter_server_config file
- Loading branch information
Showing
8 changed files
with
99 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[project] | ||
name = "test-jsp-dummyentrypoint" | ||
version = "0.0.0" | ||
|
||
|
||
[project.entry-points.jupyter_serverproxy_servers] | ||
test-serverprocessentrypoint = "test_jsp_dummyentrypoint:CustomServerProcessEntryPoint" |
17 changes: 17 additions & 0 deletions
17
tests/resources/dummyentrypoint/test_jsp_dummyentrypoint/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
""" | ||
Test whether ServerProcessEntryPoint can be configured using traitlets | ||
""" | ||
|
||
import sys | ||
from pathlib import Path | ||
|
||
from traitlets.config import default | ||
|
||
from jupyter_server_proxy import ServerProcessEntryPoint | ||
|
||
|
||
class CustomServerProcessEntryPoint(ServerProcessEntryPoint): | ||
@default("command") | ||
def _default_command(self): | ||
parent = Path(__file__).parent.resolve() | ||
return [sys.executable, str(parent / "httpinfo.py"), "--port={port}"] |
24 changes: 24 additions & 0 deletions
24
tests/resources/dummyentrypoint/test_jsp_dummyentrypoint/httpinfo.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
""" | ||
Simple webserver to respond with an echo of the sent request. | ||
""" | ||
|
||
import argparse | ||
from http.server import BaseHTTPRequestHandler, HTTPServer | ||
|
||
|
||
class EchoRequestInfo(BaseHTTPRequestHandler): | ||
def do_GET(self): | ||
self.send_response(200) | ||
self.send_header("Content-type", "text/plain") | ||
self.end_headers() | ||
self.wfile.write(f"{self.requestline}\n".encode()) | ||
self.wfile.write(f"{self.headers}\n".encode()) | ||
|
||
|
||
if __name__ == "__main__": | ||
ap = argparse.ArgumentParser() | ||
ap.add_argument("--port", type=int) | ||
args = ap.parse_args() | ||
|
||
httpd = HTTPServer(("127.0.0.1", args.port), EchoRequestInfo) | ||
httpd.serve_forever() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters