nivakaran commited on
Commit
98f8694
·
verified ·
1 Parent(s): 7f2daed

Upload folder using huggingface_hub

Browse files
README.md CHANGED
@@ -1,4 +1,4 @@
1
- ---
2
  title: Roger Intelligence Platform
3
  emoji: ⚡
4
  colorFrom: blue
@@ -28,11 +28,19 @@ A multi-agent AI system that aggregates intelligence from 47+ data sources to pr
28
  - Social Media Monitor (Reddit, Twitter, Facebook, Threads, BlueSky)
29
  - Political Intelligence (Gazette, Parliament, District Social Media)
30
  - Economic Analysis (CSE Stock Market + Technical Indicators)
31
- - Meteorological Alerts (DMC Weather + RiverNet + **FloodWatch Integration** 🆕)
32
  - Intelligence Agent (Brand Monitoring + Threat Detection + **User-Configurable Targets**)
33
  - Data Retrieval Orchestrator (Web Scraping)
34
  - Vectorization Agent (Multilingual BERT Embeddings + Anomaly Detection)
35
 
 
 
 
 
 
 
 
 
36
  ✅ **ML Anomaly Detection Pipeline** (Integrated into Graph):
37
  - Language-specific BERT models (Sinhala, Tamil, English)
38
  - Real-time anomaly inference on every graph cycle
@@ -40,31 +48,31 @@ A multi-agent AI system that aggregates intelligence from 47+ data sources to pr
40
  - Anomaly Detection (Isolation Forest, LOF)
41
  - MLflow + DagsHub tracking
42
 
43
- ✅ **Weather Prediction ML Pipeline** 🆕:
44
  - LSTM Neural Network (30-day sequences)
45
  - Predicts: Temperature, Rainfall, Flood Risk, Severity
46
  - 21 weather stations → 25 districts
47
  - Airflow DAG runs daily at 4 AM
48
 
49
- ✅ **Currency Prediction ML Pipeline** 🆕:
50
  - GRU Neural Network (optimized for 8GB RAM)
51
  - Predicts: USD/LKR exchange rate
52
  - Features: Technical indicators + CSE + Gold + Oil + USD Index
53
  - MLflow tracking + Airflow DAG at 4 AM
54
 
55
- ✅ **Stock Price Prediction ML Pipeline** 🆕:
56
  - Multi-Architecture: LSTM, GRU, BiLSTM, BiGRU
57
  - Optuna hyperparameter tuning (30 trials per stock)
58
  - Per-stock best model selection
59
  - 10 top CSE stocks (JKH, COMB, DIAL, HNB, etc.)
60
 
61
- ✅ **RAG-Powered Chatbot** 🆕:
62
  - Chat-history aware Q&A
63
  - Queries all ChromaDB intelligence collections
64
  - Domain filtering (political, economic, weather, social)
65
  - Floating chat UI in dashboard
66
 
67
- ✅ **Trending/Velocity Detection** 🆕:
68
  - SQLite-based topic frequency tracking (24-hour rolling window)
69
  - Momentum calculation: `current_hour / avg_last_6_hours`
70
  - Spike alerts when topic volume > 3x baseline
@@ -74,29 +82,29 @@ A multi-agent AI system that aggregates intelligence from 47+ data sources to pr
74
  - Live Intelligence Feed
75
  - Floating AI Chatbox
76
  - Weather Predictions Tab
77
- - **Live Satellite/Weather Map** (Windy.com) 🆕
78
- - **National Flood Threat Score** 🆕
79
- - **30-Year Historical Climate Analysis** 🆕
80
- - **Trending Topics & Spike Alerts** 🆕
81
- - **Enhanced Operational Indicators** 🆕 (infrastructure_health, regulatory_activity, investment_climate)
82
  - Operational Risk Radar
83
  - ML Anomaly Detection Display
84
  - Market Predictions with Moving Averages
85
  - Risk & Opportunity Classification
86
 
87
- ✅ **Weather Data Scraper for ML Training** 🆕:
88
  - Open-Meteo API (free historical data)
89
  - NASA FIRMS (fire/heat detection)
90
  - All 25 districts coverage
91
  - Year-wise CSV export for model training
92
 
93
- ✅ **Operational Dashboard Metrics** 🆕:
94
  - **Logistics Friction**: Average confidence of mobility/social domain risk events
95
  - **Compliance Volatility**: Average confidence of political domain risks
96
  - **Market Instability**: Average confidence of market/economical domain risks
97
  - **Opportunity Index**: Average confidence of opportunity-classified events
98
 
99
- ✅ **Multi-District Province-Aware Event Categorization** 🆕:
100
  - Events mentioning provinces are displayed in all constituent districts
101
  - Supports: Western, Southern, Central, Northern, Eastern, Sabaragamuwa, Uva, North Western, North Central provinces
102
  - Both frontend (MapView, DistrictInfoPanel) and backend are synchronized
@@ -126,7 +134,7 @@ A multi-agent AI system that aggregates intelligence from 47+ data sources to pr
126
  │ │ (Rank & Dedupe) │ │
