Create a MTurk HIT from an existing template

匆匆过客 提交于 2020-01-01 05:18:06

问题


I'm using the Python AWS package boto v2.7 to interact with the Mturk API to create and manage HIT's etc.

I'm getting stuck when trying to create a HIT using an existing template. Amazon's documentation on the topic is here: http://docs.aws.amazon.com/AWSMechTurk/2012-03-25/AWSMturkAPI/ApiReference_CreateHITOperation.html

My code is:

from boto.mturk.connection import MTurkConnection

mtc = MTurkConnection(aws_access_key_id=ACCESS_ID,
                             aws_secret_access_key=SECRET_KEY,
                             host=HOST)

mtc.create_hit(hit_layout=HIT_LAYOUT_ID)

The error is:

MTurkRequestError: MTurkRequestError: 200 OK
<?xml version="1.0"?>
<CreateHITResponse><OperationRequest><RequestId>986926dd-0263-4aca-970c-139b7ed4a0e8</RequestId></OperationRequest><HIT><Request><IsValid>False</IsValid><Errors><Error><Code>AWS.MechanicalTurk.InvalidParameterValue</Code><Message>There was an error parsing the request (1359492767224 s)</Message></Error></Errors></Request></HIT></CreateHITResponse>

It seems like the MTurk API is expecting an hit layout parameter as detailed here: http://docs.aws.amazon.com/AWSMechTurk/2012-03-25/AWSMturkAPI/ApiReference_HITLayoutArticle.html

While my original template did make use of placeholder values, I deleted them for the sake of simplicity and to just try to get the code working. In this case I'd think that the only parameter required would be the hit_layout?

Is this a limitation on boto's api or am I missing something here?

UPDATE

I tried using the mturkcore module mentioned in the comments with the following results.

Code:

import mturkcore

login_dict = {'use_sandbox':True,
              'stdout_log':False,
              'AWS_ACCESS_KEY_ID':'ACCESS_ID',
              'AWS_SECRET_ACCESS_KEY':'PASSWORD'}

mtc = mturkcore.MechanicalTurk(login_dict)

request_params = {"Title":"Test Layout",
                    "Description":"Test Description",
                    "HITLayoutId":"2QNNJKM05BMJLZIA6G7TS9RA7TECHE",
                    "Reward":0.05,
                    "LifetimeInSeconds":6000,
                    "AssignmentDurationInSeconds":600    
                    }

mtc.create_request("CreateHIT", request_params)

This yields an error msg from suds:

TypeNotFound: Type not found: 'HITLayoutId'

Again, I'm following the instructions here: http://docs.aws.amazon.com/AWSMechTurk/latest/AWSMturkAPI/ApiReference_CreateHITOperation.html which seem fairly straight forward.

SOLUTION I was finally able to create a HIT from an existing template, but only in the production environment. Apparently there are differences between sandbox and production which is probably why I was getting the above error. If anybody has had success with doing this in the sandbox, please chime in!

Additionally, you must ensure that the Reward, LifetimeInSeconds, and AssignmentDurationInSeconds parameters match the layout template you're creating. Finally, to view the HIT you created, you must click on the "Manage HITs Individually" link.

来源:https://stackoverflow.com/questions/14592338/create-a-mturk-hit-from-an-existing-template

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!