Official reference client implementation for GluRPC, the glucose prediction server. This package demonstrates best practices for integrating with GluRPC and provides both a Python SDK and a production-ready Gradio web interface for uploading CGM data and visualizing glucose predictions.
- 🌐 Full GluRPC API Coverage: Complete Python SDK with sync and async support
- 🖥️ Production-Ready Web Interface: Beautiful Gradio UI with real-time updates
- 📊 Advanced Visualization: Interactive Plotly charts with confidence intervals
- 🔍 Real-time Health Monitoring: Live server metrics with historical graphs
- ⚡ Smart Request Management: Automatic request cancellation and client-side optimization
- 💾 Format Conversion: Upload raw CGM files, get unified format with data quality warnings
- 🎚️ Interactive Exploration: Slider-based navigation through prediction samples
- 🔐 Secure Authentication: API key support for protected servers
- 📥 Export Capabilities: Download unified CSV and interactive HTML plots
- 🧪 Development Tools: Built-in test server for local development
- 📈 Performance Tracking: Client-side request timing and server queue monitoring
uv syncpip install glucosedao-client# Run client + server together (recommended for development)
uv run dev
# Run only the client (connect to existing server)
uv run client
# Run only the server
uv run serverIf you have a GluRPC server running elsewhere:
# Start the client interface
glucosedao-client launch
# Or with custom host/port
glucosedao-client launch --host 0.0.0.0 --port 7860Then open your browser and:
- Enter the server URL (e.g.,
http://your-server:8000) - Enter API key if required
- Upload your CGM data file
- View predictions!
For development or testing, start both client and server together:
# Start both client and server
glucosedao-client launch --with-server
# With custom ports
glucosedao-client launch --with-server --port 7860 --server-port 8001If you want to run just the server:
glucosedao-client server --host 0.0.0.0 --port 8000glucosedao-client launch [OPTIONS]Options:
--share: Create a public Gradio share link--host HOST: Hostname to bind to (default: 127.0.0.1)--port PORT: Port to bind to (default: 7860)--with-server: Start GluRPC server locally for testing--server-host HOST: GluRPC server host when using --with-server (default: 127.0.0.1)--server-port PORT: GluRPC server port when using --with-server (default: 8000)
Examples:
# Basic launch
glucosedao-client launch
# Launch with local test server
glucosedao-client launch --with-server
# Create public share link
glucosedao-client launch --share
# Custom configuration
glucosedao-client launch --host 0.0.0.0 --port 8080 --with-server --server-port 8001glucosedao-client server [OPTIONS]Options:
--host HOST: Host to bind to (default: 0.0.0.0)--port PORT: Port to bind to (default: 8000)
Example:
glucosedao-client server --host 0.0.0.0 --port 8000glucosedao-client check [OPTIONS]Options:
--url URL: Server URL to check (default: http://localhost:8000)
Example:
glucosedao-client check --url http://your-server:8000You can also use the client programmatically:
from glucosedao_client import GluRPCClient, GluRPCConfig
# Initialize client
config = GluRPCConfig(
base_url="http://localhost:8000",
api_key="your-api-key" # Optional
)
client = GluRPCClient(config)
# Convert raw CGM file to unified format
convert_response = client.convert_to_unified("path/to/dexcom.csv")
if not convert_response.error:
# Process the data
process_response = client.process_unified(convert_response.csv_content)
if not process_response.error:
# Generate plot for a specific sample
png_bytes = client.draw_plot(
handle=process_response.handle,
index=0
)
# Save plot
with open("prediction.png", "wb") as f:
f.write(png_bytes)
# Check server health
health = client.health()
print(f"Server status: {health.status}")
print(f"Models initialized: {health.models_initialized}")
print(f"Total requests: {health.total_requests_processed}")
# Clean up
client.close()For async applications:
from glucosedao_client import AsyncGluRPCClient, GluRPCConfig
async def main():
config = GluRPCConfig(base_url="http://localhost:8000")
async with AsyncGluRPCClient(config) as client:
# Convert file
convert_response = await client.convert_to_unified("data.csv")
# Process data
process_response = await client.process_unified(
convert_response.csv_content
)
# Get plot
png_bytes = await client.draw_plot(
process_response.handle,
index=0
)- Configure Server: Enter the GluRPC server URL and API key (if required)
- Check Health: Click "Check Server Health" to verify connectivity
- Upload Data: Upload a CGM data file (Dexcom, LibreView, etc.)
- View Predictions: The app will automatically process and show predictions
- Explore Samples: Use the slider to view predictions for different time windows
The client supports any CGM data format that GluRPC server supports:
- Dexcom
- LibreView (Freestyle Libre)
- Nightscout exports
- And more...
The server handles all format conversion automatically.
You can set default configuration using environment variables:
export GLURPC_URL="http://localhost:8000"
export GLURPC_API_KEY="your-api-key"Logs are saved to logs/app_<timestamp>.log with both console and file output. The client uses Python's standard logging library with DEBUG level for files and INFO level for console output.
# Clone the repository
git clone https://github.com/glucosedao/glucosedao_client.git
cd glucosedao_client
# Install dependencies with uv
uv sync
# Run in development mode
uv run python -m glucosedao_client.app# Install test dependencies
uv add --dev pytest pytest-asyncio httpx
# Run tests
uv run pytestThis reference implementation demonstrates proper client architecture:
-
client.py: Complete HTTP client for GluRPC API- Sync (
GluRPCClient) and async (AsyncGluRPCClient) implementations - Type-safe response models with Pydantic
- Connection pooling and timeout management
- Error handling and retry logic
- Sync (
-
app.py: Production-ready Gradio web interface (1000+ LOC)- Real-time server health monitoring with live graphs
- Automatic request cancellation for smooth slider interaction
- Data quality warnings from server validation
- Format conversion and unified CSV export
- Interactive Plotly visualizations
- Client-side performance tracking
-
server.py: Development server utilities- Local test server management
- Process lifecycle handling
-
cli.py: Typer-based CLI- Multiple launch modes (client-only, with-server, server-only)
- Health check utilities
- Flexible configuration options
The reference implementation demonstrates:
-
Efficient API Usage:
- File upload → Convert to unified format
- Process unified data → Get handle + warnings
- Draw plots on demand with caching
-
Request Management:
- Client-side request ID tracking
- Automatic cancellation of stale requests
- Server-side concurrent request handling
-
Real-time Monitoring:
- Health polling with 1-second updates
- Historical metrics visualization
- Queue size and processing time tracking
-
User Experience:
- Automatic plot generation on file upload
- Smooth slider interaction with debouncing
- Clear status messages and error handling
- Download options for data and plots
# Check if server is running
glucosedao-client check --url http://your-server:8000
# Try starting a local test server
glucosedao-client launch --with-serverMake sure you're providing the correct API key in the web interface or:
config = GluRPCConfig(
base_url="http://localhost:8000",
api_key="your-api-key"
)If the default port is in use:
# Use a different port
glucosedao-client launch --port 8080Contributions are welcome! Please feel free to submit a Pull Request.
Apache 2.0 - See LICENSE file for details.
This client serves as the official example of how to properly integrate with GluRPC:
✅ Complete API Coverage: Shows how to use all GluRPC endpoints
✅ Best Practices: Demonstrates proper error handling, caching, and request management
✅ Type Safety: Uses Pydantic models for all API interactions
✅ Production Ready: Includes monitoring, logging, and performance tracking
✅ Async Support: Shows both sync and async usage patterns
✅ User Experience: Implements smart features like request cancellation and live updates
Use this client as a template when building your own GluRPC integrations!
- Gradio 4.x - Interactive web interface with real-time updates
- httpx - Modern async HTTP client
- Typer - CLI framework with type hints
- Plotly - Interactive scientific visualization
- Pydantic 2 - Data validation and settings management
- cgm-format - CGM data format handling