Update app.py
Browse files
app.py
CHANGED
|
@@ -106,34 +106,53 @@ def run_allocation(teachers_file, exams_file, buffer=0.5):
|
|
| 106 |
assignments_df, unassigned_df = assign_duties(teachers_df, exams_df, buffer=buffer)
|
| 107 |
|
| 108 |
# Save assignments to Excel for download
|
| 109 |
-
assignments_df.to_excel("duty_allocation_summary.xlsx", index=False)
|
| 110 |
-
|
| 111 |
|
| 112 |
# Return DataFrames, summary, and file path for display and download
|
| 113 |
-
return assignments_df, unassigned_df, teachers_df[['NAME', 'DESIG', 'AssignedHours', 'DutyLimit']], total_hours, n, "duty_allocation_summary.xlsx"
|
| 114 |
|
| 115 |
except Exception as e:
|
| 116 |
return None, None, None, None, str(e), None # Return None for file path on error
|
| 117 |
|
| 118 |
|
| 119 |
# Gradio Interface
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 106 |
assignments_df, unassigned_df = assign_duties(teachers_df, exams_df, buffer=buffer)
|
| 107 |
|
| 108 |
# Save assignments to Excel for download
|
| 109 |
+
assignments_df.to_excel("duty_allocation_summary.xlsx", index=False)
|
| 110 |
+
|
| 111 |
|
| 112 |
# Return DataFrames, summary, and file path for display and download
|
| 113 |
+
return assignments_df, unassigned_df, teachers_df[['NAME', 'DESIG', 'AssignedHours', 'DutyLimit']], total_hours, n, "duty_allocation_summary.xlsx"
|
| 114 |
|
| 115 |
except Exception as e:
|
| 116 |
return None, None, None, None, str(e), None # Return None for file path on error
|
| 117 |
|
| 118 |
|
| 119 |
# Gradio Interface
|
| 120 |
+
with gr.Blocks() as iface:
|
| 121 |
+
gr.Image(
|
| 122 |
+
value="https://drive.google.com/uc?id=1nmhNC3JjyU9YsVh-bzgzAmQZgloqNtEQ",
|
| 123 |
+
height=158,
|
| 124 |
+
width=158,
|
| 125 |
+
show_label=False,
|
| 126 |
+
container=False
|
| 127 |
+
|
| 128 |
+
)
|
| 129 |
+
#gr.Markdown("## π§βπ« RKMRC Exam Invigilator Duty Allocation System")
|
| 130 |
+
gr.Markdown("<h1 style='text-align: center;'>π§βπ« RKMRC Exam Invigilator Duty Allocation System</h1>")
|
| 131 |
+
gr.Markdown("π Upload your Excel files and click 'Submit' to generate duty assignments.")
|
| 132 |
+
|
| 133 |
+
teachers_file = gr.File(label="π Teachers Excel File")
|
| 134 |
+
exams_file = gr.File(label="π Exam Summary Excel File")
|
| 135 |
+
buffer_slider = gr.Slider(minimum=0, maximum=2, step=0.1, label="Duty Buffer", value=0.5)
|
| 136 |
+
submit_btn = gr.Button("Submit")
|
| 137 |
+
|
| 138 |
+
duty_assignments = gr.Dataframe(label="β
Duty Assignments")
|
| 139 |
+
unassigned_duties = gr.Dataframe(label="β οΈ Unassigned Duties")
|
| 140 |
+
teacher_summary = gr.Dataframe(label="π¨βπ« Teacher Summary")
|
| 141 |
+
total_hours_text = gr.Textbox(label="Total Invigilator Hours")
|
| 142 |
+
avg_duty_text = gr.Textbox(label="Average Duty per Teacher")
|
| 143 |
+
download_file = gr.File(label="π Download Duty Allocation Summary")
|
| 144 |
+
|
| 145 |
+
submit_btn.click(
|
| 146 |
+
fn=run_allocation,
|
| 147 |
+
inputs=[teachers_file, exams_file, buffer_slider],
|
| 148 |
+
outputs=[
|
| 149 |
+
duty_assignments,
|
| 150 |
+
unassigned_duties,
|
| 151 |
+
teacher_summary,
|
| 152 |
+
total_hours_text,
|
| 153 |
+
avg_duty_text,
|
| 154 |
+
download_file
|
| 155 |
+
]
|
| 156 |
+
)
|
| 157 |
+
|
| 158 |
+
iface.launch()
|