127
  │ └─────────┬──────────┘ │
128
  │ ┌─────────▼──────────┐ │
129
- │ │ Vectorization │ ← NEW
130
  │ │ Agent (Optional) │ │
131
  │ └─────────┬──────────┘ │
132
  │ ┌─────────▼──────────┐ │
@@ -168,7 +176,7 @@ graph TD
168
  - Loop control with configurable intervals
169
  - Real-time WebSocket broadcasting
170
 
171
- **Architecture Improvements (v2.1):** 🆕
172
  - **Rate Limiting**: Domain-specific rate limits prevent anti-bot detection
173
  - Twitter: 15 RPM, LinkedIn: 10 RPM, News: 60 RPM
174
  - Thread-safe semaphores for max concurrent requests
@@ -226,7 +234,7 @@ graph TD
226
  ---
227
 
228
  ### 4. Meteorological Agent Graph (`meteorologicalAgentGraph.py`)
229
- **Weather & Disaster Monitoring + FloodWatch Integration** 🆕
230
 
231
  ```
232
  ┌─────────────────────────────────────┐
@@ -242,13 +250,13 @@ graph TD
242
 
243
 
244
  ┌─────────────────────────────────────┐
245
- │ FloodWatch Historical Data 🆕
246
  │ (30-year climate analysis) │
247
  └─────────────┬───────────────────────┘
248
 
249
 
250
  ┌─────────────────────────────────────┐
251
- │ National Threat Calculator 🆕
252
  │ (Aggregated flood risk 0-100) │
253
  └─────────────┬───────────────────────┘
254
 
@@ -265,7 +273,7 @@ graph TD
265
  - 🟠 Warning: Take precautions
266
  - 🔴 Critical: Immediate action required
267
 
268
- **FloodWatch Features (New):**
269
  | Feature | Description |
270
  |---------|-------------|
271
  | **Historical Analysis** | 30-year climate data (1995-2025) |
@@ -289,11 +297,11 @@ graph TD
289
  ---
290
 
291
  ### 6. Intelligence Agent Graph (`intelligenceAgentGraph.py`)
292
- **Brand & Threat Monitoring + User-Configurable Targets** 🆕
293
 
294
  ```
295
  ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
296
- │ Brand Monitor │ │ Threat Scanner │ │ User Targets 🆕
297
  │ - Company news │ │ - Security │ │ - Custom keys │
298
  │ - Competitor │ │ - Compliance │ │ - User profiles │
299
  │ - Market share │ │ - Geopolitical │ │ - Products │
@@ -307,7 +315,7 @@ graph TD
307
  └─────────────────────┘
308
  ```
309
 
310
- **User-Configurable Monitoring** 🆕:
311
  Users can define custom monitoring targets via the frontend settings panel or API:
312
 
313
  | Config Type | Description | Example |
@@ -353,7 +361,7 @@ DELETE /api/intel/config/remove?target_type=profile&value=CompetitorX&platform=t
353
 
354
  ---
355
 
356
- ### 8. Vectorization Agent Graph (`vectorizationAgentGraph.py`) 🆕
357
  **6-Step Multilingual NLP Pipeline with Anomaly + Trending Detection**
358
 
359
  ```
@@ -383,7 +391,7 @@ DELETE /api/intel/config/remove?target_type=profile&value=CompetitorX&platform=t
383
 
384
 
385
  ┌─────────────────────────────────────────────────┐
386
- │ Step 4: Trending Detection 🆕
387
  │ - Entity extraction (hashtags, proper nouns) │
388
  │ - Momentum: current_hour / avg_last_6_hours │
389
  │ - Spike alerts when momentum > 3x │
@@ -413,7 +421,7 @@ DELETE /api/intel/config/remove?target_type=profile&value=CompetitorX&platform=t
413
 
414
  ---
415
 
416
- ### 10. Weather Prediction Pipeline (`models/weather-prediction/`) 🆕
417
  **LSTM-Based Multi-District Weather Forecasting**
418
 
419
  ```
@@ -464,7 +472,7 @@ python main.py --mode train --station COLOMBO
464
 
465
  ---
466
 
467
- ### 11. Currency Prediction Pipeline (`models/currency-volatility-prediction/`) 🆕
468
  **GRU-Based USD/LKR Exchange Rate Forecasting**
469
 
470
  ```
@@ -599,7 +607,7 @@ mlflow.sklearn.log_model(model, "model")
599
 
600
  ---
601
 
602
- ## 🌧️ Weather Data Scraper (`scripts/scrape_weather_data.py`) 🆕
603
 
604
  **Historical weather data collection for ML model training**
605
 
@@ -713,8 +721,8 @@ python models/anomaly-detection/download_models.py
713
  | `/api/weather/predictions` | GET | All district forecasts |
714
  | `/api/weather/predictions/{district}` | GET | Single district |
715
  | `/api/weather/model/status` | GET | Weather model info |
