Skip to content

Conversation

ObservedObserver
Copy link
Member

Summary

  • add Reflex communication layer and API to render PygWalker in Reflex apps
  • provide example reflex_demo.py demonstrating usage
  • document Reflex example in examples README

Testing

  • pip install pytest (fails: Could not find a matching distribution)
  • pytest tests (fails: command not found)

@ObservedObserver ObservedObserver marked this pull request as ready for review May 22, 2025 17:22
@ObservedObserver ObservedObserver linked an issue May 22, 2025 that may be closed by this pull request
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Bug: Router Issues: Validation, JSON Conversion, Path Mismatch

The _pygwalker_router function has three distinct issues:

  • Input Validation: It accesses json_data["action"] and json_data["data"] without validation, causing a KeyError and API endpoint failure if these keys are missing from the request payload.
  • JSON Conversion Inefficiency: It performs an unnecessary double JSON conversion by serializing the result to a string and then immediately deserializing it before returning the JSONResponse.
  • Path Mismatch: There is an inconsistency between BASE_URL_PATH (defined without a leading slash) and PYGWALKER_ROUTE (defined with a leading slash), which may prevent frontend requests from correctly matching the API endpoint.

pygwalker/communications/reflex_comm.py#L11-L35

BASE_URL_PATH = "/_pygwalker/comm/".strip("/")
async def _pygwalker_router(req: Request) -> Response:
gid = req.path_params["gid"]
comm_obj = reflex_comm_map.get(gid, None)
if comm_obj is None:
return JSONResponse({"success": False, "message": f"Unknown gid: {gid}"})
json_data = await req.json()
result = comm_obj._receive_msg(json_data["action"], json_data["data"])
result = json.dumps(result, cls=DataFrameEncoder)
return JSONResponse(json.loads(result))
class ReflexCommunication(BaseCommunication):
"""Communication class for Reflex."""
def __init__(self, gid: str) -> None:
super().__init__(gid)
reflex_comm_map[gid] = self
PYGWALKER_ROUTE = Route(
"/_pygwalker/comm/{gid}",

Fix in Cursor


BugBot free trial expires on June 17, 2025
You have used $0.00 of your $50.00 spend limit so far. Manage your spend limit in the Cursor dashboard.

Was this report helpful? Give feedback by reacting with 👍 or 👎

@ObservedObserver ObservedObserver merged commit 5d0391d into main Jun 11, 2025
8 checks passed
@ObservedObserver ObservedObserver deleted the codex/implement-pygwalker-for-python-reflex branch June 11, 2025 12:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for pygwalker in Reflex

1 participant