Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -10,61 +10,54 @@ from reportlab.lib.styles import getSampleStyleSheet
|
|
| 10 |
from reportlab.lib.units import inch
|
| 11 |
from io import BytesIO
|
| 12 |
import base64
|
| 13 |
-
|
| 14 |
-
from
|
| 15 |
-
import
|
| 16 |
-
import
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
nest_asyncio
|
| 20 |
-
|
| 21 |
-
#
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
#
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
#
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 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
|
| 70 |
st.set_page_config(page_title="Delay 🚀", layout="wide")
|
|
@@ -115,8 +108,6 @@ def generate_pdf(input_data, prediction, heatmap_fig):
|
|
| 115 |
f"Task Expected Duration: {input_data['task_expected_duration']} days",
|
| 116 |
f"Task Actual Duration: {input_data['task_actual_duration']} days",
|
| 117 |
f"Workforce Gap: {input_data['workforce_gap']}%",
|
| 118 |
-
f"Workforce Skill Level: {input_data['workforce_skill_level']}",
|
| 119 |
-
f"Workforce Shift Hours: {input_data['workforce_shift_hours']}",
|
| 120 |
f"Weather Impact Score: {input_data['weather_impact_score']}",
|
| 121 |
f"Weather Condition: {input_data['weather_condition']}",
|
| 122 |
f"Weather Forecast Date: {input_data['weather_forecast_date']}"
|
|
@@ -228,6 +219,6 @@ if submit_button:
|
|
| 228 |
st.session_state.prediction = prediction
|
| 229 |
st.session_state.input_data = input_data
|
| 230 |
|
| 231 |
-
#
|
| 232 |
-
if __name__ == "__main__":
|
| 233 |
-
|
|
|
|
| 10 |
from reportlab.lib.units import inch
|
| 11 |
from io import BytesIO
|
| 12 |
import base64
|
| 13 |
+
# Removed FastAPI-related imports
|
| 14 |
+
# from fastapi import FastAPI, HTTPException
|
| 15 |
+
# from pydantic import BaseModel
|
| 16 |
+
# import uvicorn
|
| 17 |
+
# import nest_asyncio
|
| 18 |
+
|
| 19 |
+
# Commented out nest_asyncio and FastAPI setup
|
| 20 |
+
# nest_asyncio.apply()
|
| 21 |
+
# app = FastAPI()
|
| 22 |
+
|
| 23 |
+
# Commented out Pydantic model and API endpoint
|
| 24 |
+
# class ProjectInput(BaseModel):
|
| 25 |
+
# project_name: str
|
| 26 |
+
# phase: str
|
| 27 |
+
# task: str
|
| 28 |
+
# current_progress: float
|
| 29 |
+
# task_expected_duration: int
|
| 30 |
+
# task_actual_duration: int
|
| 31 |
+
# workforce_gap: float
|
| 32 |
+
# workforce_skill_level: str
|
| 33 |
+
# workforce_shift_hours: int
|
| 34 |
+
# weather_impact_score: int
|
| 35 |
+
# weather_forecast_date: str
|
| 36 |
+
|
| 37 |
+
# @app.post("/predict")
|
| 38 |
+
# async def predict(project_input: ProjectInput):
|
| 39 |
+
# input_data = project_input.dict()
|
| 40 |
+
# input_data["weather_condition"] = get_weather_condition(input_data["weather_impact_score"])
|
| 41 |
+
#
|
| 42 |
+
# error = validate_inputs(input_data)
|
| 43 |
+
# if error:
|
| 44 |
+
# raise HTTPException(status_code=400, detail=error)
|
| 45 |
+
#
|
| 46 |
+
# prediction = predict_delay(input_data)
|
| 47 |
+
#
|
| 48 |
+
# if "error" in prediction:
|
| 49 |
+
# raise HTTPException(status_code=500, detail=prediction["error"])
|
| 50 |
+
#
|
| 51 |
+
# fig = generate_heatmap(prediction['delay_probability'], f"{input_data['phase']}: {input_data['task']}")
|
| 52 |
+
#
|
| 53 |
+
# pdf_buffer = generate_pdf(input_data, prediction, fig)
|
| 54 |
+
# pdf_base64 = base64.b64encode(pdf_buffer.getvalue()).decode('utf-8')
|
| 55 |
+
# plt.close(fig)
|
| 56 |
+
#
|
| 57 |
+
# return {
|
| 58 |
+
# "prediction": prediction,
|
| 59 |
+
# "pdf_base64": pdf_base64
|
| 60 |
+
# }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 61 |
|
| 62 |
# Streamlit app configuration
|
| 63 |
st.set_page_config(page_title="Delay 🚀", layout="wide")
|
|
|
|
| 108 |
f"Task Expected Duration: {input_data['task_expected_duration']} days",
|
| 109 |
f"Task Actual Duration: {input_data['task_actual_duration']} days",
|
| 110 |
f"Workforce Gap: {input_data['workforce_gap']}%",
|
|
|
|
|
|
|
| 111 |
f"Weather Impact Score: {input_data['weather_impact_score']}",
|
| 112 |
f"Weather Condition: {input_data['weather_condition']}",
|
| 113 |
f"Weather Forecast Date: {input_data['weather_forecast_date']}"
|
|
|
|
| 219 |
st.session_state.prediction = prediction
|
| 220 |
st.session_state.input_data = input_data
|
| 221 |
|
| 222 |
+
# Commented out FastAPI server startup
|
| 223 |
+
# if __name__ == "__main__":
|
| 224 |
+
# uvicorn.run(app, host="0.0.0.0", port=8000, log_level="error")
|