Skip to content

Commit

Permalink
added some more logging
Browse files Browse the repository at this point in the history
  • Loading branch information
abdollahis2 authored and abdollahis2 committed Nov 9, 2023
1 parent 8846834 commit a577df8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
4 changes: 2 additions & 2 deletions tr_sys/tr_ars/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,10 +440,10 @@ def message(req, key):
mesg.code = code
mesg.data = data
mesg.save()
logger.info("pre async call for agent %s" % agent_name)
if agent_name.startswith('ara-'):
logger.info("pre async call for agent %s" % agent_name)
utils.merge_and_post_process.apply_async((parent_pk,message_to_merge['message'],agent_name))
logger.info("post async call for agent %s" % agent_name)
logger.info("post async call for agent %s" % agent_name)


# create child message if this one already has results
Expand Down
4 changes: 2 additions & 2 deletions tr_sys/tr_ars/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,15 +162,15 @@ def send_message(actor_dict, mesg_dict, timeout=300):

agent_name = str(mesg.actor.agent.name)
if mesg.code == 200 and results is not None and len(results)>0:
logger.info("pre async call for agent %s" % agent_name)
if agent_name.startswith('ara-'):
logger.info("pre async call for agent %s" % agent_name)
# logging.debug("Merge starting for "+str(mesg.pk))
# new_merged = utils.merge_received(parent_pk,message_to_merge['message'], agent_name)
# logging.debug("Merge complete for "+str(new_merged.pk))
# utils.post_process(new_merged.data,new_merged.pk, agent_name)
# logging.debug("Post processing done for "+str(new_merged.pk))
utils.merge_and_post_process.apply_async((parent_pk,message_to_merge['message'],agent_name))
logger.info("post async call for agent %s" % agent_name)
logger.info("post async call for agent %s" % agent_name)
else:
logging.debug("Skipping merge and post for "+str(mesg.pk)+
" because the contributing message is in state: "+str(mesg.code))
Expand Down
9 changes: 4 additions & 5 deletions tr_sys/tr_ars/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,8 @@ def mergeMessages(messageList,pk):

def mergeMessagesRecursive(mergedMessage,messageList,pk):
#need to clean things up and average our normalized scores now that they're all in
logging.info(f'Merging : {pk} recursively. Currently {str(len(messageList))} messages left in the queue')
logging.info(f'Merging new pk: {pk} recursively. Currently {str(len(messageList))} messages left in the queue')
logging.info(f'Current messages list in the queue: {messageList}')
if len(messageList)==0:
try:
results = mergedMessage.getResults()
Expand All @@ -295,8 +296,6 @@ def mergeMessagesRecursive(mergedMessage,messageList,pk):
ns = result["normalized_score"]
if isinstance(ns,list) and len(ns)>0:
result["normalized_score"]= sum(ns) / len(ns)
else:
logging.info("ns type is: %s" % type(ns))
else:
logging.info('there is no normalized_score in result.keys()')
except Exception as e:
Expand Down Expand Up @@ -1147,7 +1146,7 @@ def merge(pk,merged_pk):
def merge_received(parent_pk,message_to_merge, agent_name, counter=0):
parent = Message.objects.get(pk=parent_pk)
current_merged_pk=parent.merged_version_id
logging.info("Beginning merge for agent %s with pk: %s" %(agent_name,str(current_merged_pk)))
logging.info("Beginning merge for agent %s with current_pk: %s" %(agent_name,str(current_merged_pk)))
#to_merge_message= Message.objects.get(pk=pk_to_merge)
#to_merge_message_dict=get_safe(to_merge_message.to_dict(),"fields","data","message")
t_to_merge_message=TranslatorMessage(message_to_merge)
Expand Down Expand Up @@ -1200,7 +1199,7 @@ def merge_received(parent_pk,message_to_merge, agent_name, counter=0):
else:
parent.merged_versions_list.append(pk_infores_merge)
parent.save()
logging.info("returning new_merged_message to be post processed")
logging.info("returning new_merged_message to be post processed with pk: %s" % str(new_merged_message.pk))
return new_merged_message
except Exception as e:
logging.exception("problem with merging for %s :" % agent_name)
Expand Down

0 comments on commit a577df8

Please sign in to comment.