Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,7 +3,7 @@ import pandas as pd
|
|
| 3 |
import matplotlib.pyplot as plt
|
| 4 |
from datetime import datetime
|
| 5 |
from model import predict_delay, get_weather_condition
|
| 6 |
-
from utils import validate_inputs, generate_heatmap
|
| 7 |
from reportlab.lib.pagesizes import letter
|
| 8 |
from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer, Image
|
| 9 |
from reportlab.lib.styles import getSampleStyleSheet
|
|
@@ -14,7 +14,6 @@ from fastapi import FastAPI, HTTPException
|
|
| 14 |
from pydantic import BaseModel
|
| 15 |
import uvicorn
|
| 16 |
import nest_asyncio
|
| 17 |
-
import os
|
| 18 |
|
| 19 |
# Apply nest_asyncio to allow FastAPI in Streamlit's event loop
|
| 20 |
nest_asyncio.apply()
|
|
@@ -61,17 +60,10 @@ async def predict(project_input: ProjectInput):
|
|
| 61 |
pdf_base64 = base64.b64encode(pdf_buffer.getvalue()).decode('utf-8')
|
| 62 |
plt.close(fig)
|
| 63 |
|
| 64 |
-
#
|
| 65 |
-
try:
|
| 66 |
-
salesforce_result = send_to_salesforce(input_data, prediction)
|
| 67 |
-
except Exception as e:
|
| 68 |
-
raise HTTPException(status_code=500, detail=f"Salesforce integration failed: {str(e)}")
|
| 69 |
-
|
| 70 |
-
# Return prediction, PDF, and Salesforce result
|
| 71 |
return {
|
| 72 |
"prediction": prediction,
|
| 73 |
-
"pdf_base64": pdf_base64
|
| 74 |
-
"salesforce_result": salesforce_result
|
| 75 |
}
|
| 76 |
|
| 77 |
# Streamlit app configuration
|
|
@@ -233,13 +225,6 @@ if submit_button:
|
|
| 233 |
mime="application/pdf"
|
| 234 |
)
|
| 235 |
|
| 236 |
-
# Send to Salesforce and display result
|
| 237 |
-
try:
|
| 238 |
-
salesforce_result = send_to_salesforce(input_data, prediction)
|
| 239 |
-
st.success(f"Salesforce Integration: {salesforce_result}")
|
| 240 |
-
except Exception as e:
|
| 241 |
-
st.error(f"Salesforce Integration Failed: {str(e)}")
|
| 242 |
-
|
| 243 |
st.session_state.prediction = prediction
|
| 244 |
st.session_state.input_data = input_data
|
| 245 |
|
|
|
|
| 3 |
import matplotlib.pyplot as plt
|
| 4 |
from datetime import datetime
|
| 5 |
from model import predict_delay, get_weather_condition
|
| 6 |
+
from utils import validate_inputs, generate_heatmap
|
| 7 |
from reportlab.lib.pagesizes import letter
|
| 8 |
from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer, Image
|
| 9 |
from reportlab.lib.styles import getSampleStyleSheet
|
|
|
|
| 14 |
from pydantic import BaseModel
|
| 15 |
import uvicorn
|
| 16 |
import nest_asyncio
|
|
|
|
| 17 |
|
| 18 |
# Apply nest_asyncio to allow FastAPI in Streamlit's event loop
|
| 19 |
nest_asyncio.apply()
|
|
|
|
| 60 |
pdf_base64 = base64.b64encode(pdf_buffer.getvalue()).decode('utf-8')
|
| 61 |
plt.close(fig)
|
| 62 |
|
| 63 |
+
# Return prediction and PDF
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
return {
|
| 65 |
"prediction": prediction,
|
| 66 |
+
"pdf_base64": pdf_base64
|
|
|
|
| 67 |
}
|
| 68 |
|
| 69 |
# Streamlit app configuration
|
|
|
|
| 225 |
mime="application/pdf"
|
| 226 |
)
|
| 227 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 228 |
st.session_state.prediction = prediction
|
| 229 |
st.session_state.input_data = input_data
|
| 230 |
|