refactor: introduce Pydantic settings for centralized configuration management#159
Closed
priyankeshh wants to merge 3 commits intomarker-deployfrom
Closed
refactor: introduce Pydantic settings for centralized configuration management#159priyankeshh wants to merge 3 commits intomarker-deployfrom
priyankeshh wants to merge 3 commits intomarker-deployfrom
Conversation
- Add new settings to config.py for Marker, chat validation, and user migration - Replace os.getenv calls with settings object in multiple modules - Improve configuration management and type safety
- Add comprehensive field documentation and validators to Settings class - Add field-level descriptions using Pydantic Field() - Implement validators for conditional requirements (Modal, S3) - Add mask_secrets() method for safe configuration debugging - Refactor marker_client.py to use centralized settings - Create .env.example template with all configuration options - Add comprehensive configuration documentation for admins and developers - Include usage examples, troubleshooting, and best practices
Member
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🎯 Overview
This PR refactors the Extralit Server configuration system to use Pydantic Settings, providing type-safe, validated, and well-documented configuration management. This replaces scattered
os.getenv()calls throughout the codebase with a centralizedSettingsclass.🚀 Motivation
Problems with the old approach:
os.getenv()Benefits of the new approach:
SecretStrmask_secrets()method📋 Changes Made
Core Configuration System
New Files:
extralit-server/.env.example- Comprehensive configuration template with examples and commentsEnhanced Features:
Field()with descriptionsSecretStrtypemask_secrets()method for safe configuration debuggingCode Refactoring
Migrated to use settings:
Documentation
New Documentation:
📘
extralit/docs/admin_guide/configuration.md(346 lines)📗
extralit/docs/community/developer/configuration-system.md(462 lines)🔧 Configuration Categories
The new settings system organizes configuration into logical groups:
✅ Validation Examples
Modal Configuration Validation:
S3 Configuration Validation:
🔒 Security Improvements
SecretStrto prevent accidental loggingmask_secrets()method to safely export configuration📊 Impact
Files Changed: 11 files
Lines Added: 1,440+ lines
Lines Removed: 18 lines
Net Addition: +1,422 lines
Configuration Options Documented: 40+
Validators Added: 2 (Modal URL, S3 completeness)
Documentation Pages: 2 (Admin + Developer guides)
🧪 Testing
The refactoring maintains 100% backward compatibility:
🚦 Migration Path
For Users:
.envfiles - no changes required.env.examplefor new settings documentationFor Developers:
📚 Related Documentation
🔍 Review Focus Areas
📝 Notes
os.environ(e.g., OAuth integration, OpenCV runtime config)extralit/src/extralit/**) remains independent from server config✨ Future Enhancements
Potential follow-up improvements (out of scope for this PR):
🙏 Checklist
.env.examplecreated with all options