-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.py
35 lines (28 loc) · 1.04 KB
/
deploy.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import json
from mturk import Mturk
import pandas as pd
data_path = 'test2.json'
with open(data_path) as data_file:
data = json.load(data_file)
# Create your connection to MTurk
mturk = Mturk()
mturk.account_balance()
mturk.remove_old_hits()
df = pd.DataFrame(columns=['path', 'hit_id'])
for thread in data:
for email in thread['emails']:
# try:
response = mturk.create_hit(email)
# except Exception as e:
# print(e.message)
# continue
# The response included several fields that will be helpful later
hit_type_id = response[0].HITTypeId
hit_id = response[0].HITId
print("Your HIT has been created. You can see it at this link:")
print("https://workersandbox.mturk.com/mturk/preview?groupId={}".format(hit_type_id))
print("Your HIT ID is: {}".format(hit_id))
mturk_df = pd.DataFrame([[thread['path'], hit_id]],
columns=['path', 'hit_id'])
df = df.append(mturk_df, ignore_index=True)
df.to_csv('hit.csv')