AjaykumarPilla commited on
Commit
48e31af
·
verified ·
1 Parent(s): e5b3bf0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +46 -28
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 form
338
- with st.form("project_form"):
339
- col1, col2 = st.columns(2)
340
-
341
- with col1:
342
- project_name = st.text_input("Project Name")
343
- phase = st.selectbox("Phase", [""] + ["Planning", "Design", "Construction"], index=0, key="phase_select")
344
-
345
- if phase != st.session_state.phase:
346
- st.session_state.phase = phase
347
- st.session_state.task = ""
348
- task_options_list = [""] + task_options.get(phase, []) if phase else [""]
349
- task = st.selectbox("Task", task_options_list, index=0, key="task_select")
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
- with col2:
355
- workforce_gap = st.number_input("Workforce Gap (%)", min_value=0.0, max_value=100.0, step=1.0, value=0.0)
356
- workforce_skill_level = st.selectbox("Workforce Skill Level", ["", "Low", "Medium", "High"], index=0)
357
- workforce_shift_hours = st.number_input("Workforce Shift Hours", min_value=0, step=1, value=0)
358
- st.write(f"**Selected Shift Hours**: {workforce_shift_hours}")
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
- submit_button = st.form_submit_button("Fetch Weather and Predict Delay")
363
-
364
- # Process form submission
365
- if submit_button:
366
- logger.info("Processing form submission")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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,