rohan13 dishav2 commited on
Commit
885425a
1 Parent(s): c3d2b6a

Update to the reset functionality (#6)

Browse files

- Update to the reset functionality (4599b49d9a259ef376ac6afe9eda3d37bbba019c)


Co-authored-by: Disha Verma <[email protected]>

Files changed (1) hide show
  1. app.py +7 -7
app.py CHANGED
@@ -179,7 +179,7 @@ def enable_fields(url_status, canvas_api_key_status, submit_status, grade_status
179
  def reset_data():
180
  # Use shutil.rmtree() to delete output, docs, and vector_stores folders, reset grader and grader_qa, and get_grading_status, reset and return history
181
  global grader, grader_qa
182
- #If there's data in docs/output folder during grading
183
  if os.path.isdir('output') and len(glob.glob("output/*.csv")) > 0 and len(glob.glob("docs/*.json")) > 0 and len(
184
  glob.glob("docs/*.html")) > 0:
185
  reset_folder('output')
@@ -187,17 +187,17 @@ def reset_data():
187
  grader = None
188
  grader_qa = None
189
  history = [(None, 'Data reset successfully')]
190
- return history
191
- # If there's data in docs folder
192
  elif len(glob.glob("docs/*.json")) > 0 and len(glob.glob("docs/*.html")):
193
  reset_folder('docs')
194
  history = [(None, 'Data reset successfully')]
195
- return history
196
  #If there's data in vector_stores folder
197
  elif len(glob.glob("vector_stores/*.faiss")) > 0 or len(glob.glob("vector_stores/*.pkl")) > 0:
198
  reset_folder('vector_stores')
199
  history = [(None, 'Data reset successfully')]
200
- return history
201
 
202
 
203
  def get_output_dir(orig_name):
@@ -256,7 +256,7 @@ with gr.Blocks() as demo:
256
  grade = gr.Button(value="Grade", variant="secondary")
257
  download = gr.Button(value="Download", variant="secondary")
258
  file = gr.components.File(label="CSV Output", container=False, visible=False).style(height=100)
259
- reset = gr.Button(value="Reset", variant="secondary")
260
 
261
  chatbot = gr.Chatbot([], label="Chat with grading results", elem_id="chatbot", height=400)
262
 
@@ -296,7 +296,7 @@ with gr.Blocks() as demo:
296
  bot, chatbot, chatbot
297
  )
298
 
299
- reset.click(reset_data, inputs=[], outputs=[], postprocess=False, show_progress=True, ).success(
300
  bot, chatbot, chatbot)
301
 
302
  upload.upload(upload_grading_results, inputs=[upload, chatbot], outputs=[chatbot], postprocess=False, ).then(
 
179
  def reset_data():
180
  # Use shutil.rmtree() to delete output, docs, and vector_stores folders, reset grader and grader_qa, and get_grading_status, reset and return history
181
  global grader, grader_qa
182
+ #If there's data in docs/output folder during grading [During Grading]
183
  if os.path.isdir('output') and len(glob.glob("output/*.csv")) > 0 and len(glob.glob("docs/*.json")) > 0 and len(
184
  glob.glob("docs/*.html")) > 0:
185
  reset_folder('output')
 
187
  grader = None
188
  grader_qa = None
189
  history = [(None, 'Data reset successfully')]
190
+ return history, enabled, enabled, enabled, disabled, disabled, disabled
191
+ # If there's data in docs folder [During Ingestion]
192
  elif len(glob.glob("docs/*.json")) > 0 and len(glob.glob("docs/*.html")):
193
  reset_folder('docs')
194
  history = [(None, 'Data reset successfully')]
195
+ return history, enabled, enabled, enabled, disabled, disabled, disabled
196
  #If there's data in vector_stores folder
197
  elif len(glob.glob("vector_stores/*.faiss")) > 0 or len(glob.glob("vector_stores/*.pkl")) > 0:
198
  reset_folder('vector_stores')
199
  history = [(None, 'Data reset successfully')]
200
+ return history, enabled, enabled, enabled, disabled, disabled, disabled
201
 
202
 
203
  def get_output_dir(orig_name):
 
256
  grade = gr.Button(value="Grade", variant="secondary")
257
  download = gr.Button(value="Download", variant="secondary")
258
  file = gr.components.File(label="CSV Output", container=False, visible=False).style(height=100)
259
+ reset = gr.ClearButton(value="Reset")
260
 
261
  chatbot = gr.Chatbot([], label="Chat with grading results", elem_id="chatbot", height=400)
262
 
 
296
  bot, chatbot, chatbot
297
  )
298
 
299
+ reset.click(reset_data, inputs=[], outputs=[chatbot, url, canvas_api_key, submit, table, grade, download]).success(
300
  bot, chatbot, chatbot)
301
 
302
  upload.upload(upload_grading_results, inputs=[upload, chatbot], outputs=[chatbot], postprocess=False, ).then(