Mengyuan Liu commited on
Commit
4ea00ca
1 Parent(s): 50ed5c4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -85
app.py CHANGED
@@ -46,35 +46,6 @@ def on_confirm(dataset_radio, num_parts_dropdown, token_counts_radio, line_count
46
 
47
 
48
 
49
- # 定义一个函数来返回数据
50
- # def show_data(line_counts, token_counts, cyclomatic_complexity, problem_type, show_high, show_medium, show_low):
51
- # columns = ["Model"]
52
- #
53
- # if token_counts:
54
- # if show_high:
55
- # columns.append("Token Counts.I")
56
- #
57
- # if show_medium:
58
- # columns.append("Token Counts.II")
59
- # if show_low:
60
- # columns.append("Token Counts.III")
61
- # if line_counts:
62
- # if show_high:
63
- # columns.append("Line Counts.I")
64
- # if show_medium:
65
- # columns.append("Line Counts.II")
66
- # if show_low:
67
- # columns.append("Line Counts.III")
68
- # if cyclomatic_complexity:
69
- # if show_high:
70
- # columns.append("Cyclomatic Complexity.I")
71
- # if show_medium:
72
- # columns.append("Cyclomatic Complexity.II")
73
- # if show_low:
74
- # columns.append("Cyclomatic Complexity.III")
75
- # if problem_type:
76
- # columns.extend(["Problem Type_String", "Problem Type_Math", "Problem Type_Array"])
77
- # return data[columns]
78
  #用于更新数据文件的部分
79
  def execute_specified_python_files(directory_list, file_list):
80
  for directory in directory_list:
@@ -90,53 +61,8 @@ def execute_specified_python_files(directory_list, file_list):
90
  print(f"Error executing {file_path}: {e}")
91
  else:
92
  print(f"File {file_path} does not exist or is not a Python file.")
93
- # 定义一个函数来生成 CSS 样式
94
- def generate_css(line_counts, token_counts, cyclomatic_complexity, problem_type, show_high, show_medium, show_low):
95
- css = """
96
- #dataframe th {
97
- background-color: #f2f2f2
98
-
99
- }
100
- """
101
- colors = ["#e6f7ff", "#ffeecc", "#e6ffe6", "#ffe6e6"]
102
- categories = [line_counts, token_counts, cyclomatic_complexity]
103
- category_index = 0
104
- column_index = 1
105
-
106
- for category in categories:
107
- if category:
108
- if show_high:
109
- css += f"#dataframe td:nth-child({column_index + 1}) {{ background-color: {colors[category_index]}; }}\n"
110
- column_index += 1
111
- if show_medium:
112
- css += f"#dataframe td:nth-child({column_index + 1}) {{ background-color: {colors[category_index]}; }}\n"
113
- column_index += 1
114
- if show_low:
115
- css += f"#dataframe td:nth-child({column_index + 1}) {{ background-color: {colors[category_index]}; }}\n"
116
- column_index += 1
117
- category_index += 1
118
-
119
- # 为 Problem Type 相关的三个子列设置固定颜色
120
- if problem_type:
121
- problem_type_color = "#d4f0fc" # 你可以选择任何你喜欢的颜色
122
- css += f"#dataframe td:nth-child({column_index + 1}) {{ background-color: {problem_type_color}; }}\n"
123
- css += f"#dataframe td:nth-child({column_index + 2}) {{ background-color: {problem_type_color}; }}\n"
124
- css += f"#dataframe td:nth-child({column_index + 3}) {{ background-color: {problem_type_color}; }}\n"
125
-
126
- # 隐藏 "data" 标识
127
- css += """
128
- .gradio-container .dataframe-container::before {
129
- content: none !important;
130
- }
131
- """
132
-
133
- return css
134
- # def update_dataframe(line_counts, token_counts, cyclomatic_complexity, problem_type, show_high, show_medium,
135
- # show_low):
136
- # df = show_data(line_counts, token_counts, cyclomatic_complexity, problem_type, show_high, show_medium, show_low)
137
- # css = generate_css(line_counts, token_counts, cyclomatic_complexity, problem_type, show_high, show_medium,
138
- # show_low)
139
- # return gr.update(value=df), gr.update(value=f"<style>{css}</style>")
140
 
141
 
142
  def generate_file(file_obj, user_string, user_number,dataset_choice):
@@ -384,14 +310,5 @@ with gr.Blocks() as iface:
384
 
385
 
386
 
387
- # 初始化数据表格
388
- # initial_df = show_data(False, False, False, False, False, False, False)
389
- # initial_css = generate_css(False, False, False, False, True, False, False)
390
- # dataframe_output.value = initial_df
391
- # css_output.value = f"<style>{initial_css}</style>"
392
-
393
-
394
-
395
-
396
  # 启动界面
397
  iface.launch()
 
46
 
47
 
48
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49
  #用于更新数据文件的部分
50
  def execute_specified_python_files(directory_list, file_list):
51
  for directory in directory_list:
 
61
  print(f"Error executing {file_path}: {e}")
62
  else:
63
  print(f"File {file_path} does not exist or is not a Python file.")
64
+
65
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
66
 
67
 
68
  def generate_file(file_obj, user_string, user_number,dataset_choice):
 
310
 
311
 
312
 
 
 
 
 
 
 
 
 
 
313
  # 启动界面
314
  iface.launch()