Update app.py
Browse files
app.py
CHANGED
|
@@ -441,57 +441,70 @@ def nurse_scheduling_app(
|
|
| 441 |
|
| 442 |
# Create Gradio interface
|
| 443 |
def create_interface():
|
| 444 |
-
with gr.Blocks(
|
| 445 |
-
gr.Markdown("#
|
| 446 |
|
| 447 |
with gr.Row():
|
| 448 |
with gr.Column():
|
| 449 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 450 |
|
| 451 |
-
|
| 452 |
-
|
| 453 |
-
|
| 454 |
-
|
| 455 |
-
|
| 456 |
-
|
| 457 |
-
|
| 458 |
-
|
| 459 |
-
|
| 460 |
-
|
| 461 |
-
|
| 462 |
-
|
|
|
|
|
|
|
| 463 |
|
| 464 |
with gr.Column():
|
| 465 |
-
|
| 466 |
-
|
| 467 |
-
|
| 468 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 469 |
|
| 470 |
-
|
|
|
|
| 471 |
fn=nurse_scheduling_app,
|
| 472 |
inputs=[
|
| 473 |
-
|
| 474 |
-
beds_per_staff,
|
| 475 |
-
|
| 476 |
-
|
| 477 |
-
|
| 478 |
clinic_start,
|
| 479 |
clinic_end,
|
| 480 |
-
|
|
|
|
| 481 |
],
|
| 482 |
-
outputs=[
|
| 483 |
-
summary_output,
|
| 484 |
-
gantt_output,
|
| 485 |
-
schedule_output,
|
| 486 |
-
csv_output
|
| 487 |
-
]
|
| 488 |
)
|
| 489 |
-
|
| 490 |
-
return
|
| 491 |
|
| 492 |
-
#
|
| 493 |
-
|
| 494 |
|
| 495 |
-
#
|
| 496 |
if __name__ == "__main__":
|
| 497 |
-
interface
|
|
|
|
|
|
| 441 |
|
| 442 |
# Create Gradio interface
|
| 443 |
def create_interface():
|
| 444 |
+
with gr.Blocks() as interface:
|
| 445 |
+
gr.Markdown("# Staff Scheduling Optimizer")
|
| 446 |
|
| 447 |
with gr.Row():
|
| 448 |
with gr.Column():
|
| 449 |
+
# Left panel for inputs
|
| 450 |
+
gr.Markdown("### Clinic Parameters") # Use Markdown instead of Group label
|
| 451 |
+
with gr.Group(): # Group without label
|
| 452 |
+
csv_input = gr.File(label="Upload CSV")
|
| 453 |
+
beds_per_staff = gr.Number(label="Beds per Staff", value=3)
|
| 454 |
+
max_hours_per_staff = gr.Number(label="Maximum monthly hours", value=160)
|
| 455 |
+
hours_per_cycle = gr.Number(label="Hours per Cycle", value=4)
|
| 456 |
+
rest_days_per_week = gr.Number(label="Rest Days per Week", value=2)
|
| 457 |
|
| 458 |
+
gr.Markdown("### Time Parameters") # Use Markdown for section headers
|
| 459 |
+
with gr.Group():
|
| 460 |
+
clinic_start = gr.Dropdown(
|
| 461 |
+
label="Clinic Start Hour",
|
| 462 |
+
choices=am_pm_times,
|
| 463 |
+
value="08:00 AM"
|
| 464 |
+
)
|
| 465 |
+
clinic_end = gr.Dropdown(
|
| 466 |
+
label="Clinic End Hour",
|
| 467 |
+
choices=am_pm_times,
|
| 468 |
+
value="08:00 PM"
|
| 469 |
+
)
|
| 470 |
+
overlap_time = gr.Number(label="Overlap Time", value=0)
|
| 471 |
+
max_start_time_change = gr.Number(label="Max Start Time Change", value=2)
|
| 472 |
|
| 473 |
with gr.Column():
|
| 474 |
+
# Right panel for outputs
|
| 475 |
+
with gr.Tabs():
|
| 476 |
+
with gr.TabItem("Schedule"):
|
| 477 |
+
schedule_output = gr.Dataframe()
|
| 478 |
+
with gr.TabItem("Visualization"):
|
| 479 |
+
gantt_chart = gr.Plot()
|
| 480 |
+
with gr.TabItem("Statistics"):
|
| 481 |
+
stats_output = gr.Markdown()
|
| 482 |
+
|
| 483 |
+
optimize_btn = gr.Button("Optimize Schedule", variant="primary")
|
| 484 |
|
| 485 |
+
# Connect the button to your optimization function
|
| 486 |
+
optimize_btn.click(
|
| 487 |
fn=nurse_scheduling_app,
|
| 488 |
inputs=[
|
| 489 |
+
csv_input,
|
| 490 |
+
beds_per_staff,
|
| 491 |
+
max_hours_per_staff,
|
| 492 |
+
hours_per_cycle,
|
| 493 |
+
rest_days_per_week,
|
| 494 |
clinic_start,
|
| 495 |
clinic_end,
|
| 496 |
+
overlap_time,
|
| 497 |
+
max_start_time_change
|
| 498 |
],
|
| 499 |
+
outputs=[schedule_output, gantt_chart, stats_output]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 500 |
)
|
| 501 |
+
|
| 502 |
+
return interface
|
| 503 |
|
| 504 |
+
# Define your time options
|
| 505 |
+
am_pm_times = [f"{i:02d}:00 AM" for i in range(1, 13)] + [f"{i:02d}:00 PM" for i in range(1, 13)]
|
| 506 |
|
| 507 |
+
# Launch the interface
|
| 508 |
if __name__ == "__main__":
|
| 509 |
+
interface = create_interface()
|
| 510 |
+
interface.launch(share=True)
|