Skip to content

feat: Standalone FastAPI web server adapter (env="fastapi") to bypass Jupyter dependencies#741

Open
Sagar369r wants to merge 2 commits into
Kanaries:mainfrom
Sagar369r:feat/fastapi-standalone-server-adapter
Open

feat: Standalone FastAPI web server adapter (env="fastapi") to bypass Jupyter dependencies#741
Sagar369r wants to merge 2 commits into
Kanaries:mainfrom
Sagar369r:feat/fastapi-standalone-server-adapter

Conversation

@Sagar369r

Copy link
Copy Markdown

(Note to maintainers: This PR is independent of and compatible with my Polars data parser optimization PR #740).

Summary of Changes

Currently, PyGWalker entry points (pygwalker.walk()) rely heavily on IPython.display and Jupyter kernel inter-process communication (IPC) channels. This makes it challenging to embed PyGWalker inside standalone Python web servers, headless environments, or custom desktop applications without pulling in full Jupyter dependencies.

This PR introduces a lightweight, standalone FastAPI server and CLI adapter under pygwalker.api.server (env="fastapi"):

Key Capabilities

  • walk_server(df) Adapter (pygwalker/api/server.py): Bypasses IPython.display entirely. Configures props["communicationUrl"] = "/comm" and serves the raw _get_render_iframe(return_iframe=False) HTML directly over an async FastAPI web server.
  • Direct /comm Bridge: Maps Graphic-Walker JSON communication requests (POST /comm) directly to PygWalker.comm._receive_msg() without going through Jupyter widgets or anywidget transport layers.
  • Standalone CLI (pygwalker/api/cli.py): Exposes an internal terminal command (pygwalker-cli <file>) for instant local exploration.
  • Zero Overhead for Existing Users: Designed to be served via optional dependencies (pip install pygwalker[server]), keeping the default installation lightweight for standard notebook users.

Verification & Compatibility Proof

  • Jupyter Compatibility Untouched: All existing test_pygwalker_core.py and test_computation.py suites (114 passed) execute without issue, ensuring zero regressions for env="jupyter", env="streamlit", or env="gradio".
  • Fully Compatible with PR feat: Native Polars SQLContext data parser bypassing DuckDB and Pandas #740: Works seamlessly with PolarsDataFrameDataParser or any standard data parser.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e0ef3e0398

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread pygwalker/api/server.py
Comment thread pygwalker/api/server.py
Comment thread pygwalker/api/server.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant