Test cloud run deployment and features - #146
Conversation
This commit introduces a unified AI API that integrates emotion detection, text summarization, and voice transcription. It includes a new Dockerfile, updated deployment scripts, and comprehensive requirements. The API now supports configurable models and rate limiting through environment variables, with adjusted resource allocations for improved performance. Co-authored-by: denizcan.uelker <denizcan.uelker@mercedes-benz.com>
|
Cursor Agent can help with this pull request. Just |
Reviewer's GuideThis PR overhauls the Cloud Run deployment and configuration of the unified AI API by parameterizing model and rate-limiting settings via environment variables, introducing a dedicated Dockerfile and dependencies file, and adding comprehensive local testing and deployment documentation. Sequence diagram for model loading with environment variable configurationsequenceDiagram
participant FastAPI
participant "unified_ai_api.py"
participant "Emotion Model Loader"
participant "Text Summarizer Loader"
participant "Voice Transcriber Loader"
FastAPI->>"unified_ai_api.py": Start lifespan
"unified_ai_api.py"->>"Emotion Model Loader": Load model (ID from ENV)
"Emotion Model Loader"-->>"unified_ai_api.py": Model loaded
"unified_ai_api.py"->>"Text Summarizer Loader": Load model (ID from ENV)
"Text Summarizer Loader"-->>"unified_ai_api.py": Model loaded
"unified_ai_api.py"->>"Voice Transcriber Loader": Load model (ID from ENV)
"Voice Transcriber Loader"-->>"unified_ai_api.py": Model loaded
"unified_ai_api.py"-->>FastAPI: Models ready
Class diagram for updated unified_ai_api.py model and rate limiting configurationclassDiagram
class UnifiedAIAPI {
+emotion_model_id: str
+text_summarizer_model: str
+voice_transcriber_model: str
+rate_limit_requests_per_minute: int
+rate_limit_burst_size: int
+rate_limit_max_concurrent: int
+rate_limit_rapid_fire_threshold: int
+rate_limit_sustained_threshold: int
+load_models()
+configure_rate_limiting()
}
class EmotionModelLoader {
+load(model_id: str)
}
class TextSummarizerLoader {
+load(model_id: str)
}
class VoiceTranscriberLoader {
+load(model_id: str)
}
class RateLimitingMiddleware {
+configure(requests_per_minute: int, burst_size: int, ...)
}
UnifiedAIAPI --> EmotionModelLoader : uses
UnifiedAIAPI --> TextSummarizerLoader : uses
UnifiedAIAPI --> VoiceTranscriberLoader : uses
UnifiedAIAPI --> RateLimitingMiddleware : configures
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the ✨ Finishing Touches🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Here's the code health analysis summary for commits Analysis Summary
|
|
Closing cloud run testing draft - Comprehensive Cloud Run health monitoring has been implemented in PR #181 with production-ready monitoring and graceful shutdown capabilities. |
🚀 Unified AI API Cloud Run Deployment & Feature Enablement - FOCUSED
📋 PR Overview
This PR addresses critical deployment and configuration issues for the
samo-unified-apiCloud Run service, enabling all three core AI features (Emotion Detection, Voice Transcription, Text Summarization) and resolving previous rate-limiting blocks. This is a focused fix to get the complete pipeline operational.🎯 Scope: UNIFIED API DEPLOYMENT & FUNCTIONALITY ONLY
What This PR DOES:
✅ Enable All Three AI Features
✅ Fix Cloud Run Deployment Issues
Dockerfile.unifiedfor proper containerization.deploy_unified_cloud_run.sh) to use the correct Dockerfile and set environment variables.✅ Resolve Rate Limiting Conflicts
src/unified_ai_api.pyusing environment variables.✅ Improve Configurability & Dependencies
dependencies/requirements-unified.txtwith all necessary packages for the unified API.✅ Provide Comprehensive Testing & Documentation
test_unified_api_locally.pyfor local validation.DEPLOY_UNIFIED_API.mdwith detailed deployment and testing instructions.What This PR DOES NOT DO:
❌ No new features (only enabling existing ones)
❌ No refactoring (only configuration and dependency updates)
❌ No changes to other Cloud Run services (focused solely on
samo-unified-api)❌ No authentication implementation (future work)
❌ No scope creep (strictly focused on unified API functionality)
🚨 CRITICAL PROBLEM ADDRESSED:
Root Cause:
The
samo-unified-apiCloud Run service was previously deployed but suffered from:This prevented the full unified AI pipeline from being tested and utilized.
📊 Change Summary
🔍 Files Modified/Added
Files Modified:
scripts/deployment/deploy_unified_cloud_run.sh- ✅ UPDATED (Dockerfile, env vars, resources)src/unified_ai_api.py- ✅ UPDATED (Env var config for models & rate limiting)New Files Added:
DEPLOY_UNIFIED_API.md- ✅ NEW (Deployment & Testing Guide)Dockerfile.unified- ✅ NEW (Unified service Dockerfile)dependencies/requirements-unified.txt- ✅ NEW (Comprehensive dependencies)test_audio.wav- ✅ NEW (Empty file for local testing)test_unified_api_locally.py- ✅ NEW (Local testing script)🧪 Testing Improvements Made
1. Full Feature Testability
2. Local Validation
test_unified_api_locally.py) is provided to easily validate all API endpoints locally before deployment.3. Deployment Guide
DEPLOY_UNIFIED_API.mdprovides clear, step-by-step instructions for deployment and testing, includingcurlcommands for each feature.🚀 Benefits of This Focused Approach
For Developers:
For CI/CD:
🔒 SCOPE CONTROL MEASURES
1. Strict Focus:
samo-unified-apifixes2. Clear Documentation:
DEPLOY_UNIFIED_API.mdexplicitly outlines the scope and functionality.🧪 Testing Instructions
After Deployment (using
DEPLOY_UNIFIED_API.md):curl -X POST https://samo-unified-api-[PROJECT_NUMBER]-us-central1.run.app/summarize/text -d "text=Today I had an amazing experience at the conference. I learned so much about AI and ML.&model=t5-small&max_length=50&min_length=10"🎯 Success Criteria
🚀 Future Considerations
Next Phase (Separate PRs):
📋 Review Checklist
Dockerfile.unifiedare correct🎉 CONCLUSION
This PR successfully fixes and redeploys the
samo-unified-apiCloud Run service, making all three critical AI features (Emotion Detection, Voice Transcription, and Text Summarization) fully operational. It resolves key deployment and configuration challenges, providing a stable and functional unified AI pipeline.Ready for review and merge! 🚀
Summary by Sourcery
Fix and redeploy the unified AI API on Cloud Run with proper containerization, configurable environment variables, adjusted rate limits, enhanced logging, consolidated dependencies, and comprehensive testing and documentation.
Bug Fixes:
Enhancements:
Build:
Deployment:
Documentation:
Tests: