Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -334,36 +334,54 @@ 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 |
-
current_progress = st.number_input("Current Progress (%)", min_value=0.0, max_value=100.0, step=1.0, value=0.0)
|
351 |
-
task_expected_duration = st.number_input("Task Expected Duration (days)", min_value=0, step=1, value=0)
|
352 |
-
task_actual_duration = st.number_input("Task Actual Duration (days)", min_value=0, step=1, value=0)
|
353 |
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
project_location = st.text_input("Project Location (City)", placeholder="e.g., New York")
|
360 |
-
weather_forecast_date = st.date_input("Weather Forecast Date", min_value=datetime(2025, 1, 1), value=None)
|
361 |
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
367 |
input_data = {
|
368 |
"project_name": project_name,
|
369 |
"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 |
+
project_name = st.text_input("Project Name", help="Enter the name of the project")
|
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 |
+
task_options_list = [""] + task_options.get(phase, []) if phase else [""]
|
358 |
+
logger.info(f"Task options for phase '{phase}': {task_options_list}")
|
359 |
+
task = st.selectbox(
|
360 |
+
"Task",
|
361 |
+
task_options_list,
|
362 |
+
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,
|
363 |
+
key="task_select",
|
364 |
+
help="Select the task corresponding to the phase"
|
365 |
+
)
|
366 |
+
st.session_state.task = task
|
367 |
+
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")
|
368 |
+
task_expected_duration = st.number_input("Task Expected Duration (days)", min_value=0, step=1, value=0, help="Enter the expected duration in days")
|
369 |
+
task_actual_duration = st.number_input("Task Actual Duration (days)", min_value=0, step=1, value=0, help="Enter the actual duration in days")
|
370 |
+
|
371 |
+
with col2:
|
372 |
+
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")
|
373 |
+
workforce_skill_level = st.selectbox("Workforce Skill Level", ["", "Low", "Medium", "High"], index=0, help="Select the workforce skill level")
|
374 |
+
workforce_shift_hours = st.number_input("Workforce Shift Hours", min_value=0, step=1, value=0, help="Enter the shift hours")
|
375 |
+
st.write(f"**Selected Shift Hours**: {workforce_shift_hours}")
|
376 |
+
project_location = st.text_input("Project Location (City)", placeholder="e.g., New York", help="Enter the city for weather data")
|
377 |
+
weather_forecast_date = st.date_input("Weather Forecast Date", min_value=datetime(2025, 1, 1), value=None, help="Select the forecast date")
|
378 |
+
|
379 |
+
# Predict button
|
380 |
+
predict_button = st.button("Fetch Weather and Predict Delay")
|
381 |
+
|
382 |
+
# Process inputs when button is clicked
|
383 |
+
if predict_button:
|
384 |
+
logger.info("Processing prediction request")
|
385 |
input_data = {
|
386 |
"project_name": project_name,
|
387 |
"phase": phase,
|