Chapters: 

A concise reference for inspecting and understanding the Python landscape on Camelot, including Jupyter Server’s REST API surface and module locations. 

Prerequisites

  • Access to the camelot server via SSH (user: tux or jupyter).
  • Jupyter Server running locally on port 8888.
  • jq installed for JSON parsing (sudo dnf install -y jq).

1. Inspect Installed Python Packages

List all Jupyter-related and core packages:

pip3 list | grep -E 'notebook|jupyter|jupyter_server|python'

This shows you package names and versions, confirming your runtime environment.

2. Locate Package Source Directories

Find on-disk locations for key modules:

python3 - <<'PYCODE'
import notebook, jupyter_server, os
print("notebook module at:      ", os.path.dirname(notebook.__file__))
print("jupyter_server module at: ", os.path.dirname(jupyter_server.__file__))
PYCODE

Use these paths when browsing source or grepping for specific code patterns.

3. Enumerate REST Endpoints via OpenAPI

Jupyter Server exposes a full OpenAPI spec at /openapi.json. To list all available routes:

curl -s http://localhost:8888/openapi.json \
  | jq -r '.paths | keys[]' \
  | sort

This prints every API path (e.g., /api/contents/{path}, /api/kernels, etc.).

4. Drill into Tornado Handler Mappings

Rather than Flask Blueprints, Jupyter Server uses Tornado handlers. To see which regex maps to which Python class:

python3 - <<'PYCODE'
from jupyter_server import serverapp
app = serverapp.ServerApp()
app.initialize([])

# Default host_patterns and routes
host_patterns, default_handlers = (
    app.web_app.add_handlers.__wrapped__.__defaults__
)
for host_pat, routes in host_patterns:
    print(f"\nHost pattern: {host_pat}")
    for regex, handler in routes:
        print(f"  {regex.pattern:40} → {handler.__name__}")
PYCODE

This outputs lines like:

Host pattern: .*$
  /api/contents/(.*)           → ContentsHandler
  /api/kernels                  → KernelHandler
  ...

5. Search Source for Key Concepts

If you want to audit a concept (e.g., authentication, file I/O), grep inside the module directories:

grep -R --include="*.py" -n "Auth" "$(python3 - <<<'PYCODE'
import jupyter_server, os
print(os.path.dirname(jupyter_server.__file__))
PYCODE)"

Modify the search term for other patterns (e.g., ContentsHandler, FileManagerMixin, etc.).

6. Quick Python REPL Exploration

For ad-hoc introspection, start a REPL and import components:

python3
>>> from jupyter_server.serverapp import ServerApp
>>> app = ServerApp()
>>> app.initialize([])
>>> app.web_app.settings.keys()
>>> app.web_app.settings['kernel_manager_class']

This approach helps you poke at internal settings and configurations.

Now you have a turnkey guide for any explorer to map Camelot’s Python environment and Jupyter Server’s REST API — perfect for your Encyclopedia!