我是MTurk的新手,我正尝试使用python创建HIT。 我已成功连接到沙箱(通过成功打印我的帐户余额)。 我现在正在尝试创建HIT并收到请求错误。我想知道我错过了什么。
import boto3
region_name = 'us-east-1'
aws_access_key_id = 'MYID'
aws_secret_access_key = 'MYSECRETKEY'
endpoint_url = 'https://mturk-requester-sandbox.us-east-1.amazonaws.com'
# Uncomment this line to use in production
# endpoint_url = 'https://mturk-requester.us-east-1.amazonaws.com'
create_hits_in_live = False
environments = {
"live": {
"endpoint": "https://mturk-requester.us-east-1.amazonaws.com",
"preview": "https://www.mturk.com/mturk/preview",
"manage": "https://requester.mturk.com/mturk/manageHITs",
"reward": "0.00"
},
"sandbox": {
"endpoint": "https://mturk-requester-sandbox.us-east-1.amazonaws.com",
"preview": "https://workersandbox.mturk.com/mturk/preview",
"manage": "https://requestersandbox.mturk.com/mturk/manageHITs",
"reward": "0.11"
},
}
mturk_environment = environments["live"] if create_hits_in_live else environments["sandbox"]
session = boto3.Session()
client = boto3.client(
'mturk',
endpoint_url=endpoint_url,
region_name=region_name,
aws_access_key_id=aws_access_key_id,
aws_secret_access_key=aws_secret_access_key,
)
# This will return $10,000.00 in the MTurk Developer Sandbox
print(client.get_account_balance()['AvailableBalance'])
question_sample = open("q.xml", "r").read()
worker_requirements = [{
'QualificationTypeId': '000000000000000000L0',
'Comparator': 'GreaterThanOrEqualTo',
'IntegerValues': [80],
'RequiredToPreview': True,
}]
response = client.create_hit(
MaxAssignments=3,
LifetimeInSeconds=604800,
AssignmentDurationInSeconds=600,
Reward=mturk_environment['reward'],
Title='title',
Keywords='question, answer, research',
Description='description.',
Question=question_sample,
QualificationRequirements=worker_requirements
)
引发的错误:
botocore.errorfactory.RequestError: An error occurred (RequestError) when
calling the CreateHIT operation: Please log in to the appropriate MTurk UI
and complete registration. (1539419496875 s)
答案 0 :(得分:0)
当您的Mechanical Turk未正确链接到您的AWS账户时,可能会发生这种情况。您是否已完成Getting Started Guide中的链接步骤?请注意,您需要分别链接沙盒和生产,购买登录到每个站点并进行链接的步骤。还有一个blog post discussing these steps。