716
- | `/api/weather/historical` | GET | 30-year climate analysis 🆕 |
717
- | `/api/weather/threat` | GET | National flood threat score 🆕 |
718
  | `/api/currency/prediction` | GET | USD/LKR next-day forecast |
719
  | `/api/currency/history` | GET | Historical rates |
720
  | `/api/currency/model/status` | GET | Currency model info |
@@ -724,6 +732,12 @@ python models/anomaly-detection/download_models.py
724
  | `/api/rag/chat` | POST | Chat with RAG |
725
  | `/api/rag/stats` | GET | RAG system stats |
726
  | `/api/rag/clear` | POST | Clear chat history |
 
 
 
 
 
 
727
 
728
  ### WebSocket
729
  - `ws://localhost:8000/ws` - Real-time updates
@@ -750,7 +764,7 @@ astro dev start
750
  # Open http://localhost:8080
751
  ```
752
 
753
- ### DAG: `weather_prediction_daily` 🆕
754
 
755
  ```
756
  ingest_data → train_models → generate_predictions → publish_predictions
@@ -764,7 +778,7 @@ ingest_data → train_models → generate_predictions → publish_predictions
764
  - Generate 25-district predictions
765
  - Save to JSON for API
766
 
767
- ### DAG: `currency_prediction_daily` 🆕
768
 
