Spaces:
Sleeping
Sleeping
Petr Tsvetkov
commited on
Commit
·
9589862
1
Parent(s):
5df3f2f
Reset the answers when moving to the next sample
Browse files
app.py
CHANGED
@@ -9,6 +9,7 @@ from data_loader import load_data
|
|
9 |
|
10 |
HF_TOKEN = os.environ.get('HF_TOKEN')
|
11 |
HF_DATASET = os.environ.get('HF_DATASET')
|
|
|
12 |
|
13 |
data, models = load_data()
|
14 |
|
@@ -71,13 +72,17 @@ def update_commit_view(sample_ind):
|
|
71 |
models_shuffled)
|
72 |
|
73 |
|
|
|
|
|
|
|
|
|
74 |
def next_sample(current_sample_ind, shuffled_idx):
|
75 |
if current_sample_ind == n_samples:
|
76 |
return None
|
77 |
|
78 |
current_sample_ind += 1
|
79 |
updated_view = update_commit_view(shuffled_idx[current_sample_ind])
|
80 |
-
return (current_sample_ind,) + updated_view
|
81 |
|
82 |
|
83 |
with open("head.html") as head_file:
|
@@ -115,79 +120,67 @@ with gr.Blocks(theme=gr.themes.Soft(), head=head_html, css="style_overrides.css"
|
|
115 |
comments = []
|
116 |
model_name = []
|
117 |
|
|
|
|
|
118 |
for model_ind in range(n_models):
|
119 |
-
with gr.Tab(f"
|
120 |
commit_msg.append(gr.TextArea(label="Commit message (can be scrollable)",
|
121 |
interactive=False,
|
122 |
))
|
123 |
gr.Markdown("## Please, rate your level of agreement with each statement\n"
|
124 |
"\n"
|
125 |
-
"*1 - strongly disagree, 2 - disagree, 3 -
|
126 |
|
127 |
-
is_correct.append(gr.
|
128 |
info='The information provided in the commit message is consistent with the code changes.',
|
129 |
label=f'is_correct_{model_ind}',
|
130 |
show_label=False,
|
131 |
-
|
132 |
-
|
133 |
-
interactive=True,
|
134 |
-
maximum=4))
|
135 |
-
|
136 |
-
has_what.append(gr.Slider(
|
137 |
-
info='The commit message answers the question of WHAT changes have been made.',
|
138 |
-
label=f'has_what_{model_ind}',
|
139 |
-
show_label=False,
|
140 |
-
minimum=1,
|
141 |
-
step=1,
|
142 |
-
interactive=True,
|
143 |
-
maximum=4))
|
144 |
-
|
145 |
-
has_why.append(gr.Slider(
|
146 |
-
info='The commit message answers the question of WHY these changes have been made.',
|
147 |
-
label=f'has_why_{model_ind}',
|
148 |
-
show_label=False,
|
149 |
-
minimum=1,
|
150 |
-
step=1,
|
151 |
-
interactive=True,
|
152 |
-
maximum=4))
|
153 |
|
154 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
155 |
info='The commit message can be substantially shortened without loss of important information.',
|
156 |
label=f'is_not_verbose_{model_ind}',
|
157 |
show_label=False,
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
minimum=1,
|
169 |
-
step=1,
|
170 |
-
interactive=True,
|
171 |
-
maximum=4))
|
172 |
|
173 |
-
easy_to_read.append(gr.
|
174 |
info='The commit message is easy to read and to understand.',
|
175 |
label=f'easy_to_read_{model_ind}',
|
176 |
show_label=False,
|
177 |
-
|
178 |
-
|
179 |
-
interactive=True,
|
180 |
-
maximum=4))
|
181 |
|
182 |
-
overall_rating.append(gr.
|
183 |
info='Please, describe your overall impression of the commit message (1 - very bad, 5 - very '
|
184 |
'good)',
|
185 |
label=f'overall_rating_{model_ind}',
|
186 |
show_label=False,
|
187 |
-
|
188 |
-
|
189 |
-
interactive=True,
|
190 |
-
maximum=5))
|
191 |
|
192 |
comments.append(gr.Textbox(
|
193 |
info='Additional comments on the commit message',
|
@@ -216,30 +209,35 @@ with gr.Blocks(theme=gr.themes.Soft(), head=head_html, css="style_overrides.css"
|
|
216 |
hash_val,
|
217 |
sample_loaded_timestamp,
|
218 |
*commit_msg,
|
219 |
-
*model_name
|
220 |
]
|
221 |
|
222 |
-
|
223 |
session_val,
|
224 |
repo_val,
|
225 |
hash_val,
|
226 |
sample_loaded_timestamp,
|
227 |
sample_submitted_timestamp,
|
|
|
|
|
|
|
|
|
228 |
*is_correct,
|
229 |
-
*has_what,
|
230 |
-
*has_why,
|
231 |
*is_not_verbose,
|
232 |
-
*has_headline,
|
233 |
*easy_to_read,
|
234 |
*overall_rating,
|
235 |
-
*comments
|
236 |
-
*model_name
|
237 |
]
|
238 |
|
239 |
-
|
|
|
|
|
240 |
|
241 |
skip_btn.click(next_sample, inputs=[current_sample_sld, shuffled_idx_val],
|
242 |
-
outputs=[current_sample_sld] + commit_view)
|
243 |
|
244 |
|
245 |
def submit(current_sample, shuffled_idx, *args):
|
@@ -247,8 +245,8 @@ with gr.Blocks(theme=gr.themes.Soft(), head=head_html, css="style_overrides.css"
|
|
247 |
return next_sample(current_sample, shuffled_idx)
|
248 |
|
249 |
|
250 |
-
submit_btn.click(submit, inputs=[current_sample_sld, shuffled_idx_val] +
|
251 |
-
outputs=[current_sample_sld] + commit_view)
|
252 |
|
253 |
|
254 |
def init_session(current_sample):
|
|
|
9 |
|
10 |
HF_TOKEN = os.environ.get('HF_TOKEN')
|
11 |
HF_DATASET = os.environ.get('HF_DATASET')
|
12 |
+
N_QUESTIONS = 5
|
13 |
|
14 |
data, models = load_data()
|
15 |
|
|
|
72 |
models_shuffled)
|
73 |
|
74 |
|
75 |
+
def reset_answers():
|
76 |
+
return (None,) * (n_models * N_QUESTIONS)
|
77 |
+
|
78 |
+
|
79 |
def next_sample(current_sample_ind, shuffled_idx):
|
80 |
if current_sample_ind == n_samples:
|
81 |
return None
|
82 |
|
83 |
current_sample_ind += 1
|
84 |
updated_view = update_commit_view(shuffled_idx[current_sample_ind])
|
85 |
+
return (current_sample_ind,) + updated_view + reset_answers()
|
86 |
|
87 |
|
88 |
with open("head.html") as head_file:
|
|
|
120 |
comments = []
|
121 |
model_name = []
|
122 |
|
123 |
+
SCALE = list(range(1, 6))
|
124 |
+
|
125 |
for model_ind in range(n_models):
|
126 |
+
with gr.Tab(f"Variant #{model_ind + 1}"):
|
127 |
commit_msg.append(gr.TextArea(label="Commit message (can be scrollable)",
|
128 |
interactive=False,
|
129 |
))
|
130 |
gr.Markdown("## Please, rate your level of agreement with each statement\n"
|
131 |
"\n"
|
132 |
+
"*1 - strongly disagree, 2 - disagree, 3 - not sure, 4 - agree, 5 - strongly agree*")
|
133 |
|
134 |
+
is_correct.append(gr.Radio(
|
135 |
info='The information provided in the commit message is consistent with the code changes.',
|
136 |
label=f'is_correct_{model_ind}',
|
137 |
show_label=False,
|
138 |
+
choices=SCALE,
|
139 |
+
interactive=True))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
140 |
|
141 |
+
# has_what.append(gr.Radio(
|
142 |
+
# info='The commit message answers the question of WHAT changes have been made.',
|
143 |
+
# label=f'has_what_{model_ind}',
|
144 |
+
# show_label=False,
|
145 |
+
# choices=SCALE,
|
146 |
+
# interactive=True))
|
147 |
+
#
|
148 |
+
# has_why.append(gr.Radio(
|
149 |
+
# info='The commit message answers the question of WHY these changes have been made.',
|
150 |
+
# label=f'has_why_{model_ind}',
|
151 |
+
# show_label=False,
|
152 |
+
# choices=SCALE,
|
153 |
+
# interactive=True))
|
154 |
+
|
155 |
+
is_not_verbose.append(gr.Radio(
|
156 |
info='The commit message can be substantially shortened without loss of important information.',
|
157 |
label=f'is_not_verbose_{model_ind}',
|
158 |
show_label=False,
|
159 |
+
choices=SCALE,
|
160 |
+
interactive=True))
|
161 |
+
|
162 |
+
# has_headline.append(gr.Radio(
|
163 |
+
# info='The commit message includes a short headline that provides a good overview of the '
|
164 |
+
# 'changes.',
|
165 |
+
# label=f'has_headline_{model_ind}',
|
166 |
+
# show_label=False,
|
167 |
+
# choices=SCALE,
|
168 |
+
# interactive=True))
|
|
|
|
|
|
|
|
|
169 |
|
170 |
+
easy_to_read.append(gr.Radio(
|
171 |
info='The commit message is easy to read and to understand.',
|
172 |
label=f'easy_to_read_{model_ind}',
|
173 |
show_label=False,
|
174 |
+
choices=SCALE,
|
175 |
+
interactive=True))
|
|
|
|
|
176 |
|
177 |
+
overall_rating.append(gr.Radio(
|
178 |
info='Please, describe your overall impression of the commit message (1 - very bad, 5 - very '
|
179 |
'good)',
|
180 |
label=f'overall_rating_{model_ind}',
|
181 |
show_label=False,
|
182 |
+
choices=SCALE,
|
183 |
+
interactive=True))
|
|
|
|
|
184 |
|
185 |
comments.append(gr.Textbox(
|
186 |
info='Additional comments on the commit message',
|
|
|
209 |
hash_val,
|
210 |
sample_loaded_timestamp,
|
211 |
*commit_msg,
|
212 |
+
*model_name,
|
213 |
]
|
214 |
|
215 |
+
feedback_metadata = [
|
216 |
session_val,
|
217 |
repo_val,
|
218 |
hash_val,
|
219 |
sample_loaded_timestamp,
|
220 |
sample_submitted_timestamp,
|
221 |
+
*model_name
|
222 |
+
]
|
223 |
+
|
224 |
+
feedback_answers = [
|
225 |
*is_correct,
|
226 |
+
# *has_what,
|
227 |
+
# *has_why,
|
228 |
*is_not_verbose,
|
229 |
+
# *has_headline,
|
230 |
*easy_to_read,
|
231 |
*overall_rating,
|
232 |
+
*comments
|
|
|
233 |
]
|
234 |
|
235 |
+
assert len(feedback_answers) == N_QUESTIONS * n_models
|
236 |
+
|
237 |
+
saver.setup([current_sample_sld] + feedback_metadata + feedback_answers, "feedback")
|
238 |
|
239 |
skip_btn.click(next_sample, inputs=[current_sample_sld, shuffled_idx_val],
|
240 |
+
outputs=[current_sample_sld] + commit_view + feedback_answers)
|
241 |
|
242 |
|
243 |
def submit(current_sample, shuffled_idx, *args):
|
|
|
245 |
return next_sample(current_sample, shuffled_idx)
|
246 |
|
247 |
|
248 |
+
submit_btn.click(submit, inputs=[current_sample_sld, shuffled_idx_val] + feedback_metadata + feedback_answers,
|
249 |
+
outputs=[current_sample_sld] + commit_view + feedback_answers)
|
250 |
|
251 |
|
252 |
def init_session(current_sample):
|