Pendrokar commited on
Commit
ead44bc
Β·
1 Parent(s): 326eddb

prev model visible fix

Browse files
Files changed (2) hide show
  1. app/sample_caching.py +7 -3
  2. app/vote.py +6 -6
app/sample_caching.py CHANGED
@@ -131,10 +131,14 @@ def give_cached_sample(session_hash: str, autoplay: bool, request: gr.Request):
131
  return None
132
 
133
  pair = get_next_pair(voting_users[userid])
 
134
  if pair is None:
135
  comp_defaults = []
136
  for i in range(0, 14):
137
- comp_defaults.append(gr.update())
 
 
 
138
  return [
139
  *comp_defaults,
140
  # *clear_stuff(),
@@ -152,8 +156,8 @@ def give_cached_sample(session_hash: str, autoplay: bool, request: gr.Request):
152
  gr.update(visible=True, value=pair[1].filename, interactive=False, autoplay=False, playback_position=0), # aud2
153
  gr.update(visible=True, interactive=False), #abetter
154
  gr.update(visible=True, interactive=False), #bbetter
155
- gr.update(visible=False), #prevmodel1
156
- gr.update(visible=False), #prevmodel2
157
  gr.update(visible=True, value="⚑ Skip Round", elem_classes=['skip-round']), #nxt round btn
158
  # reset aplayed, bplayed audio playback events
159
  False, #aplayed
 
131
  return None
132
 
133
  pair = get_next_pair(voting_users[userid])
134
+ # no other cached pair, generate default outputs
135
  if pair is None:
136
  comp_defaults = []
137
  for i in range(0, 14):
138
+ if (i >= 9 and i <= 10): # prevmodel1 || prevmodel2
139
+ comp_defaults.append(gr.update(visible=False))
140
+ else:
141
+ comp_defaults.append(gr.update())
142
  return [
143
  *comp_defaults,
144
  # *clear_stuff(),
 
156
  gr.update(visible=True, value=pair[1].filename, interactive=False, autoplay=False, playback_position=0), # aud2
157
  gr.update(visible=True, interactive=False), #abetter
158
  gr.update(visible=True, interactive=False), #bbetter
159
+ gr.HTML(value='', visible=False), #prevmodel1 FIXME: Gradio ignores visible=False
160
+ gr.HTML(value='', visible=False), #prevmodel2 FIXME: Gradio ignores visible=False
161
  gr.update(visible=True, value="⚑ Skip Round", elem_classes=['skip-round']), #nxt round btn
162
  # reset aplayed, bplayed audio playback events
163
  False, #aplayed
app/vote.py CHANGED
@@ -114,17 +114,17 @@ def reload(chosenmodel1=None, chosenmodel2=None, userid=None, chose_a=False, cho
114
  chosenmodel1 = make_link_to_space(chosenmodel1)
115
  chosenmodel2 = make_link_to_space(chosenmodel2)
116
  out = [
117
- gr.update(interactive=False, visible=False),
118
- gr.update(interactive=False, visible=False)
119
  ]
120
  style = 'text-align: center; font-size: 1rem; margin-bottom: 0; padding: var(--input-padding)'
121
  if chose_a == True:
122
- out.append(gr.HTML(value=f'<p style="{style}">Your vote: {chosenmodel1}</p>', visible=True))
123
- out.append(gr.HTML(value=f'<p style="{style}">{chosenmodel2}</p>', visible=True))
124
  gr.Info(f'{chosenmodel1}πŸ”ΌπŸ† > {chosenmodel2}πŸ”½', duration=5)
125
  else:
126
- out.append(gr.HTML(value=f'<p style="{style}">{chosenmodel1}</p>', visible=True))
127
- out.append(gr.HTML(value=f'<p style="{style}">Your vote: {chosenmodel2}</p>', visible=True))
128
  gr.Info(f'{chosenmodel1}πŸ”½ < {chosenmodel2}πŸ”ΌπŸ†', duration=5)
129
  out.append(gr.update(visible=True, value="⚑ [N]ext Round", elem_classes=['next-round']))
130
  return out
 
114
  chosenmodel1 = make_link_to_space(chosenmodel1)
115
  chosenmodel2 = make_link_to_space(chosenmodel2)
116
  out = [
117
+ gr.update(interactive=False, visible=True),
118
+ gr.update(interactive=False, visible=True)
119
  ]
120
  style = 'text-align: center; font-size: 1rem; margin-bottom: 0; padding: var(--input-padding)'
121
  if chose_a == True:
122
+ out.append(gr.update(value=f'<p style="{style}">Your vote: {chosenmodel1}</p>', visible=True))
123
+ out.append(gr.update(value=f'<p style="{style}">{chosenmodel2}</p>', visible=True))
124
  gr.Info(f'{chosenmodel1}πŸ”ΌπŸ† > {chosenmodel2}πŸ”½', duration=5)
125
  else:
126
+ out.append(gr.update(value=f'<p style="{style}">{chosenmodel1}</p>', visible=True))
127
+ out.append(gr.update(value=f'<p style="{style}">Your vote: {chosenmodel2}</p>', visible=True))
128
  gr.Info(f'{chosenmodel1}πŸ”½ < {chosenmodel2}πŸ”ΌπŸ†', duration=5)
129
  out.append(gr.update(visible=True, value="⚑ [N]ext Round", elem_classes=['next-round']))
130
  return out