Spaces:
Sleeping
Sleeping
Upload realtime_pipeline.py
Browse files- realtime_pipeline.py +14 -5
realtime_pipeline.py
CHANGED
|
@@ -844,11 +844,20 @@ class RealTimeFeatureExtractor:
|
|
| 844 |
year = query_time.year
|
| 845 |
month = query_time.month
|
| 846 |
|
| 847 |
-
|
| 848 |
-
|
| 849 |
-
|
| 850 |
-
|
| 851 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 852 |
|
| 853 |
scaled_soil = {}
|
| 854 |
if soil_data:
|
|
|
|
| 844 |
year = query_time.year
|
| 845 |
month = query_time.month
|
| 846 |
|
| 847 |
+
# Parallel Execution for real-time features (5 concurrent requests)
|
| 848 |
+
with concurrent.futures.ThreadPoolExecutor(max_workers=5) as executor:
|
| 849 |
+
future_weather = executor.submit(self.get_realtime_weather, latitude, longitude)
|
| 850 |
+
future_soil = executor.submit(self.get_soil_data_with_buffer, latitude, longitude)
|
| 851 |
+
future_ndvi = executor.submit(self.get_ndvi_data, latitude, longitude)
|
| 852 |
+
future_bdod = executor.submit(self.get_bdod_data, latitude, longitude)
|
| 853 |
+
future_lc = executor.submit(self.get_landcover_type, latitude, longitude)
|
| 854 |
+
|
| 855 |
+
# Wait for all to complete
|
| 856 |
+
weather_data = future_weather.result()
|
| 857 |
+
soil_data = future_soil.result()
|
| 858 |
+
ndvi_data = future_ndvi.result()
|
| 859 |
+
bdod_data = future_bdod.result()
|
| 860 |
+
lc_type = future_lc.result()
|
| 861 |
|
| 862 |
scaled_soil = {}
|
| 863 |
if soil_data:
|