Shiyu Zhao commited on
Commit
7bc286a
·
1 Parent(s): 7fbffac

Update space

Browse files
Files changed (1) hide show
  1. app.py +35 -1
app.py CHANGED
@@ -25,6 +25,8 @@ from stark_qa.evaluator import Evaluator
25
  from utils.hub_storage import HubStorage
26
  from utils.token_handler import TokenHandler
27
 
 
 
28
 
29
  from stark_qa import load_qa
30
  from stark_qa.evaluator import Evaluator
@@ -39,6 +41,7 @@ try:
39
  except Exception as e:
40
  raise RuntimeError(f"Failed to initialize HuggingFace Hub storage: {e}")
41
 
 
42
 
43
  def process_single_instance(args):
44
  """Process a single instance with improved validation and error handling"""
@@ -811,6 +814,8 @@ def process_submission(
811
  # Send confirmation email and update leaderboard data
812
  # send_submission_confirmation(meta_data, processed_results)
813
  update_leaderboard_data(submission_data)
 
 
814
 
815
  # Return success message
816
  return f"""
@@ -844,7 +849,22 @@ def process_submission(
844
  except Exception as e:
845
  print(f"Warning: Failed to delete temporary file {temp_file}: {str(e)}")
846
 
847
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
848
  def filter_by_model_type(df, selected_types):
849
  """
850
  Filter DataFrame by selected model types, including submitted models.
@@ -1041,6 +1061,20 @@ with gr.Blocks(css=css) as demo:
1041
  inputs=[model_type_filter],
1042
  outputs=all_dfs
1043
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1044
 
1045
  # Event handler for submission button
1046
  submit_btn.click(
 
25
  from utils.hub_storage import HubStorage
26
  from utils.token_handler import TokenHandler
27
 
28
+ from forum import ForumPost, SubmissionForum
29
+
30
 
31
  from stark_qa import load_qa
32
  from stark_qa.evaluator import Evaluator
 
41
  except Exception as e:
42
  raise RuntimeError(f"Failed to initialize HuggingFace Hub storage: {e}")
43
 
44
+ forum = SubmissionForum()
45
 
46
  def process_single_instance(args):
47
  """Process a single instance with improved validation and error handling"""
 
814
  # Send confirmation email and update leaderboard data
815
  # send_submission_confirmation(meta_data, processed_results)
816
  update_leaderboard_data(submission_data)
817
+
818
+ forum.add_submission_post(method_name, dataset, split)
819
 
820
  # Return success message
821
  return f"""
 
849
  except Exception as e:
850
  print(f"Warning: Failed to delete temporary file {temp_file}: {str(e)}")
851
 
852
+ # Modify the review script to add forum posts for status updates
853
+ def update_json_file(file_path: str, content: dict, method_name: str = None, new_status: str = None) -> bool:
854
+ """Update local JSON file and add forum post if status changed"""
855
+ try:
856
+ with open(file_path, 'w') as f:
857
+ json.dump(content, f, indent=4)
858
+
859
+ # Add forum post if this is a status update
860
+ if method_name and new_status:
861
+ forum.add_status_update(method_name, new_status)
862
+
863
+ return True
864
+ except Exception as e:
865
+ print(f"Error updating {file_path}: {str(e)}")
866
+ return False
867
+
868
  def filter_by_model_type(df, selected_types):
869
  """
870
  Filter DataFrame by selected model types, including submitted models.
 
1061
  inputs=[model_type_filter],
1062
  outputs=all_dfs
1063
  )
1064
+
1065
+ # Add forum section
1066
+ gr.Markdown("---")
1067
+ gr.Markdown("## Recent Submissions and Updates")
1068
+
1069
+ forum_display = gr.Markdown(forum.format_posts_for_display())
1070
+ refresh_btn = gr.Button("Refresh Forum")
1071
+
1072
+ # Event handler for forum refresh
1073
+ refresh_btn.click(
1074
+ lambda: forum.format_posts_for_display(),
1075
+ inputs=[],
1076
+ outputs=[forum_display]
1077
+ )
1078
 
1079
  # Event handler for submission button
1080
  submit_btn.click(