-
Notifications
You must be signed in to change notification settings - Fork 984
feat: Add bundled React webview CLI for local file visualization #2107
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
base: main
Are you sure you want to change the base?
Conversation
Problem Statement What we're trying to solve: - Python project generates local output files that need visual inspection - Users need a simple CLI command (load-webview) to instantly view these files in a web interface - Want to ship React frontend + Python backend as a single pip-installable package - Need both development mode (separate servers) and production mode (bundled React served by Python) The Architecture: pip install my-project ↓ my-project generates local files ↓ load-webview # Single CLI command ↓ Launches: Python API server + React frontend ↓ User opens browser → Views local files via web interface How we're solving it: 1. Bundled Distribution Strategy: - Development: React dev server (port 3000) + Python API (port 8000) running separately - Production: React app pre-built into static files, served by Python server - Single pip package contains both frontend bundle and Python backend 2. CLI Workflow: # User installs package pip install my-project # User generates files with main project my-project --input data.json --output results/ # User views results in browser load-webview --data-dir results/ # → Opens http://localhost:8000 with React app 3. Build Pipeline: - scripts/build.py: Builds React app → js-bundle/ directory - scripts/dev.py: Runs both servers for development - Package includes pre-built React bundle for production - CLI automatically serves bundled frontend if available 4. Technical Implementation: - Frontend: React + TypeScript for file visualization (tables, charts, etc.) - Backend: FastAPI with file reading APIs (/api/datasets, /api/files) - Development: Auto-reload on code changes, CORS configured - Production: Static file serving, SPA routing, single server
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Greptile Summary
This PR introduces a new feature to add a web-based visualization interface for Ragas evaluation results through a bundled React webview CLI. The implementation allows users to view local evaluation files through a browser with a simple CLI command.
The changes introduce:
- A Python FastAPI backend that serves both API endpoints and static files
- A React frontend with TypeScript and TailwindCSS for visualization
- Development mode with separate servers and hot-reload
- Production mode where React is pre-built and served by Python
However, there are several critical issues that need addressing:
- The package.json specifies non-existent future versions of dependencies (React 19.1.0, TailwindCSS 4.0.0)
- The datasets.py service has hardcoded paths and ignores the data_dir parameter
- Bundle validation in bundle.py could be more robust
Confidence score: 2/5
- This PR will likely cause immediate dependency and runtime issues if merged
- The dependency versions and hardcoded paths make this PR unstable and potentially broken
- Files needing attention:
- webview-poc/ragas-webview/package.json (invalid dependency versions)
- webview-poc/ragas_webview_cli/services/datasets.py (hardcoded paths)
- webview-poc/ragas_webview_cli/services/bundle.py (validation logic)
30 files reviewed, 19 comments
Edit PR Review Bot Settings | Greptile
|
||
export function ErrorMessage({ message, onRetry }: ErrorMessageProps) { | ||
return ( | ||
<div className="flex items-center justify-center min-h-screen"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: min-h-screen forces full viewport height - might not be desirable in all contexts where this error could be used
.Python | ||
build/ | ||
develop-eggs/ | ||
dist/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: dist/ appears multiple times in the file (line 56). Consider consolidating these entries to avoid confusion.
|
||
def get_environment() -> Environment: | ||
"""Get current environment from env var.""" | ||
env_str = os.getenv("WEBVIEW_ENV", "PRODUCTION").upper() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: env var name should have prefix matching project (RAGAS_WEBVIEW_ENV instead of WEBVIEW_ENV)
background-color: #f9fafb; | ||
color: #111827; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: use CSS variables instead of hardcoded colors to maintain consistency with the theme system
import sys | ||
import os | ||
import time | ||
import signal |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: signal module is imported but never used
current_file = Path(__file__) | ||
project_root = current_file.parent.parent.parent | ||
csv_file = project_root / "samples_data" / "evaluation_results.csv" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: path resolution from file is fragile and assumes fixed directory structure. This breaks if installed via pip. Use data_dir parameter instead
export default tseslint.config([ | ||
globalIgnores(['dist']), | ||
{ | ||
files: ['**/*.{ts,tsx}'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: Add .jsx extension to file pattern for better compatibility
- `GET /` - Serves React app (production) or API info (development) | ||
- `GET /api/health` - Health check endpoint | ||
- `GET /assets/*` - Static assets (CSS, JS, images) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: API endpoints section is incomplete. Missing dataset and file endpoints mentioned in the PR description.
) | ||
|
||
|
||
def create_datasets_router(data_dir: Optional[str] = None) -> APIRouter: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: data_dir parameter is never used in the implementation. Either use it or remove it
return router | ||
|
||
|
||
def mount_static_files(app, js_bundle_dir: Path): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: Missing type hint for 'app' parameter
Problem Statement
What we're trying to solve:
The Architecture:
pip install my-project
↓
my-project generates local files
↓
load-webview # Single CLI command
↓
Launches: Python API server + React frontend
↓
User opens browser → Views local files via web interface
How we're solving it:
- Development: React dev server (port 3000) + Python API (port 8000) running separately
- Production: React app pre-built into static files, served by Python server
- Single pip package contains both frontend bundle and Python backend
User generates files with main project
my-project --input data.json --output results/
User views results in browser
load-webview --data-dir results/
→ Opens http://localhost:8000 with React app
- scripts/build.py: Builds React app → js-bundle/ directory
- scripts/dev.py: Runs both servers for development
- Package includes pre-built React bundle for production
- CLI automatically serves bundled frontend if available
- Frontend: React + TypeScript for file visualization (tables, charts, etc.)
- Backend: FastAPI with file reading APIs (/api/datasets, /api/files)
- Development: Auto-reload on code changes, CORS configured
- Production: Static file serving, SPA routing, single server