def update_analysis_results(task): """ Update analysis results for this task. """ # If the task does not currently exist for the given sample in the # database, add it. obj_class = class_from_type(task.obj._meta['crits_type']) obj = obj_class.objects(id=task.obj.id).first() obj_id = obj.id found = False for a in obj.analysis: if str(a.analysis_id) == task.task_id: found = True break if not found: logger.warning("Tried to update a task that didn't exist.") insert_analysis_results(task) else: # Otherwise, update it. ear = EmbeddedAnalysisResult() tdict = task.to_dict() tdict['analysis_id'] = tdict['id'] del tdict['id'] ear.merge(arg_dict=tdict) obj_class.objects(id=obj_id, analysis__id=task.task_id).update_one(set__analysis__S=ear)
def insert_analysis_results(task): """ Insert analysis results for this task. """ obj_class = class_from_type(task.obj._meta['crits_type']) ear = EmbeddedAnalysisResult() tdict = task.to_dict() tdict['analysis_id'] = tdict['id'] del tdict['id'] ear.merge(arg_dict=tdict) obj_class.objects(id=task.obj.id).update_one(push__analysis=ear)
def _insert_analysis_results(self, task): """ Insert analysis results for this task. """ obj_class = class_from_type(task.context.crits_type) query = self.get_db_query(task.context) ear = EmbeddedAnalysisResult() tdict = task.to_dict() tdict['analysis_type'] = tdict['type'] tdict['analysis_id'] = tdict['id'] del tdict['type'] del tdict['id'] ear.merge(arg_dict=tdict) ear.config = AnalysisConfig(**tdict['config']) obj_class.objects(__raw__=query).update_one(push__analysis=ear)
def _update_analysis_results(self, task): """ Update analysis results for this task. """ # If the task does not currently exist for the given sample in the # database, add it. obj_class = class_from_type(task.context.crits_type) query = self.get_db_query(task.context) obj = obj_class.objects(__raw__=query).first() obj_id = obj.id found = False c = 0 for a in obj.analysis: if str(a.analysis_id) == task.task_id: found = True break c += 1 if not found: logger.warning("Tried to update a task that didn't exist.") self._insert_analysis_results(task) else: # Otherwise, update it. ear = EmbeddedAnalysisResult() tdict = task.to_dict() tdict['analysis_type'] = tdict['type'] tdict['analysis_id'] = tdict['id'] del tdict['type'] del tdict['id'] ear.merge(arg_dict=tdict) ear.config = AnalysisConfig(**tdict['config']) obj_class.objects( id=obj_id, analysis__id=task.task_id).update_one(set__analysis__S=ear)
def _update_analysis_results(self, task): """ Update analysis results for this task. """ # If the task does not currently exist for the given sample in the # database, add it. obj_class = class_from_type(task.context.crits_type) query = self.get_db_query(task.context) obj = obj_class.objects(__raw__=query).first() obj_id = obj.id found = False c = 0 for a in obj.analysis: if str(a.analysis_id) == task.task_id: found = True break c += 1 if not found: logger.warning("Tried to update a task that didn't exist.") self._insert_analysis_results(task) else: # Otherwise, update it. ear = EmbeddedAnalysisResult() tdict = task.to_dict() tdict['analysis_type'] = tdict['type'] tdict['analysis_id'] = tdict['id'] del tdict['type'] del tdict['id'] ear.merge(arg_dict=tdict) ear.config = AnalysisConfig(**tdict['config']) obj_class.objects(id=obj_id, analysis__id=task.task_id).update_one(set__analysis__S=ear)