Spaces:
Runtime error
Runtime error
Tristan Thrush
commited on
Commit
•
a54b97e
1
Parent(s):
96e0ce2
debugging
Browse files
app.py
CHANGED
@@ -17,7 +17,7 @@ with demo:
|
|
17 |
dummy = gr.Textbox(visible=False) # dummy for passing assignmentId
|
18 |
|
19 |
# We keep track of state as a Variable
|
20 |
-
state_dict = {"assignmentId": "", "cnt": 0, "fooled": 0, "data": [], "metadata": {}}
|
21 |
state = gr.Variable(state_dict)
|
22 |
|
23 |
gr.Markdown("# DADC in Gradio example")
|
@@ -64,13 +64,16 @@ with demo:
|
|
64 |
# Update the URL below to switch from Sandbox to real data collection
|
65 |
def _submit(state, dummy):
|
66 |
query = parse_qs(dummy[1:])
|
|
|
67 |
assert "assignment_id" in query, "No assignment ID provided, unable to submit"
|
|
|
68 |
state["assignmentId"] = query["assignment_id"]
|
69 |
url = "https://workersandbox.mturk.com/mturk/externalSubmit"
|
70 |
x = requests.post(url, data=state)
|
|
|
71 |
print(x)
|
72 |
-
print(x.text)
|
73 |
-
return x
|
74 |
|
75 |
# Button event handlers
|
76 |
submit_ex_button.click(
|
@@ -78,10 +81,12 @@ with demo:
|
|
78 |
inputs=[text_input, label_input, state],
|
79 |
outputs=[label_output, text_output, state, example_submit, final_submit, state_display],
|
80 |
)
|
|
|
|
|
81 |
submit_hit_button.click(
|
82 |
_submit,
|
83 |
inputs=[state, dummy],
|
84 |
-
outputs=
|
85 |
_js="function(state, dummy) { return [state, window.location.search]; }",
|
86 |
)
|
87 |
#gr.Markdown(state["response"].text if "response" in state and state["response"] is not None else "")
|
|
|
17 |
dummy = gr.Textbox(visible=False) # dummy for passing assignmentId
|
18 |
|
19 |
# We keep track of state as a Variable
|
20 |
+
state_dict = {"assignmentId": "", "cnt": 0, "fooled": 0, "data": [], "metadata": {}, "response": ""}
|
21 |
state = gr.Variable(state_dict)
|
22 |
|
23 |
gr.Markdown("# DADC in Gradio example")
|
|
|
64 |
# Update the URL below to switch from Sandbox to real data collection
|
65 |
def _submit(state, dummy):
|
66 |
query = parse_qs(dummy[1:])
|
67 |
+
print('yo')
|
68 |
assert "assignment_id" in query, "No assignment ID provided, unable to submit"
|
69 |
+
print('yo2')
|
70 |
state["assignmentId"] = query["assignment_id"]
|
71 |
url = "https://workersandbox.mturk.com/mturk/externalSubmit"
|
72 |
x = requests.post(url, data=state)
|
73 |
+
print('yo3')
|
74 |
print(x)
|
75 |
+
#print(x.text)
|
76 |
+
return str(x) + " With assignmentID " + state["assignmentId"][0], state, dummy
|
77 |
|
78 |
# Button event handlers
|
79 |
submit_ex_button.click(
|
|
|
81 |
inputs=[text_input, label_input, state],
|
82 |
outputs=[label_output, text_output, state, example_submit, final_submit, state_display],
|
83 |
)
|
84 |
+
|
85 |
+
response_output = gr.Markdown()
|
86 |
submit_hit_button.click(
|
87 |
_submit,
|
88 |
inputs=[state, dummy],
|
89 |
+
outputs=[response_output, state, dummy],
|
90 |
_js="function(state, dummy) { return [state, window.location.search]; }",
|
91 |
)
|
92 |
#gr.Markdown(state["response"].text if "response" in state and state["response"] is not None else "")
|