Upload app.py
Browse files
app.py
CHANGED
|
@@ -115,9 +115,10 @@ class PredictionTask:
|
|
| 115 |
data = stock_model.fetch_stock_data(self.symbol, outputsize="compact")
|
| 116 |
print(f"Fetched {len(data)} rows for {self.symbol}")
|
| 117 |
except Exception as e:
|
| 118 |
-
|
|
|
|
| 119 |
self.status = "failed"
|
| 120 |
-
self.result = {"error":
|
| 121 |
return
|
| 122 |
|
| 123 |
if data is None:
|
|
@@ -333,9 +334,10 @@ class PredictionTask:
|
|
| 333 |
print(f"Prediction complete for {self.symbol}")
|
| 334 |
|
| 335 |
except Exception as e:
|
|
|
|
| 336 |
self.status = "failed"
|
| 337 |
-
self.result = {"error":
|
| 338 |
-
print(f"
|
| 339 |
traceback.print_exc()
|
| 340 |
|
| 341 |
|
|
@@ -416,7 +418,8 @@ def prediction_status(task_id):
|
|
| 416 |
"taskId": task_id,
|
| 417 |
"status": task.status,
|
| 418 |
"progress": task.progress,
|
| 419 |
-
"result": task.result if task.status
|
|
|
|
| 420 |
})
|
| 421 |
except Exception as e:
|
| 422 |
print(f"Error generating status response: {e}")
|
|
|
|
| 115 |
data = stock_model.fetch_stock_data(self.symbol, outputsize="compact")
|
| 116 |
print(f"Fetched {len(data)} rows for {self.symbol}")
|
| 117 |
except Exception as e:
|
| 118 |
+
error_msg = str(e)
|
| 119 |
+
print(f"\n[ERROR] {error_msg}\n")
|
| 120 |
self.status = "failed"
|
| 121 |
+
self.result = {"error": error_msg}
|
| 122 |
return
|
| 123 |
|
| 124 |
if data is None:
|
|
|
|
| 334 |
print(f"Prediction complete for {self.symbol}")
|
| 335 |
|
| 336 |
except Exception as e:
|
| 337 |
+
error_msg = str(e)
|
| 338 |
self.status = "failed"
|
| 339 |
+
self.result = {"error": error_msg}
|
| 340 |
+
print(f"\n[ERROR] {error_msg}\n")
|
| 341 |
traceback.print_exc()
|
| 342 |
|
| 343 |
|
|
|
|
| 418 |
"taskId": task_id,
|
| 419 |
"status": task.status,
|
| 420 |
"progress": task.progress,
|
| 421 |
+
"result": task.result if task.status in ["completed", "failed"] else None,
|
| 422 |
+
"error": task.result.get("error") if (task.status == "failed" and task.result and isinstance(task.result, dict)) else None
|
| 423 |
})
|
| 424 |
except Exception as e:
|
| 425 |
print(f"Error generating status response: {e}")
|