saptak21 commited on
Commit
2d12975
Β·
verified Β·
1 Parent(s): 5843474

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +42 -23
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
- iface = gr.Interface(
121
- fn=run_allocation,
122
- inputs=[
123
- gr.File(label="Teachers Excel File"),
124
- gr.File(label="Exam Summary Excel File"),
125
- gr.Slider(minimum=0, maximum=2, step=0.1, label="Duty Buffer", value=0.5),
126
- ],
127
- outputs=[
128
- gr.Dataframe(label="Duty Assignments"),
129
- gr.Dataframe(label="Unassigned Duties"),
130
- gr.Dataframe(label="Teacher Summary"),
131
- gr.Textbox(label="Total Invigilator Hours"),
132
- gr.Textbox(label="Average Duty per Teacher"),
133
- gr.File(label="Download Duty Allocation Summary") # Add File component for download
134
- ],
135
- title="πŸ§‘β€πŸ« Duty Allocation System",
136
- description="Upload your Excel files and click 'Submit' to generate duty assignments."
137
- )
138
-
139
- iface.launch(inline = False)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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()