Pendrokar commited on
Commit
494526e
1 Parent(s): 193c0b7

shuffle cached

Browse files
Files changed (1) hide show
  1. app.py +6 -2
app.py CHANGED
@@ -280,6 +280,7 @@ voting_users = {
280
 
281
  def generate_matching_pairs(samples: List[Sample]) -> List[Tuple[Sample, Sample]]:
282
  transcript_groups: Dict[str, List[Sample]] = {}
 
283
  for sample in samples:
284
  if sample.transcript not in transcript_groups:
285
  transcript_groups[sample.transcript] = []
@@ -1119,11 +1120,11 @@ def unlock_vote(btn_index, aplayed, bplayed):
1119
 
1120
  def get_userid(request: gr.Request):
1121
  if request.username:
1122
- print('auth by username')
1123
  # by HuggingFace username
1124
  return sha1(bytes(request.username.encode('ascii'))).hexdigest()
1125
  else:
1126
- print('auth by ip')
1127
  # by IP address
1128
  return sha1(bytes(request.client.host.encode('ascii'))).hexdigest()
1129
  # by browser session hash
@@ -1135,6 +1136,7 @@ def give_cached_sample(request: gr.Request):
1135
  # add new userid to voting_users from Browser session hash
1136
  # stored only in RAM
1137
  userid = get_userid(request)
 
1138
 
1139
  if userid not in voting_users:
1140
  voting_users[userid] = User(userid)
@@ -1183,6 +1185,8 @@ def give_cached_sample(request: gr.Request):
1183
  # note the vote on cached sample pair
1184
  def voted_on_cached(modelName1: str, modelName2: str, transcript: str, request: gr.Request):
1185
  userid = get_userid(request)
 
 
1186
  if userid not in voting_users:
1187
  voting_users[userid] = User(userid)
1188
 
 
280
 
281
  def generate_matching_pairs(samples: List[Sample]) -> List[Tuple[Sample, Sample]]:
282
  transcript_groups: Dict[str, List[Sample]] = {}
283
+ samples = random.sample(samples, k=len(samples))
284
  for sample in samples:
285
  if sample.transcript not in transcript_groups:
286
  transcript_groups[sample.transcript] = []
 
1120
 
1121
  def get_userid(request: gr.Request):
1122
  if request.username:
1123
+ # print('auth by username')
1124
  # by HuggingFace username
1125
  return sha1(bytes(request.username.encode('ascii'))).hexdigest()
1126
  else:
1127
+ # print('auth by ip')
1128
  # by IP address
1129
  return sha1(bytes(request.client.host.encode('ascii'))).hexdigest()
1130
  # by browser session hash
 
1136
  # add new userid to voting_users from Browser session hash
1137
  # stored only in RAM
1138
  userid = get_userid(request)
1139
+ print(f'userid asked for cached: {userid}')
1140
 
1141
  if userid not in voting_users:
1142
  voting_users[userid] = User(userid)
 
1185
  # note the vote on cached sample pair
1186
  def voted_on_cached(modelName1: str, modelName2: str, transcript: str, request: gr.Request):
1187
  userid = get_userid(request)
1188
+ print(f'userid voted on cached: {userid}')
1189
+
1190
  if userid not in voting_users:
1191
  voting_users[userid] = User(userid)
1192