Я пытаюсь настроить уведомления SQS для MTURK HIT, созданного с помощью Boto. Я могу создать тип HIT, создать HIT с этим типом, создать очередь SQS и записать и прочитать из очереди. Я также написал команду, которая (я думал) установила уведомления для данного типа HIT. Но никаких уведомлений не отправляется.Использование Boto для отправки уведомлений SQS для MTurk hit
Любая идея, что происходит?
print "Debugging..."
import boto
import boto.sqs
from boto.mturk.connection import MTurkConnection
from boto.mturk.question import QuestionContent, Question, QuestionForm, \
Overview, AnswerSpecification, SelectionAnswer, FormattedContent, \
FreeTextAnswer
import uuid
ACCESS_ID = 'REDACTED'
SECRET_KEY = 'REDACTED'
HOST = 'mechanicalturk.sandbox.amazonaws.com'
mtc = MTurkConnection(aws_access_key_id=ACCESS_ID,
aws_secret_access_key=SECRET_KEY,
host=HOST)
print mtc.get_account_balance()
# --------------- DESIGN THE HIT -------------------
title = 'Give your opinion about a website ' + str(uuid.uuid4())
print title
description = ('Visit a website and give us your opinion about'
' the design and also some personal comments')
keywords = 'website, rating, opinions'
ratings = [
('Very Bad', '-2'),
('Bad', '-1'),
('Not bad', '0'),
('Good', '1'),
('Very Good', '1')
]
# --------------- BUILD OVERVIEW -------------------
overview = Overview()
overview.append_field('Title', 'Give your opinion on this website')
overview.append(FormattedContent('hello'))
qc1 = QuestionContent()
qc1.append_field('Title', 'Your personal comments')
fta2 = FreeTextAnswer()
q = Question(identifier="comments",
content=qc1,
answer_spec=AnswerSpecification(fta2))
# --------------- BUILD THE QUESTION FORM -------------------
question_form = QuestionForm()
question_form.append(overview)
question_form.append(q)
# --------------- CREATE THE HIT -------------------
hit_type = mtc.register_hit_type(
title,
description,
0.05,
60*5,
keywords=keywords,
approval_delay=None,
qual_req=None)[0]
print hit_type.HITTypeId
hit = mtc.create_hit(
hit_type=hit_type.HITTypeId,
questions=question_form,
max_assignments=1,
title=title,
description=description,
keywords=keywords,
duration=60*5,
reward=0.05)[0]
print hit
print dir(hit)
print hit.HITTypeId
sqs_connection = boto.sqs.connect_to_region(
"us-west-2",
aws_access_key_id=ACCESS_ID,
aws_secret_access_key=SECRET_KEY)
# Set up Amazon Simple Queue Service.
queue_name = "wallace_queue"
queue = sqs_connection.create_queue(queue_name)
sqs_connection.add_permission(
queue,
"MTurkSendMessage",
"755651556756",
"SendMessage")
m = boto.sqs.message.Message()
m.set_body("hello world.")
queue.write(m)
rs = queue.get_messages()
for m in rs:
msg = m.get_body()
print "got message:"
print msg
assert msg == "hello world."
# set up queue notifications
qrl = "https://sqs.us-west-2.amazonaws.com/134127175127/" + queue_name
all_event_types = [
"AssignmentAccepted",
"AssignmentAbandoned",
"AssignmentReturned",
"AssignmentSubmitted",
"HITReviewable",
"HITExpired",
]
mtc.set_sqs_notification(
hit.HITTypeId, qrl, event_types=all_event_types)
print "Done."