def get(self): experiments = Experiment.all().filter('second_stage_started = ', None) for experiment in experiments: worker_count = 0 for worker in Worker.all().filter('experiment = ', experiment): if worker.has_labeled_an_image(): worker_count += 1 if worker_count == experiment.cohort_size * experiment.cohort_count: taskqueue.add(queue_name='worker-grouping', params={'key': experiment.key()}) experiment.second_stage_started = datetime.now() experiment.put()
def post(self): experiment = Experiment() for (k, v) in yaml.load(self.request.get('file')).iteritems(): setattr(experiment, k, v) experiment.put() response = mturk.create_hit( experiment, self.host_url('/hit', {'key': experiment.key()})) if response.status is True: experiment.hit_id = response[0].HITId experiment.put() self.reply(201, 'Created HIT: ' + experiment.hit_id) else: self.reply(500, 'Bad Mechanical Turk response: ' + repr(response))
def post(self): experiment = Experiment() for (k, v) in yaml.load(self.request.get('file')).iteritems(): setattr(experiment, k, v) experiment.put() response = mturk.create_hit(experiment, self.host_url('/hit', {'key': experiment.key()})) if response.status is True: experiment.hit_id = response[0].HITId experiment.put() self.reply(201, 'Created HIT: ' + experiment.hit_id) else: self.reply(500, 'Bad Mechanical Turk response: ' + repr(response))