Dependency Fix Summary
Issues Fixed
1. β AttributeError: module 'utils' has no attribute 'setup_logging'
Problem: The application was crashing on startup with:
AttributeError: module 'utils' has no attribute 'setup_logging'
Root Cause:
- Python was importing the
utils/package directory instead of finding thesetup_logging()function - The
utils/__init__.pyfile was empty and didn't expose the required functions
Solution:
Updated /workspace/utils/__init__.py to:
- Import
setup_loggerfromutils/logger.py - Create a
setup_logging()wrapper function for backward compatibility - Dynamically import all utility functions from the standalone
utils.pyfile - Properly export all functions via
__all__
2. β Plotly Dependency Management
Problem:
- No graceful handling when plotly is not installed
- Charts would crash the application
Solution:
Updated /workspace/app.py to:
- Check if plotly is available on import
- Set
PLOTLY_AVAILABLEflag - Create dummy plotly objects if not available
- Modified
generate_chart()to show helpful error message when plotly is missing - Log dependency status on startup
3. β Transformers Dependency Management
Problem:
- Inconsistent handling of missing transformers library
- Warning message but no clear status
Solution:
- Enhanced logging to show transformers availability status
- Already had proper handling in
ai_models.pywithTRANSFORMERS_AVAILABLEflag - Added status logging in
app.pyto show all dependency statuses at startup
4. β Requirements Files Updated
Updated /workspace/requirements.txt:
- Added pandas
- Added comments about optional dependencies
- Clear separation between core and optional packages
Updated /workspace/requirements_gradio.txt:
- Marked plotly as REQUIRED for chart features
- Added transformers, torch, and sentencepiece for AI features
- Clear comments explaining which dependencies are optional
Dependency Status
Required Dependencies (Core API)
- β fastapi
- β uvicorn
- β pydantic
- β sqlalchemy
- β httpx
- β websockets
- β requests
- β aiohttp
- β pandas
Required Dependencies (Gradio Dashboard)
- gradio (CRITICAL - app exits if not installed)
- plotly (REQUIRED for charts - graceful degradation if missing)
Optional Dependencies (AI Features)
- transformers (AI sentiment analysis - gracefully disabled if missing)
- torch (required by transformers)
- sentencepiece (required by some models)
Installation Instructions
Install Core API Dependencies
pip install -r requirements.txt
Install Gradio Dashboard Dependencies
pip install -r requirements_gradio.txt
Install AI/ML Dependencies (Optional)
pip install transformers torch sentencepiece
Quick Install (All Features)
pip install -r requirements.txt
pip install -r requirements_gradio.txt
Testing
Run the dependency test script:
python3 test_dependencies.py
This will check:
- β utils.setup_logging() functionality
- β All utility helper functions
- β Availability of gradio, plotly, transformers
- β AI models module
- β app.py syntax validation
Startup Behavior
Before Fix
Traceback (most recent call last):
File "/app/app.py", line 27, in <module>
logger = utils.setup_logging()
AttributeError: module 'utils' has no attribute 'setup_logging'
After Fix
{"timestamp": "2025-11-16T15:47:32.594534Z", "level": "INFO", "logger": "crypto_aggregator", ...}
{"timestamp": "...", "level": "INFO", "message": "Dependency Status:"}
{"timestamp": "...", "level": "INFO", "message": " - Gradio: β Available"}
{"timestamp": "...", "level": "INFO", "message": " - Plotly: β Available"}
{"timestamp": "...", "level": "INFO", "message": " - Transformers: β Missing (AI features disabled)"}
Graceful Degradation
- No Gradio: Application exits with clear error message
- No Plotly: Charts show helpful message, dashboard continues to work
- No Transformers: AI features disabled, rest of app works normally
Files Modified
/workspace/utils/__init__.py- Added setup_logging() and utility function exports/workspace/app.py- Added dependency checking and graceful handling/workspace/requirements.txt- Added pandas and documentation/workspace/requirements_gradio.txt- Added transformers and AI dependencies
Files Created
/workspace/test_dependencies.py- Comprehensive dependency testing script/workspace/DEPENDENCY_FIX_SUMMARY.md- This documentation
Verification
All fixes have been tested and verified:
- β
utils.setup_logging()works correctly - β All utility functions accessible (format_number, calculate_rsi, etc.)
- β App handles missing dependencies gracefully
- β Requirements files updated with all dependencies
- β Clear installation instructions provided
- β Test script created for future validation
Next Steps
To run the application with all features:
Install dependencies:
pip install -r requirements_gradio.txtRun the application:
python3 app.py
The application will now start successfully and show clear status messages about which features are available based on installed dependencies.