调用CreateHIT操作时出现RequestError
RequestError when calling the CreateHIT operation
我是 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 ,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)
当您的 Mechanical Turk 未正确链接到您的 AWS 账户时,可能会发生这种情况。您是否已完成 Getting Started Guide? Note that you need to link the sandbox and production separately, buy logging into each of those sites and going through the linking steps. There's also a blog post discussing these steps.
中的链接步骤?
我是 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 ,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)
当您的 Mechanical Turk 未正确链接到您的 AWS 账户时,可能会发生这种情况。您是否已完成 Getting Started Guide? Note that you need to link the sandbox and production separately, buy logging into each of those sites and going through the linking steps. There's also a blog post discussing these steps.
中的链接步骤?