Petr Tsvetkov commited on
Commit
d154956
·
1 Parent(s): 815e7fc

Add GitHub link for commits

Browse files
Files changed (1) hide show
  1. app.py +16 -4
app.py CHANGED
@@ -1,7 +1,7 @@
1
- from datetime import datetime
2
  import os
3
  import random
4
  import uuid
 
5
 
6
  import gradio as gr
7
 
@@ -44,6 +44,10 @@ def get_diff2html_view(raw_diff):
44
  return html
45
 
46
 
 
 
 
 
47
  def update_commit_view(sample_ind):
48
  if sample_ind >= n_samples:
49
  return None
@@ -51,8 +55,11 @@ def update_commit_view(sample_ind):
51
  record = data[sample_ind]
52
 
53
  diff_view = get_diff2html_view(convert_diff_to_unified(record['mods']))
 
54
  repo_val = record['repo']
55
  hash_val = record['hash']
 
 
56
  diff_loaded_timestamp = datetime.now().isoformat()
57
 
58
  models_shuffled = models[:]
@@ -60,7 +67,8 @@ def update_commit_view(sample_ind):
60
 
61
  commit_messages = tuple(record[model] for model in models_shuffled)
62
 
63
- return (diff_view, repo_val, hash_val, diff_loaded_timestamp) + commit_messages + tuple(models_shuffled)
 
64
 
65
 
66
  def next_sample(current_sample_ind, shuffled_idx):
@@ -93,6 +101,7 @@ with gr.Blocks(theme=gr.themes.Soft(), head=head_html, css="style_overrides.css"
93
  skip_btn = gr.Button("Skip the current sample")
94
  with gr.Row():
95
  with gr.Column(scale=2):
 
96
  diff_view = gr.HTML()
97
  with gr.Column(scale=1):
98
  commit_msg = []
@@ -152,7 +161,8 @@ with gr.Blocks(theme=gr.themes.Soft(), head=head_html, css="style_overrides.css"
152
  maximum=4))
153
 
154
  has_headline.append(gr.Slider(
155
- info='The commit message includes a short headline that provides a good overview of the changes.',
 
156
  label=f'has_headline_{model_ind}',
157
  show_label=False,
158
  minimum=1,
@@ -170,7 +180,8 @@ with gr.Blocks(theme=gr.themes.Soft(), head=head_html, css="style_overrides.css"
170
  maximum=4))
171
 
172
  overall_rating.append(gr.Slider(
173
- info='Please, describe your overall impression of the commit message (1 - very bad, 5 - very good)',
 
174
  label=f'overall_rating_{model_ind}',
175
  show_label=False,
176
  minimum=1,
@@ -199,6 +210,7 @@ with gr.Blocks(theme=gr.themes.Soft(), head=head_html, css="style_overrides.css"
199
  label='submitted_ts')
200
 
201
  commit_view = [
 
202
  diff_view,
203
  repo_val,
204
  hash_val,
 
 
1
  import os
2
  import random
3
  import uuid
4
+ from datetime import datetime
5
 
6
  import gradio as gr
7
 
 
44
  return html
45
 
46
 
47
+ def get_github_link_md(repo, hash):
48
+ return f'[See the commit on Github](https://github.com/{repo}/commit/{hash})'
49
+
50
+
51
  def update_commit_view(sample_ind):
52
  if sample_ind >= n_samples:
53
  return None
 
55
  record = data[sample_ind]
56
 
57
  diff_view = get_diff2html_view(convert_diff_to_unified(record['mods']))
58
+
59
  repo_val = record['repo']
60
  hash_val = record['hash']
61
+ github_link_md = get_github_link_md(repo_val, hash_val)
62
+
63
  diff_loaded_timestamp = datetime.now().isoformat()
64
 
65
  models_shuffled = models[:]
 
67
 
68
  commit_messages = tuple(record[model] for model in models_shuffled)
69
 
70
+ return (github_link_md, diff_view, repo_val, hash_val, diff_loaded_timestamp) + commit_messages + tuple(
71
+ models_shuffled)
72
 
73
 
74
  def next_sample(current_sample_ind, shuffled_idx):
 
101
  skip_btn = gr.Button("Skip the current sample")
102
  with gr.Row():
103
  with gr.Column(scale=2):
104
+ github_link = gr.Markdown()
105
  diff_view = gr.HTML()
106
  with gr.Column(scale=1):
107
  commit_msg = []
 
161
  maximum=4))
162
 
163
  has_headline.append(gr.Slider(
164
+ info='The commit message includes a short headline that provides a good overview of the '
165
+ 'changes.',
166
  label=f'has_headline_{model_ind}',
167
  show_label=False,
168
  minimum=1,
 
180
  maximum=4))
181
 
182
  overall_rating.append(gr.Slider(
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
  minimum=1,
 
210
  label='submitted_ts')
211
 
212
  commit_view = [
213
+ github_link,
214
  diff_view,
215
  repo_val,
216
  hash_val,