769
  ```
770
  ingest_data → train_model → generate_prediction → publish_prediction
@@ -800,9 +814,9 @@ Roger-Ultimate/
800
  │ ├── storage/ # ChromaDB, SQLite, Neo4j stores
801
  │ ├── rag.py # RAG chatbot
802
  │ └── utils/
803
- │ └── utils.py # Tools incl. FloodWatch 🆕
804
  ├── scripts/
805
- │ └── scrape_weather_data.py # Weather data scraper 🆕
806
  ├── models/
807
  │ ├── anomaly-detection/ # ML Anomaly Pipeline
808
  │ │ ├── src/
@@ -825,7 +839,7 @@ Roger-Ultimate/
825
  │ ├── artifacts/ # Trained GRU model
826
  │ └── main.py # CLI entry point
827
  ├── datasets/
828
- │ └── weather/ # Scraped weather CSVs 🆕
829
  ├── frontend/
830
  │ └── app/
831
  │ ├── components/
@@ -833,16 +847,16 @@ Roger-Ultimate/
833
  │ │ │ ├── AnomalyDetection.tsx
834
  │ │ │ ├── WeatherPredictions.tsx
835
  │ │ │ ├── CurrencyPrediction.tsx
836
- │ │ │ ├── NationalThreatCard.tsx # Flood threat score 🆕
837
- │ │ │ ├── HistoricalIntel.tsx # 30-year climate 🆕
838
  │ │ │ └── ...
839
  │ │ ├── map/
840
  │ │ │ ├── MapView.tsx
841
- │ │ │ └── SatelliteView.tsx # Windy.com embed 🆕
842
  │ │ ├── FloatingChatBox.tsx # RAG chat UI
843
  │ │ └── ...
844
  │ └── pages/
845
- │ └── Index.tsx # 7 tabs incl. SATELLITE 🆕
846
  ├── main.py # FastAPI backend
847
  ├── start.sh # Startup script
848
  └── requirements.txt
@@ -1034,3 +1048,4 @@ MIT License - Built for Production
1034
  - **Optuna** - Hyperparameter optimization
1035
  - **MLflow** - Experiment tracking
1036
  - Sri Lankan government for open data sources
 
 
1
+ ---
2
  title: Roger Intelligence Platform
3
  emoji: ⚡
4
  colorFrom: blue
 
28
  - Social Media Monitor (Reddit, Twitter, Facebook, Threads, BlueSky)
29
  - Political Intelligence (Gazette, Parliament, District Social Media)
30
  - Economic Analysis (CSE Stock Market + Technical Indicators)
31
+ - Meteorological Alerts (DMC Weather + RiverNet + **FloodWatch Integration**)
32
  - Intelligence Agent (Brand Monitoring + Threat Detection + **User-Configurable Targets**)
33
  - Data Retrieval Orchestrator (Web Scraping)
34
  - Vectorization Agent (Multilingual BERT Embeddings + Anomaly Detection)
35
 
36
+ ✅ **Situational Awareness Dashboard**:
37
+ - **CEB Power Status** - Load shedding / power outage monitoring
38
+ - **Fuel Prices** - Petrol 92/95, Diesel, Kerosene (CEYPETCO)
39
+ - **CBSL Economic Indicators** - Inflation, policy rates, forex reserves, USD/LKR
40
+ - **Health Alerts** - Dengue case tracking, disease outbreak monitoring
41
+ - **Commodity Prices** - 15 essential goods (rice, sugar, gas, eggs, etc.)
42
+ - **Water Supply Status** - NWSDB disruption alerts
43
+
44
  ✅ **ML Anomaly Detection Pipeline** (Integrated into Graph):
45
  - Language-specific BERT models (Sinhala, Tamil, English)
46
  - Real-time anomaly inference on every graph cycle
 
48
  - Anomaly Detection (Isolation Forest, LOF)
49
  - MLflow + DagsHub tracking
50
 
51
+ ✅ **Weather Prediction ML Pipeline**:
52
  - LSTM Neural Network (30-day sequences)
53
  - Predicts: Temperature, Rainfall, Flood Risk, Severity
54
  - 21 weather stations → 25 districts
55
  - Airflow DAG runs daily at 4 AM
56
 
57
+ ✅ **Currency Prediction ML Pipeline**:
58
  - GRU Neural Network (optimized for 8GB RAM)
59
  - Predicts: USD/LKR exchange rate
60
  - Features: Technical indicators + CSE + Gold + Oil + USD Index
61
  - MLflow tracking + Airflow DAG at 4 AM
62
 
63
+ ✅ **Stock Price Prediction ML Pipeline**:
64
  - Multi-Architecture: LSTM, GRU, BiLSTM, BiGRU
65
  - Optuna hyperparameter tuning (30 trials per stock)
66
  - Per-stock best model selection
67
  - 10 top CSE stocks (JKH, COMB, DIAL, HNB, etc.)
68
 
69
+ ✅ **RAG-Powered Chatbot**:
70
  - Chat-history aware Q&A
71
  - Queries all ChromaDB intelligence collections
72
  - Domain filtering (political, economic, weather, social)
73
  - Floating chat UI in dashboard
74
 
75
+ ✅ **Trending/Velocity Detection**:
76
  - SQLite-based topic frequency tracking (24-hour rolling window)
77
  - Momentum calculation: `current_hour / avg_last_6_hours`
78
  - Spike alerts when topic volume > 3x baseline
 
82
  - Live Intelligence Feed
83
  - Floating AI Chatbox
84
  - Weather Predictions Tab
85
+ - **Live Satellite/Weather Map** (Windy.com)
86
+ - **National Flood Threat Score**
87
+ - **30-Year Historical Climate Analysis**
88
+ - **Trending Topics & Spike Alerts**
89
+ - **Enhanced Operational Indicators** (infrastructure_health, regulatory_activity, investment_climate)
90
  - Operational Risk Radar
91
  - ML Anomaly Detection Display
92
  - Market Predictions with Moving Averages
93
  - Risk & Opportunity Classification
94
 
95
+ ✅ **Weather Data Scraper for ML Training**:
96
  - Open-Meteo API (free historical data)
97
  - NASA FIRMS (fire/heat detection)
98
  - All 25 districts coverage
99
  - Year-wise CSV export for model training
100
 
101
+ ✅ **Operational Dashboard Metrics**:
102
  - **Logistics Friction**: Average confidence of mobility/social domain risk events
103
  - **Compliance Volatility**: Average confidence of political domain risks
104
  - **Market Instability**: Average confidence of market/economical domain risks
105
  - **Opportunity Index**: Average confidence of opportunity-classified events
106
 
107
+ ✅ **Multi-District Province-Aware Event Categorization**:
108
  - Events mentioning provinces are displayed in all constituent districts
109
  - Supports: Western, Southern, Central, Northern, Eastern, Sabaragamuwa, Uva, North Western, North Central provinces
110
  - Both frontend (MapView, DistrictInfoPanel) and backend are synchronized
 
134
  │ │ (Rank & Dedupe) │ │
135
  │ └─────────┬──────────┘ │
136
  │ ┌─────────▼──────────┐ │
137
+ │ │ Vectorization │
138
  │ │ Agent (Optional) │ │
139
  │ └─────────┬──────────┘ │
140
  │ ┌─────────▼──────────┐ │
 
176
  - Loop control with configurable intervals
177
  - Real-time WebSocket broadcasting
178
 
179
+ **Architecture Improvements (v2.1):**
180
  - **Rate Limiting**: Domain-specific rate limits prevent anti-bot detection
181
  - Twitter: 15 RPM, LinkedIn: 10 RPM, News: 60 RPM
182
  - Thread-safe semaphores for max concurrent requests
 
234
  ---
235
 
236
  ### 4. Meteorological Agent Graph (`meteorologicalAgentGraph.py`)
237
+ **Weather & Disaster Monitoring + FloodWatch Integration**
238
 
239
  ```
240
  ┌─────────────────────────────────────┐
 
250
 
251
 
252
  ┌─────────────────────────────────────┐
253
+ │ FloodWatch Historical Data │
254
  │ (30-year climate analysis) │
255
  └─────────────┬───────────────────────┘
256
 
257
 
258
  ┌─────────────────────────────────────┐
259
+ │ National Threat Calculator │
260
  │ (Aggregated flood risk 0-100) │
261
  └─────────────┬───────────────────────┘
262
 
 
273
  - 🟠 Warning: Take precautions
274
  - 🔴 Critical: Immediate action required
275
 
276
+ **FloodWatch Features:**
277
  | Feature | Description |
278
  |---------|-------------|
