forked from jcjohnson/simple-amt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_all_hits.py
37 lines (34 loc) · 1.17 KB
/
get_all_hits.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
36
37
import argparse, json
import simpleamt
import sys
"""
Run with --prod to get all the hits from production.
"""
def get_all_reviewable_hits(mtc):
page_size = 50
hits = mtc.get_reviewable_hits(page_size=page_size)
print "Total results to fetch %s " % hits.TotalNumResults
print "Request hits page %i" % 1
total_pages = float(hits.TotalNumResults)/page_size
int_total= int(total_pages)
if(total_pages-int_total>0):
total_pages = int_total+1
else:
total_pages = int_total
pn = 1
while pn < total_pages:
pn = pn + 1
print "Request hits page %i" % pn
temp_hits = mtc.get_reviewable_hits(page_size=page_size,page_number=pn)
hits.extend(temp_hits)
return hits
if __name__ == '__main__':
parser = argparse.ArgumentParser(parents=[simpleamt.get_parent_parser()])
parser.add_argument('--reviewable', action='store_true', default=False)
args = parser.parse_args()
mtc = simpleamt.get_mturk_connection_from_args(args)
hits = get_all_reviewable_hits(mtc) if args.reviewable else mtc.get_all_hits()
hitIds = [h.HITId for h in hits]
print "Got %i hits" % len(hitIds)
for hitId in hitIds:
print hitId