コード例 #1
0
    def __http_score__update__(self, subjects_to_update=None):
        """
        after we have updated the scores, return them to panoptes using the http api
        the alternative might be to upload to s3 or email someone the results
        :param subjects_to_update: if there are a certain select number of subjects you want to update
        so specifically, you used a heuristic to select which subjects to update and only want to send
        those back. Basically if you selected heuristic for update and after sending everything back, that is
        kinda silly - hence the assert
        :return:
        """
        assert (self.update_type == "complete") or (subjects_to_update
                                                    is not None)

        for subject_id, aggregation in self.aggregator.__list_aggregations__(
                subjects_to_update):
            # try creating the aggregation
            status, explanation = panoptesPythonAPI.create_aggregation(
                self.workflow_id, subject_id, self.token, aggregation)

            # if we had a problem, try updating the aggregation
            if status == 400:
                aggregation_id, etag = panoptesPythonAPI.find_aggregation_etag(
                    self.workflow_id, subject_id, self.token)
                panoptesPythonAPI.update_aggregation(
                    self.workflow_id, self.workflow_version, subject_id,
                    aggregation_id, self.token, aggregation, etag)
コード例 #2
0
ファイル: aggregation.py プロジェクト: JiaminXuan/aggregation
def aggregate(scores):
    # now do the aggregation
    for (workflow_id,subject_id),values in scores.items():
        # calculate the average score, std and set up the JSON results
        avg_score = (values[0]*-1+ + values[1]*1 + values[2]*3)/float(sum(values))
        std = math.sqrt((-1-avg_score)**2*(values[0]/float(sum(values))) + (1-avg_score)**2*(values[1]/float(sum(values))) + (3-avg_score)**2*(values[1]/float(sum(values))))
        aggregation = {"mean":avg_score,"std":std,"count":values}

        # try creating the aggregation
        status,explanation = panoptesPythonAPI.create_aggregation(workflow_id,subject_id,token,aggregation)

        # if we had a problem, try updating the aggregation
        if status == 400:
            aggregation_id,etag = panoptesPythonAPI.find_aggregation_etag(workflow_id,subject_id,token)
            panoptesPythonAPI.update_aggregation(workflow_id,workflow_version,subject_id,aggregation_id,token,aggregation,etag)
コード例 #3
0
    def __http_score__update__(self,subjects_to_update=None):
        """
        after we have updated the scores, return them to panoptes using the http api
        the alternative might be to upload to s3 or email someone the results
        :param subjects_to_update: if there are a certain select number of subjects you want to update
        so specifically, you used a heuristic to select which subjects to update and only want to send
        those back. Basically if you selected heuristic for update and after sending everything back, that is
        kinda silly - hence the assert
        :return:
        """
        assert (self.update_type == "complete") or (subjects_to_update is not None)

        for subject_id,aggregation in self.aggregator.__list_aggregations__(subjects_to_update):
            # try creating the aggregation
            status,explanation = panoptesPythonAPI.create_aggregation(self.workflow_id,subject_id,self.token,aggregation)

            # if we had a problem, try updating the aggregation
            if status == 400:
                aggregation_id,etag = panoptesPythonAPI.find_aggregation_etag(self.workflow_id,subject_id,self.token)
                panoptesPythonAPI.update_aggregation(self.workflow_id,self.workflow_version,subject_id,aggregation_id,self.token,aggregation,etag)