【问题标题】:Creating mTurk HIT from Layout with parameters using boto and python使用 boto 和 python 从 Layout 中创建 mTurk HIT
【发布时间】:2015-05-26 00:07:57
【问题描述】:

我正在尝试利用 boto 在土耳其机械人中产生 HIT。目标是使用已经在我的 mTurk 帐户上生成的通用布局,并将图像的 url 传递给它以迭代地创建 HIT。

问题在于,即使正确命名了参数 if 对于图像 url,boto 也不成功。我创建命中的示例代码是:

from boto.mturk.connection import MTurkConnection
from boto.s3.connection import S3Connection
from boto.mturk.layoutparam import LayoutParameter
from boto.s3.key import Key
import datetime

mtc = MTurkConnection(aws_access_key_id=AWSKEY,
                  aws_secret_access_key=AWSSKEY,
                  host=HOST)

#Define the layout ID to use and url to the image being used (bucket and serial defined in another place
LAYOUTID = '30W9SLHWRYCURO27D44916CUTGKDS2'
S3URL = LayoutParameter('image_url','https://s3.amazonaws.com/'+BUCKET_NAME+'/'+SERIAL)
REWARD = 0.05

#Call create_hit to generate the HIT
hit_result = mtc.create_hit(hit_layout=LAYOUTID,layout_params=S3URL,  keywords=keywords_list, reward=REWARD,
                            duration=datetime.timedelta(7),max_assignments=1)

这会产生错误 您的请求缺少必需的参数。必需的参数包括 HITLayoutParameter。您尚未提供所有必需的 HITLayout 参数。缺少参数名称:image_url

为了确保我的布局 ID 具有正确的参数名称,当我检查 mTurk 时,我看到了(无法发布屏幕截图):

布局 ID: 30W9SLHWRYCURO27D44916CUTGKDS2 参数: 图片网址

使用 LayoutParameter 有什么技巧吗?还是我以错误的方式使用 create_hit?

【问题讨论】:

    标签: python python-2.7 boto mechanicalturk


    【解决方案1】:

    您好,我知道现在回答有点晚了,但这是您需要做的。将布局参数放入 LayoutParameter 类后,将其打包到 LayoutParameters 类中。 例如。

    ......
    from boto.mturk.layoutparam import LayoutParameter
    from boto.mturk.layoutparam import LayoutParameters
    ........
    
    S3URL = LayoutParameter('image_url','https://s3.amazonaws.com/'+BUCKET_NAME+'/'+SERIAL)
    
    # put the layout parameter in a list/tuple and pass it to LayoutParameters
    params = LayoutParameters([S3URL])
    
    hit_result = mtc.create_hit(hit_layout=LAYOUTID,layout_params=params,  keywords=keywords_list, reward=REWARD,
                                duration=datetime.timedelta(7),max_assignments=1)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多