-
Notifications
You must be signed in to change notification settings - Fork 3
/
mtk_utils.py
49 lines (29 loc) · 1.24 KB
/
mtk_utils.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
38
39
40
41
42
43
44
45
46
47
48
import sys
import argparse
import re
from numpy import array, random
import utils
import amazon_config
def get_mtc(mtc_type = 'sandbox'):
from boto.mturk.connection import MTurkConnection
from boto.mturk.question import QuestionContent, Question, QuestionForm, Overview, AnswerSpecification, SelectionAnswer, FormattedContent, FreeTextAnswer
from boto.mturk.qualification import PercentAssignmentsApprovedRequirement, Qualifications
ACCESS_ID = amazon_config.ACCESS_ID
SECRET_KEY = amazon_config.SECRET_KEY
HOST = 'mechanicalturk.sandbox.amazonaws.com'
if (mtc_type == 'normal'):
HOST = 'mechanicalturk.amazonaws.com'
mtc = MTurkConnection(aws_access_key_id=ACCESS_ID,
aws_secret_access_key=SECRET_KEY,
host=HOST)
return mtc
def get_workers(mtc_type, hit_id, status):
mtc = get_mtc(mtc_type)
assignments = get_assignments(mtc, hit_id, status)
workers = []
for assignment in assignments:
workers.append(assignment.WorkerId)
return workers
def get_assignments(mtc, arg_hit_id, arg_status):
assignments = mtc.get_assignments(hit_id = arg_hit_id, status = arg_status, page_size = 100, page_number = 1)
return assignments