Skip to content

Commit

Permalink
Merge pull request #524 from NCATSTranslator/NoneType_Error
Browse files Browse the repository at this point in the history
None type error
  • Loading branch information
ShervinAbd92 authored Nov 8, 2023
2 parents db52552 + d250607 commit 8d2d0b8
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions tr_sys/tr_ars/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,14 +286,11 @@ def mergeMessagesRecursive(mergedMessage,messageList,pk):
if len(messageList)==0:
try:
results = mergedMessage.getResults()
logging.info('the type of results for mergedMessage.getResults class %s' % (type(results)))
if results is not None:
logging.info(f'Averaing normalized scores for {pk}')
try:
results = results.getRaw()
logging.info('the type of results for results.getRaw class %s' % (type(results)))
for result in results:
logging.info('result.keys are: %s' % (result.keys()))
if "normalized_score" in result.keys():
ns = result["normalized_score"]
if isinstance(ns,list) and len(ns)>0:
Expand Down Expand Up @@ -606,8 +603,8 @@ def merge_and_post_process(parent_pk,message_to_merge, agent_name):
merged = merge_received(parent_pk,message_to_merge, agent_name)
post_process(merged.data,merged.id, agent_name)
except Exception as e:
logging.debug("Problem with merger or post processing for agent %s pk: %s " % (agent_name, (parent_pk)))
logging.exception("error in merger or post processing")
logging.info("Problem with merger or post processing for agent %s pk: %s " % (agent_name, (parent_pk)))
merged.status='E'
merged.code = 422
merged.save()
Expand Down Expand Up @@ -1181,6 +1178,7 @@ def merge_received(parent_pk,message_to_merge, agent_name, counter=0):


merged_dict = merged.to_dict()
logging.info('the keys for merged_dict are %s' % merged_dict.keys())
new_merged_message.data=merged_dict
new_merged_message.status='R'
new_merged_message.code=202
Expand All @@ -1200,8 +1198,8 @@ def merge_received(parent_pk,message_to_merge, agent_name, counter=0):
parent.save()
return new_merged_message
except Exception as e:
logging.exception("problem with merging for %s :" % agent_name)
raise e
logging.exception("problem with merging for %s :" % agent_name)
#If anything goes wrong, we at least need to unlock the semaphore
#TODO make some actual proper Exception handling here.
parent.merge_semaphore=False
Expand Down

0 comments on commit 8d2d0b8

Please sign in to comment.