279
  | **Historical Analysis** | 30-year climate data (1995-2025) |
 
297
  ---
298
 
299
  ### 6. Intelligence Agent Graph (`intelligenceAgentGraph.py`)
300
+ **Brand & Threat Monitoring + User-Configurable Targets**
301
 
302
  ```
303
  ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
304
+ │ Brand Monitor │ │ Threat Scanner │ │ User Targets │
305
  │ - Company news │ │ - Security │ │ - Custom keys │
306
  │ - Competitor │ │ - Compliance │ │ - User profiles │
307
  │ - Market share │ │ - Geopolitical │ │ - Products │
 
315
  └─────────────────────┘
316
  ```
317
 
318
+ **User-Configurable Monitoring**:
319
  Users can define custom monitoring targets via the frontend settings panel or API:
320
 
321
  | Config Type | Description | Example |
 
361
 
362
  ---
363
 
364
+ ### 8. Vectorization Agent Graph (`vectorizationAgentGraph.py`)
365
  **6-Step Multilingual NLP Pipeline with Anomaly + Trending Detection**
366
 
367
  ```
 
391
 
392
 
393
  ┌─────────────────────────────────────────────────┐
394
+ │ Step 4: Trending Detection │
395
  │ - Entity extraction (hashtags, proper nouns) │
396
  │ - Momentum: current_hour / avg_last_6_hours │
397
  │ - Spike alerts when momentum > 3x │
 
421
 
422
  ---
423
 
424
+ ### 10. Weather Prediction Pipeline (`models/weather-prediction/`)
425
  **LSTM-Based Multi-District Weather Forecasting**
426
 
427
  ```
 
472
 
473
  ---
474
 
475
+ ### 11. Currency Prediction Pipeline (`models/currency-volatility-prediction/`)
476
  **GRU-Based USD/LKR Exchange Rate Forecasting**
477
 
478
  ```
 
607
 
608
  ---
609
 
610
+ ## 🌧️ Weather Data Scraper (`scripts/scrape_weather_data.py`)
611
 
612
  **Historical weather data collection for ML model training**
613
 
 
721
  | `/api/weather/predictions` | GET | All district forecasts |
722
  | `/api/weather/predictions/{district}` | GET | Single district |
723
  | `/api/weather/model/status` | GET | Weather model info |
724
+ | `/api/weather/historical` | GET | 30-year climate analysis |
725
+ | `/api/weather/threat` | GET | National flood threat score |
726
  | `/api/currency/prediction` | GET | USD/LKR next-day forecast |
727
  | `/api/currency/history` | GET | Historical rates |
728
  | `/api/currency/model/status` | GET | Currency model info |
 
732
  | `/api/rag/chat` | POST | Chat with RAG |
733
  | `/api/rag/stats` | GET | RAG system stats |
734
  | `/api/rag/clear` | POST | Clear chat history |
735
+ | `/api/power` | GET | CEB power/load shedding status |
736
+ | `/api/fuel` | GET | Current fuel prices |
737
+ | `/api/economy` | GET | CBSL economic indicators |
738
+ | `/api/health` | GET | Health alerts & dengue data |
739
+ | `/api/commodities` | GET | Essential goods prices |
740
+ | `/api/water` | GET | Water supply disruptions |
741
 
742
  ### WebSocket
743
  - `ws://localhost:8000/ws` - Real-time updates
 
764
  # Open http://localhost:8080
765
  ```
766
 
767
+ ### DAG: `weather_prediction_daily`
768
 
769
  ```
770
  ingest_data → train_models → generate_predictions → publish_predictions
 
778
  - Generate 25-district predictions
779
  - Save to JSON for API
780
 
781
+ ### DAG: `currency_prediction_daily`
782
 
