Update app.py
Browse files
app.py
CHANGED
|
@@ -334,62 +334,61 @@ def save_to_salesforce(input_data, prediction, pdf_buffer):
|
|
| 334 |
logger.error(f"Error saving to Salesforce: {str(e)}")
|
| 335 |
return f"Error saving to Salesforce: {str(e)}"
|
| 336 |
|
| 337 |
-
# Input
|
| 338 |
-
|
| 339 |
-
|
| 340 |
-
|
| 341 |
-
|
| 342 |
-
|
| 343 |
-
|
| 344 |
-
|
| 345 |
-
|
| 346 |
-
|
| 347 |
-
|
| 348 |
-
|
| 349 |
-
|
| 350 |
-
)
|
| 351 |
-
|
| 352 |
-
# Update task options when phase changes
|
| 353 |
-
if phase != st.session_state.phase:
|
| 354 |
-
st.session_state.phase = phase
|
| 355 |
-
st.session_state.task = "" # Reset task when phase changes
|
| 356 |
-
logger.info(f"Phase changed to {phase}, resetting task")
|
| 357 |
-
|
| 358 |
-
with col2:
|
| 359 |
-
# Task selection
|
| 360 |
-
task_options_list = [""] + task_options.get(phase, []) if phase else [""]
|
| 361 |
-
logger.info(f"Task options for phase '{phase}': {task_options_list}")
|
| 362 |
-
task = st.selectbox(
|
| 363 |
-
"Task",
|
| 364 |
-
task_options_list,
|
| 365 |
-
index=0 if st.session_state.task == "" else task_options_list.index(st.session_state.task) if st.session_state.task in task_options_list else 0,
|
| 366 |
-
key="task_select",
|
| 367 |
-
help="Select the task corresponding to the phase"
|
| 368 |
-
)
|
| 369 |
-
st.session_state.task = task
|
| 370 |
-
|
| 371 |
-
# Other form inputs
|
| 372 |
-
col1, col2 = st.columns([1, 1])
|
| 373 |
-
with col1:
|
| 374 |
-
project_name = st.text_input("Project Name", help="Enter the name of the project")
|
| 375 |
-
current_progress = st.number_input("Current Progress (%)", min_value=0.0, max_value=100.0, step=1.0, value=0.0, help="Enter the current progress percentage")
|
| 376 |
-
task_expected_duration = st.number_input("Task Expected Duration (days)", min_value=0, step=1, value=0, help="Enter the expected duration in days")
|
| 377 |
-
task_actual_duration = st.number_input("Task Actual Duration (days)", min_value=0, step=1, value=0, help="Enter the actual duration in days")
|
| 378 |
-
|
| 379 |
-
with col2:
|
| 380 |
-
workforce_gap = st.number_input("Workforce Gap (%)", min_value=0.0, max_value=100.0, step=1.0, value=0.0, help="Enter the workforce gap percentage")
|
| 381 |
-
workforce_skill_level = st.selectbox("Workforce Skill Level", ["", "Low", "Medium", "High"], index=0, help="Select the workforce skill level")
|
| 382 |
-
workforce_shift_hours = st.number_input("Workforce Shift Hours", min_value=0, step=1, value=0, help="Enter the shift hours")
|
| 383 |
-
st.write(f"**Selected Shift Hours**: {workforce_shift_hours}")
|
| 384 |
-
project_location = st.text_input("Project Location (City)", placeholder="e.g., New York", help="Enter the city for weather data")
|
| 385 |
-
weather_forecast_date = st.date_input("Weather Forecast Date", min_value=datetime(2025, 1, 1), value=None, help="Select the forecast date")
|
| 386 |
|
| 387 |
-
#
|
| 388 |
-
|
| 389 |
-
|
| 390 |
-
#
|
| 391 |
-
|
| 392 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 393 |
input_data = {
|
| 394 |
"project_name": project_name,
|
| 395 |
"phase": phase,
|
|
|
|
| 334 |
logger.error(f"Error saving to Salesforce: {str(e)}")
|
| 335 |
return f"Error saving to Salesforce: {str(e)}"
|
| 336 |
|
| 337 |
+
# Input section
|
| 338 |
+
st.markdown("### Project Details")
|
| 339 |
+
col1, col2 = st.columns([1, 1]) # Equal width columns for better alignment
|
| 340 |
+
|
| 341 |
+
with col1:
|
| 342 |
+
# Phase selection
|
| 343 |
+
phase = st.selectbox(
|
| 344 |
+
"Phase",
|
| 345 |
+
[""] + ["Planning", "Design", "Construction"],
|
| 346 |
+
index=0 if st.session_state.phase == "" else ["", "Planning", "Design", "Construction"].index(st.session_state.phase),
|
| 347 |
+
key="phase_select",
|
| 348 |
+
help="Select the project phase"
|
| 349 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 350 |
|
| 351 |
+
# Update task options when phase changes
|
| 352 |
+
if phase != st.session_state.phase:
|
| 353 |
+
st.session_state.phase = phase
|
| 354 |
+
st.session_state.task = "" # Reset task when phase changes
|
| 355 |
+
logger.info(f"Phase changed to {phase}, resetting task")
|
| 356 |
+
|
| 357 |
+
with col2:
|
| 358 |
+
# Task selection
|
| 359 |
+
task_options_list = [""] + task_options.get(phase, []) if phase else [""]
|
| 360 |
+
logger.info(f"Task options for phase '{phase}': {task_options_list}")
|
| 361 |
+
task = st.selectbox(
|
| 362 |
+
"Task",
|
| 363 |
+
task_options_list,
|
| 364 |
+
index=0 if st.session_state.task == "" else task_options_list.index(st.session_state.task) if st.session_state.task in task_options_list else 0,
|
| 365 |
+
key="task_select",
|
| 366 |
+
help="Select the task corresponding to the phase"
|
| 367 |
+
)
|
| 368 |
+
st.session_state.task = task
|
| 369 |
+
|
| 370 |
+
# Other inputs
|
| 371 |
+
col1, col2 = st.columns([1, 1])
|
| 372 |
+
with col1:
|
| 373 |
+
project_name = st.text_input("Project Name", help="Enter the name of the project")
|
| 374 |
+
current_progress = st.number_input("Current Progress (%)", min_value=0.0, max_value=100.0, step=1.0, value=0.0, help="Enter the current progress percentage")
|
| 375 |
+
task_expected_duration = st.number_input("Task Expected Duration (days)", min_value=0, step=1, value=0, help="Enter the expected duration in days")
|
| 376 |
+
task_actual_duration = st.number_input("Task Actual Duration (days)", min_value=0, step=1, value=0, help="Enter the actual duration in days")
|
| 377 |
+
|
| 378 |
+
with col2:
|
| 379 |
+
workforce_gap = st.number_input("Workforce Gap (%)", min_value=0.0, max_value=100.0, step=1.0, value=0.0, help="Enter the workforce gap percentage")
|
| 380 |
+
workforce_skill_level = st.selectbox("Workforce Skill Level", ["", "Low", "Medium", "High"], index=0, help="Select the workforce skill level")
|
| 381 |
+
workforce_shift_hours = st.number_input("Workforce Shift Hours", min_value=0, step=1, value=0, help="Enter the shift hours")
|
| 382 |
+
st.write(f"**Selected Shift Hours**: {workforce_shift_hours}")
|
| 383 |
+
project_location = st.text_input("Project Location (City)", placeholder="e.g., New York", help="Enter the city for weather data")
|
| 384 |
+
weather_forecast_date = st.date_input("Weather Forecast Date", min_value=datetime(2025, 1, 1), value=None, help="Select the forecast date")
|
| 385 |
+
|
| 386 |
+
# Predict button
|
| 387 |
+
predict_button = st.button("Fetch Weather and Predict Delay")
|
| 388 |
+
|
| 389 |
+
# Process inputs when button is clicked
|
| 390 |
+
if predict_button:
|
| 391 |
+
logger.info("Processing prediction request")
|
| 392 |
input_data = {
|
| 393 |
"project_name": project_name,
|
| 394 |
"phase": phase,
|