ruby rTurk无法从Amazon Mechanical Turk获取结果

mcdcgff0  于 2023-03-17  发布在  Ruby
关注(0)|答案(1)|浏览(129)

我遇到了一个非常奇怪的问题。我能够正确地向Amazon Mechanical Turk提交一个HIT。我有一个cron,它不断检查是否有任何作业准备好进行审查。然而,当一个作业完成时,我没有收到它,而是处理了HIT(在函数内部进行了什么来审查它)。奇怪的是,这个问题并不总是发生,而是经常发生。
这是用于审查HIT的函数代码:

def self.review_hits
hits = RTurk::Hit.all_reviewable
p "HITS"
p hits
puts "REVIEWABLE HITS: " + hits.count.to_s
hits_results = {}

unless hits.empty?
  hits.each do |hit|
    puts "IN EACH HIT"
    p hit
    results = []
    hit.expire!

    # Get results for each HIT assignment
    hit.assignments.each do |assignment|
      # Check if the assignmment has been submitted. It can be the case where the maximum waiting time
      # for the job to finish expired and there remain assignments that are not submitted
      if assignment.status == 'Submitted'
        p "STATUS 1"
        p assignment.status
        temp = {}
        temp[:worker_id] = assignment.worker_id
        temp[:answer] = assignment.answers
        p "STATUS 2"
        p assignment.status
        assignment.approve!
        results << temp
      end
    end

    begin
      hit.dispose!
    rescue
    end

    hits_results[hit.id] = {}
    hits_results[hit.id][:results] = results
  end

  # Let Rails know that there are new results
  AmazonTurkHit.store_results(hits_results) 
end

结束
所以puts“revisiewable HITS:“是0,但是HIT被处理了。有人知道为什么吗?

zzwlnbp8

zzwlnbp81#

经过一段时间的疯狂之后,我意识到这个问题非常愚蠢...我有两个系统示例正在运行,一个在生产中,一个在暂存中,但都使用相同的AWS帐户,所以有时HIT被其他系统捕获...:)

相关问题