akera commited on
Commit
6e3baf0
·
verified ·
1 Parent(s): e764015

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -3
app.py CHANGED
@@ -753,17 +753,45 @@ with gr.Blocks(
753
  outputs=[download_file, download_info]
754
  )
755
 
756
- # Validate predictions
 
 
 
 
 
757
  def handle_validation(file, model_name, author, description):
758
  report, predictions = validate_submission(file, model_name, author, description)
759
- is_valid = predictions is not None
760
- return report, predictions, predictions, is_valid
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
761
 
762
  validate_btn.click(
763
  fn=handle_validation,
764
  inputs=[predictions_file, model_name_input, author_input, description_input],
765
  outputs=[validation_output, predictions_validated, validation_info_state, submit_btn]
766
  )
 
 
 
767
 
768
  # Submit for evaluation
769
  def handle_submission(predictions, model_name, author, description, validation_info):
 
753
  outputs=[download_file, download_info]
754
  )
755
 
756
+ # # Validate predictions
757
+ # def handle_validation(file, model_name, author, description):
758
+ # report, predictions = validate_submission(file, model_name, author, description)
759
+ # is_valid = predictions is not None
760
+ # return report, predictions, predictions, is_valid
761
+
762
  def handle_validation(file, model_name, author, description):
763
  report, predictions = validate_submission(file, model_name, author, description)
764
+ valid = predictions is not None
765
+
766
+ # Build the four returns:
767
+ # 1) report Markdown
768
+ # 2) store predictions in state
769
+ # 3) store validation info in state
770
+ # 4) enable or disable the submit button
771
+ if valid:
772
+ return (
773
+ report,
774
+ predictions, # predictions_validated state
775
+ predictions, # validation_info_state (you can store whatever you like here)
776
+ gr.update(interactive=True)
777
+ )
778
+ else:
779
+ return (
780
+ report,
781
+ None,
782
+ None,
783
+ gr.update(interactive=False) # <— this *disables* the button
784
+ )
785
+
786
 
787
  validate_btn.click(
788
  fn=handle_validation,
789
  inputs=[predictions_file, model_name_input, author_input, description_input],
790
  outputs=[validation_output, predictions_validated, validation_info_state, submit_btn]
791
  )
792
+
793
+
794
+
795
 
796
  # Submit for evaluation
797
  def handle_submission(predictions, model_name, author, description, validation_info):