Migration Summary: Making HelpDesk and Google Sheets Optional¶
What Was Done¶
1. Storage Abstraction Layer¶
- Created
src/pytanis/storage/
with abstract base classes - Implemented
LocalFileClient
for CSV/Excel file storage - Created
GoogleSheetsStorageClient
adapter for existing functionality - All storage providers implement the same interface
2. Communication Abstraction Layer¶
- Created
src/pytanis/communication/
with abstract base classes - Created adapters for existing Mailgun and HelpDesk clients
- Defined standard
EmailMessage
andTicket
data classes
3. Optional Dependencies¶
- Updated
pyproject.toml
to move dependencies to extras: pytanis[google]
- Google Sheets supportpytanis[helpdesk]
- HelpDesk supportpytanis[mailgun]
- Mailgun supportpytanis[jupyter]
- Jupyter notebookspytanis[optimization]
- Schedule optimizationpytanis[all]
- Everything
4. Configuration Updates¶
- Made Google, HelpDesk, and Mailgun sections optional in Config
- Added new Storage and Communication configuration sections
- Backward compatible - old configs still work
5. Lazy Loading¶
GSheetsClient
andHelpDeskClient
are now lazy-loaded- Clear error messages when dependencies are missing
- Maintains backward compatibility
6. Factory Functions¶
get_storage_client()
- Returns appropriate storage backendget_mail_client()
- Returns appropriate email clientget_ticket_client()
- Returns appropriate ticket client
Benefits¶
- Reduced Dependencies: Core installation is much lighter
- Flexibility: Easy to switch between storage/communication providers
- Testing: Can use local storage for tests instead of Google Sheets
- Extensibility: Easy to add new providers
- Backward Compatible: Existing code continues to work
Migration Path¶
For existing users:
# If using all features
pip install pytanis[all]
# Or only what you need
pip install pytanis[google,mailgun]
New code can use the abstraction:
from pytanis import get_storage_client
storage = get_storage_client() # Uses config to determine provider
df = storage.read_sheet('data', 'Sheet1')
Old code still works:
from pytanis import GSheetsClient # Still works if pytanis[google] installed
client = GSheetsClient()