783
  ```
784
  ingest_data → train_model → generate_prediction → publish_prediction
 
814
  │ ├── storage/ # ChromaDB, SQLite, Neo4j stores
815
  │ ├── rag.py # RAG chatbot
816
  │ └── utils/
817
+ │ └── utils.py # Tools incl. FloodWatch
818
  ├── scripts/
819
+ │ └── scrape_weather_data.py # Weather data scraper
820
  ├── models/
821
  │ ├── anomaly-detection/ # ML Anomaly Pipeline
822
  │ │ ├── src/
 
839
  │ ├── artifacts/ # Trained GRU model
840
  │ └── main.py # CLI entry point
841
  ├── datasets/
842
+ │ └── weather/ # Scraped weather CSVs
843
  ├── frontend/
844
  │ └── app/
845
  │ ├── components/
 
847
  │ │ │ ├── AnomalyDetection.tsx
848
  │ │ │ ├── WeatherPredictions.tsx
849
  │ │ │ ├── CurrencyPrediction.tsx
850
+ │ │ │ ├── NationalThreatCard.tsx # Flood threat score
851
+ │ │ │ ├── HistoricalIntel.tsx # 30-year climate
852
  │ │ │ └── ...
853
  │ │ ├── map/
854
  │ │ │ ├── MapView.tsx
855
+ │ │ │ └── SatelliteView.tsx # Windy.com embed
856
  │ │ ├── FloatingChatBox.tsx # RAG chat UI
857
  │ │ └── ...
858
  │ └── pages/
859
+ │ └── Index.tsx # 7 tabs incl. SATELLITE
860
  ├── main.py # FastAPI backend
861
  ├── start.sh # Startup script
862
  └── requirements.txt
 
1048
  - **Optuna** - Hyperparameter optimization
1049
  - **MLflow** - Experiment tracking
1050
  - Sri Lankan government for open data sources
1051
+
main.py CHANGED
@@ -495,6 +495,12 @@ def run_graph_loop():
495
  main_event_loop
496
  )
497
 
 
 
 
 
 
 
498
  except Exception as e:
499
  logger.error(f"[GRAPH THREAD] Error in cycle #{cycle_count}: {e}", exc_info=True)
500
 
@@ -508,6 +514,8 @@ def run_graph_loop():
508
  logger.info(f"[GRAPH THREAD] Waiting {wait_time:.1f}s before next cycle...")
509
  # Use Event.wait() for interruptible sleep instead of time.sleep()
510
  shutdown_event.wait(timeout=wait_time)
 
 
511
 
512
 
513
 
@@ -1676,6 +1684,7 @@ def get_weather_predictor():
1676
  try:
1677
  import importlib.util
1678
  from pathlib import Path
 
1679
 
1680
  # Use importlib.util for fully isolated import (avoids package collisions)
1681
  weather_src = Path(__file__).parent / "models" / "weather-prediction" / "src"
@@ -1685,39 +1694,52 @@ def get_weather_predictor():
1685
  logger.error(f"[WeatherAPI] predictor.py not found at {predictor_path}")
1686
  return None
1687
 
1688
- # First, ensure entity module is loadable
1689
- entity_path = weather_src / "entity" / "config_entity.py"
1690
- if entity_path.exists():
1691
- entity_spec = importlib.util.spec_from_file_location(
1692
- "weather_config_entity",
1693
- str(entity_path)
1694
- )
1695
- entity_module = importlib.util.module_from_spec(entity_spec)
1696
- sys.modules["weather_config_entity"] = entity_module
1697
- entity_spec.loader.exec_module(entity_module)
1698
-
1699
- # Add weather src to path temporarily for relative imports
1700
- # sys is already imported at top of file
 
 
 
1701
  weather_src_str = str(weather_src)
1702
  if weather_src_str not in sys.path:
1703
  sys.path.insert(0, weather_src_str)
1704
 
1705
- # Now load predictor module
1706
- spec = importlib.util.spec_from_file_location(
1707
- "weather_predictor_module",
1708
- str(predictor_path)
1709
- )
1710
- module = importlib.util.module_from_spec(spec)
1711
- spec.loader.exec_module(module)
 
 
 
 
 
 
 
 
 
 
 
1712
 
1713
- _weather_predictor = module.WeatherPredictor()
1714
- logger.info("[WeatherAPI] ✓ Weather predictor initialized via isolated import")
1715
  return _weather_predictor
1716
 
 
1717
  except Exception as e:
1718
  logger.error(f"[WeatherAPI] Failed to initialize predictor: {e}")
1719
  import traceback
1720
- logger.debug(traceback.format_exc())
1721
  return None
1722
 
1723
 
 
495
  main_event_loop
496
  )
497
 
498
+ except RuntimeError as e:
499
+ if "cannot schedule new futures after interpreter shutdown" in str(e):
500
+ logger.warning("[GRAPH THREAD] Interpreter shutting down, stopping graph loop gracefully")
501
+ break # Exit the loop cleanly
502
+ else:
503
+ logger.error(f"[GRAPH THREAD] RuntimeError in cycle #{cycle_count}: {e}", exc_info=True)
504
  except Exception as e:
505
  logger.error(f"[GRAPH THREAD] Error in cycle #{cycle_count}: {e}", exc_info=True)
506
 
 
514
  logger.info(f"[GRAPH THREAD] Waiting {wait_time:.1f}s before next cycle...")
515
  # Use Event.wait() for interruptible sleep instead of time.sleep()
516
  shutdown_event.wait(timeout=wait_time)
517
+
518
+ logger.info("[GRAPH THREAD] Graph loop stopped")
519
 
520
 
521
 
 
1684
  try:
1685
  import importlib.util
1686
  from pathlib import Path
1687
+ import json
1688
 
1689
  # Use importlib.util for fully isolated import (avoids package collisions)
1690
  weather_src = Path(__file__).parent / "models" / "weather-prediction" / "src"
 
1694
  logger.error(f"[WeatherAPI] predictor.py not found at {predictor_path}")
1695
  return None
1696
 
1697
+ # CRITICAL: Remove any conflicting paths (currency-volatility-prediction/src)
1698
+ # to avoid entity.config_entity collision
1699
+ currency_src = str(Path(__file__).parent / "models" / "currency-volatility-prediction" / "src")
1700
+ stock_src = str(Path(__file__).parent / "models" / "stock-price-prediction" / "src")
1701
+ anomaly_src = str(Path(__file__).parent / "models" / "anomaly-detection" / "src")
1702
+
1703
+ original_path = sys.path.copy()
1704
+ sys.path = [p for p in sys.path if currency_src not in p and stock_src not in p and anomaly_src not in p]
1705
+
1706
+ # CRITICAL: Clear cached entity modules that may have been imported from wrong path
1707
+ modules_to_clear = [k for k in sys.modules.keys() if 'entity' in k.lower() or 'config_entity' in k.lower()]
1708
+ saved_modules = {}
1709
+ for mod_name in modules_to_clear:
1710
+ saved_modules[mod_name] = sys.modules.pop(mod_name, None)
1711
+
1712
+ # Add weather src to path FIRST for relative imports
1713
  weather_src_str = str(weather_src)
1714
  if weather_src_str not in sys.path:
1715
  sys.path.insert(0, weather_src_str)
1716
 
1717
+ try:
1718
+ # Now load predictor module
1719
+ spec = importlib.util.spec_from_file_location(
1720
+ "weather_predictor_module",
1721
+ str(predictor_path)
1722
+ )
1723
+ module = importlib.util.module_from_spec(spec)
1724
+ spec.loader.exec_module(module)
1725
+
1726
+ _weather_predictor = module.WeatherPredictor()
1727
+ logger.info("[WeatherAPI] ✓ Weather predictor initialized via isolated import")
1728
+ finally:
1729
+ # Restore original path
1730
+ sys.path = original_path
1731
+ # Restore saved modules (to avoid breaking other parts of the system)
1732
+ for mod_name, mod in saved_modules.items():
1733
+ if mod is not None:
1734
+ sys.modules[mod_name] = mod
1735
 
 
 
1736
  return _weather_predictor
1737
 
1738
+
1739
  except Exception as e:
1740
  logger.error(f"[WeatherAPI] Failed to initialize predictor: {e}")
1741
  import traceback
1742
+ logger.error(f"[WeatherAPI] Full traceback:\n{traceback.format_exc()}")
1743
  return None
1744
 
1745
 
models/currency-volatility-prediction/src/exception/exception.py CHANGED
@@ -1,5 +1,5 @@
1
  import sys
2
- from src.logging import logger
3
 
4
  class NetworkSecurityException(Exception):
5
  def __init__(self,error_message,error_details:sys):
 
1
  import sys
2
+ from src.log_utils import logger
3
 
4
  class NetworkSecurityException(Exception):
5
  def __init__(self,error_message,error_details:sys):
models/currency-volatility-prediction/src/log_utils/__init__.py ADDED
File without changes
models/currency-volatility-prediction/src/log_utils/logger.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import logging
2
+ import os
3
+ from datetime import datetime
4
+
5
+ LOG_FILE=f"{datetime.now().strftime('%m_%d_%Y_%H_%M_%S')}.log"
6
+
7
+ logs_path=os.path.join(os.getcwd(), "logs", LOG_FILE)
8
+
9
+ os.makedirs(logs_path, exist_ok=True)
10
+ # Create the file only if it is not created
11
+
12
+ LOG_FILE_PATH=os.path.join(logs_path, LOG_FILE)
13
+
14
+ logging.basicConfig(
15
+ filename=LOG_FILE_PATH,
16
+ format="[ %(asctime)s ] %(lineno)d %(name)s - %(levelname)s - %(message)s",
17
+ level=logging.INFO
18
+ )
19
+
20
+
models/weather-prediction/src/exception/exception.py CHANGED
@@ -1,5 +1,5 @@
1
  import sys
2
- from src.logging import logger
3
 
4
  class NetworkSecurityException(Exception):
5
  def __init__(self,error_message,error_details:sys):
 
1
  import sys
2
+ from src.log_utils import logger
3
 
4
  class NetworkSecurityException(Exception):
5
  def __init__(self,error_message,error_details:sys):
models/weather-prediction/src/log_utils/__init__.py ADDED
File without changes
models/weather-prediction/src/log_utils/logger.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import logging
2
+ import os
3
+ from datetime import datetime
4
+
5
+ LOG_FILE=f"{datetime.now().strftime('%m_%d_%Y_%H_%M_%S')}.log"
6
+
7
+ logs_path=os.path.join(os.getcwd(), "logs", LOG_FILE)
8
+
9
+ os.makedirs(logs_path, exist_ok=True)
10
+ # Create the file only if it is not created
11
+
12
+ LOG_FILE_PATH=os.path.join(logs_path, LOG_FILE)
13
+
14
+ logging.basicConfig(
15
+ filename=LOG_FILE_PATH,
16
+ format="[ %(asctime)s ] %(lineno)d %(name)s - %(levelname)s - %(message)s",
17
+ level=logging.INFO
18
+ )
19
+
20
+
pyproject.toml CHANGED
@@ -55,6 +55,7 @@ dependencies = [
55
  "sentence-transformers>=5.1.2",
56
  "streamlit>=1.28.0",
57
  "tensorflow>=2.20.0",
 
58
  "torch>=2.9.1",
59
  "tqdm>=4.67.1",
60
  "transformers>=4.57.3",
 
55
  "sentence-transformers>=5.1.2",
56
  "streamlit>=1.28.0",
57
  "tensorflow>=2.20.0",
58
+ "tf-keras>=2.20.1",
59
  "torch>=2.9.1",
60
  "tqdm>=4.67.1",
61
  "transformers>=4.57.3",
requirements.txt CHANGED
@@ -138,4 +138,5 @@ python-multipart
138
  yfinance
139
  tensorflow
140
  streamlit
141
- plotly
 
 
138
  yfinance
139
  tensorflow
140
  streamlit
141
+ plotly
142
+ tf_keras
uv.lock CHANGED
@@ -3391,6 +3391,7 @@ dependencies = [
3391
  { name = "sentence-transformers" },
3392
  { name = "streamlit" },
3393
  { name = "tensorflow" },
 
3394
  { name = "torch" },
3395
  { name = "tqdm" },
3396
  { name = "transformers" },
@@ -3453,6 +3454,7 @@ requires-dist = [
3453
  { name = "sentence-transformers", specifier = ">=5.1.2" },
3454
  { name = "streamlit", specifier = ">=1.28.0" },
3455
  { name = "tensorflow", specifier = ">=2.20.0" },
 
3456
  { name = "torch", specifier = ">=2.9.1" },
3457
  { name = "tqdm", specifier = ">=4.67.1" },
3458
  { name = "transformers", specifier = ">=4.57.3" },
@@ -6283,6 +6285,18 @@ wheels = [
6283
  { url = "https://files.pythonhosted.org/packages/f9/d5/141f53d7c1eb2a80e6d3e9a390228c3222c27705cbe7f048d3623053f3ca/termcolor-3.2.0-py3-none-any.whl", hash = "sha256:a10343879eba4da819353c55cb8049b0933890c2ebf9ad5d3ecd2bb32ea96ea6", size = 7698, upload-time = "2025-10-25T19:11:41.536Z" },
6284
  ]
6285
 
 
 
 
 
 
 
 
 
 
 
 
 
6286
  [[package]]
6287
  name = "threadpoolctl"
6288
  version = "3.6.0"
 
3391
  { name = "sentence-transformers" },
3392
  { name = "streamlit" },
3393
  { name = "tensorflow" },
3394
+ { name = "tf-keras" },
3395
  { name = "torch" },
3396
  { name = "tqdm" },
3397
  { name = "transformers" },
 
3454
  { name = "sentence-transformers", specifier = ">=5.1.2" },
3455
  { name = "streamlit", specifier = ">=1.28.0" },
3456
  { name = "tensorflow", specifier = ">=2.20.0" },
3457
+ { name = "tf-keras", specifier = ">=2.20.1" },
3458
  { name = "torch", specifier = ">=2.9.1" },
3459
  { name = "tqdm", specifier = ">=4.67.1" },
3460
  { name = "transformers", specifier = ">=4.57.3" },
 
6285
  { url = "https://files.pythonhosted.org/packages/f9/d5/141f53d7c1eb2a80e6d3e9a390228c3222c27705cbe7f048d3623053f3ca/termcolor-3.2.0-py3-none-any.whl", hash = "sha256:a10343879eba4da819353c55cb8049b0933890c2ebf9ad5d3ecd2bb32ea96ea6", size = 7698, upload-time = "2025-10-25T19:11:41.536Z" },
6286
  ]
6287
 
6288
+ [[package]]
6289
+ name = "tf-keras"
6290
+ version = "2.20.1"
6291
+ source = { registry = "https://pypi.org/simple" }
6292
+ dependencies = [
6293
+ { name = "tensorflow" },
6294
+ ]
6295
+ sdist = { url = "https://files.pythonhosted.org/packages/42/38/6060f6c7472439bb3890b9094d69d31d9f8d5da123b16c738773e70fff91/tf_keras-2.20.1.tar.gz", hash = "sha256:884be5938fb0b2b53b1583c1ae2b660ef87215377c29b5b6a77fd221b472aeaf", size = 1254487, upload-time = "2025-09-04T21:23:41.81Z" }
6296
+ wheels = [
6297
+ { url = "https://files.pythonhosted.org/packages/85/6b/d9a8202bfe5c9e3b078cf550bafab962aa9d6b1a1f1180f0065399d4c9b2/tf_keras-2.20.1-py3-none-any.whl", hash = "sha256:3f0e0a34d9a4c8758f24fdc1053e6e335f16ab5534c7d34f1899b8924779760c", size = 1694335, upload-time = "2025-09-04T21:23:40.153Z" },
6298
+ ]
6299
+
6300
  [[package]]
6301
  name = "threadpoolctl"
6302
  version = "3.6.0"