Tristan Thrush commited on
Commit
29025ba
1 Parent(s): 40bc8d5
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -63,12 +63,12 @@ with demo:
63
  toggle_example_submit = gr.update(visible=not done)
64
  new_state_md = f"State: {state['cnt']}/{total_cnt} ({state['fooled']} fooled)"
65
 
 
66
  if "assignmentId" in query:
67
  # It seems that someone is using this app on mturk. We need to
68
  # store the assignmentId in the state before submit_hit_button
69
  # is clicked. We can do this here in _predict. We need to save the
70
  # assignmentId so that the turker can get credit for their hit.
71
- query = parse_qs(dummy[1:])
72
  state["assignmentId"] = query["assignmentId"][0]
73
 
74
  return pred_confidences, ret, state, toggle_example_submit, toggle_final_submit, new_state_md, dummy
@@ -89,7 +89,7 @@ with demo:
89
  # The HIT is also stored and logged on mturk when post_hit_js is run below.
90
  # This _store_in_huggingface_dataset function just demonstrates how easy it is
91
  # to automatically create a Hugging Face dataset from mturk.
92
- def _store_in_huggingface_dataset(state, toggle_final_submit, toggle_example_submit, new_state_md):
93
  with open(DATA_FILE, "a") as jsonlfile:
94
  jsonlfile.write(json.dumps(state) + "\n")
95
  repo.push_to_hub()
@@ -136,14 +136,14 @@ with demo:
136
  document.body.appendChild(form);
137
  form.submit();
138
  }
139
- return [state, toggle_final_submit, toggle_example_submit, new_state_md];
140
  }
141
  """
142
 
143
  submit_hit_button.click(
144
  _store_in_huggingface_dataset,
145
- inputs=[state, toggle_final_submit, toggle_example_submit, new_state_md],
146
- outputs=[state, toggle_final_submit, toggle_example_submit, new_state_md],
147
  _js=post_hit_js,
148
  )
149
 
 
63
  toggle_example_submit = gr.update(visible=not done)
64
  new_state_md = f"State: {state['cnt']}/{total_cnt} ({state['fooled']} fooled)"
65
 
66
+ query = parse_qs(dummy[1:])
67
  if "assignmentId" in query:
68
  # It seems that someone is using this app on mturk. We need to
69
  # store the assignmentId in the state before submit_hit_button
70
  # is clicked. We can do this here in _predict. We need to save the
71
  # assignmentId so that the turker can get credit for their hit.
 
72
  state["assignmentId"] = query["assignmentId"][0]
73
 
74
  return pred_confidences, ret, state, toggle_example_submit, toggle_final_submit, new_state_md, dummy
 
89
  # The HIT is also stored and logged on mturk when post_hit_js is run below.
90
  # This _store_in_huggingface_dataset function just demonstrates how easy it is
91
  # to automatically create a Hugging Face dataset from mturk.
92
+ def _store_in_huggingface_dataset(state):
93
  with open(DATA_FILE, "a") as jsonlfile:
94
  jsonlfile.write(json.dumps(state) + "\n")
95
  repo.push_to_hub()
 
136
  document.body.appendChild(form);
137
  form.submit();
138
  }
139
+ return [state];
140
  }
141
  """
142
 
143
  submit_hit_button.click(
144
  _store_in_huggingface_dataset,
145
+ inputs=[state],
146
+ outputs=[state, final_submit, example_submit, state_display],
147
  _js=post_hit_js,
148
  )
149