ynhe commited on
Commit
17401cb
1 Parent(s): 0c33ecc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -7
app.py CHANGED
@@ -1,12 +1,14 @@
1
-
2
  __all__ = ['block', 'make_clickable_model', 'make_clickable_user', 'get_submissions']
3
-
4
  import gradio as gr
5
  import pandas as pd
6
  import json
7
  import tempfile
8
 
9
  from constants import *
 
 
 
10
 
11
  global data_component, filter_component
12
 
@@ -29,6 +31,8 @@ def add_new_eval(
29
  return "Error! Empty file!"
30
 
31
  upload_data=json.loads(input_file)
 
 
32
  csv_data = pd.read_csv(CSV_DIR)
33
 
34
  if LLM_type == 'Other':
@@ -66,10 +70,12 @@ def add_new_eval(
66
  new_data.append(0)
67
  csv_data.loc[col] = new_data
68
  csv_data = csv_data.to_csv(CSV_DIR, index=False)
 
69
  return 0
70
 
71
  def get_baseline_df():
72
- # pdb.set_trace()
 
73
  df = pd.read_csv(CSV_DIR)
74
  df = df.sort_values(by="Avg", ascending=False)
75
  present_columns = MODEL_INFO + checkbox_group.value
@@ -77,6 +83,8 @@ def get_baseline_df():
77
  return df
78
 
79
  def get_all_df():
 
 
80
  df = pd.read_csv(CSV_DIR)
81
  df = df.sort_values(by="Avg", ascending=False)
82
  return df
@@ -111,9 +119,6 @@ with block:
111
  interactive=True,
112
  )
113
 
114
-
115
-
116
- # 创建数据帧组件
117
  data_component = gr.components.Dataframe(
118
  value=get_baseline_df,
119
  headers=COLUMN_NAMES,
@@ -129,6 +134,7 @@ with block:
129
  # columns:
130
  selected_columns = [item for item in TASK_INFO if item in selected_columns]
131
  present_columns = MODEL_INFO + selected_columns
 
132
  updated_data = updated_data[present_columns]
133
  updated_data = updated_data.sort_values(by=selected_columns[0], ascending=False)
134
  updated_headers = present_columns
@@ -226,7 +232,6 @@ with block:
226
 
227
  def refresh_data():
228
  value1 = get_baseline_df()
229
-
230
  return value1
231
 
232
  with gr.Row():
 
 
1
  __all__ = ['block', 'make_clickable_model', 'make_clickable_user', 'get_submissions']
2
+ import os
3
  import gradio as gr
4
  import pandas as pd
5
  import json
6
  import tempfile
7
 
8
  from constants import *
9
+ from huggingface_hub import Repository
10
+
11
+ HF_TOKEN = os.environ.get("HF_TOKEN")
12
 
13
  global data_component, filter_component
14
 
 
31
  return "Error! Empty file!"
32
 
33
  upload_data=json.loads(input_file)
34
+ submission_repo = Repository(local_dir=SUBMISSION_NAME, clone_from=SUBMISSION_URL, use_auth_token=HF_TOKEN, repo_type="dataset")
35
+ submission_repo.git_pull()
36
  csv_data = pd.read_csv(CSV_DIR)
37
 
38
  if LLM_type == 'Other':
 
70
  new_data.append(0)
71
  csv_data.loc[col] = new_data
72
  csv_data = csv_data.to_csv(CSV_DIR, index=False)
73
+ submission_repo.push_to_hub()
74
  return 0
75
 
76
  def get_baseline_df():
77
+ submission_repo = Repository(local_dir=SUBMISSION_NAME, clone_from=SUBMISSION_URL, use_auth_token=HF_TOKEN, repo_type="dataset")
78
+ submission_repo.git_pull()
79
  df = pd.read_csv(CSV_DIR)
80
  df = df.sort_values(by="Avg", ascending=False)
81
  present_columns = MODEL_INFO + checkbox_group.value
 
83
  return df
84
 
85
  def get_all_df():
86
+ submission_repo = Repository(local_dir=SUBMISSION_NAME, clone_from=SUBMISSION_URL, use_auth_token=HF_TOKEN, repo_type="dataset")
87
+ submission_repo.git_pull()
88
  df = pd.read_csv(CSV_DIR)
89
  df = df.sort_values(by="Avg", ascending=False)
90
  return df
 
119
  interactive=True,
120
  )
121
 
 
 
 
122
  data_component = gr.components.Dataframe(
123
  value=get_baseline_df,
124
  headers=COLUMN_NAMES,
 
134
  # columns:
135
  selected_columns = [item for item in TASK_INFO if item in selected_columns]
136
  present_columns = MODEL_INFO + selected_columns
137
+ print("selected_columns",'|'.join(selected_columns))
138
  updated_data = updated_data[present_columns]
139
  updated_data = updated_data.sort_values(by=selected_columns[0], ascending=False)
140
  updated_headers = present_columns
 
232
 
233
  def refresh_data():
234
  value1 = get_baseline_df()
 
235
  return value1
236
 
237
  with gr.Row():