Skip to content

Commit

Permalink
added transaction atomic for merge process
Browse files Browse the repository at this point in the history
  • Loading branch information
abdollahis2 authored and abdollahis2 committed Dec 7, 2023
1 parent a4db998 commit 9389b13
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions tr_sys/tr_ars/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
}

NORMALIZER_URL=os.getenv("TR_NORMALIZER") if os.getenv("TR_NORMALIZER") is not None else "https://nodenormalization-sri.renci.org/1.4/get_normalized_nodes"
ANNOTATOR_URL=os.getenv("TR_ANNOTATOR") if os.getenv("TR_ANNOTATOR") is not None else "https://biothings.ci.transltr.io/annotator/"
#ANNOTATOR_URL=os.getenv("TR_ANNOTATOR") if os.getenv("TR_ANNOTATOR") is not None else "https://biothings.ci.transltr.io/annotator/"
ANNOTATOR_URL=os.getenv("TR_ANNOTATOR") if os.getenv("TR_ANNOTATOR") is not None else "https://biothings.ncats.io/annotator/"
APPRAISER_URL=os.getenv("TR_APPRAISE") if os.getenv("TR_APPRAISE") is not None else "http://localhost:9096/get_appraisal"


Expand Down Expand Up @@ -606,11 +607,10 @@ def merge_and_post_process(parent_pk,message_to_merge, agent_name):
parent = Message.objects.select_for_update().get(pk=parent_pk)
merged = merge_received(parent,message_to_merge, agent_name)
if merged is not None:
json_merged = json.dumps(merged.data, indent=4)
with open(str(parent_pk)+'_'+agent_name+"_merged.json", "w") as outfile:
outfile.write(json_merged)
logging.info('merged data for agent %s with pk %s is returned & ready to be preprocessed' % (agent_name, str(merged.id)))
post_process(merged.data,merged.id, agent_name)
parent.code = 200
parent.status = 'D'
parent.save()
transaction.commit()
except Exception as e:
Expand Down Expand Up @@ -734,8 +734,8 @@ def annotate_nodes(mesg,data,agent_name):
json_data = json.dumps(nodes_message)
try:
logging.info('posting data to the annotator URL %s' % ANNOTATOR_URL)
with open(str(mesg.pk)+'_'+agent_name+"_KG_nodes_annotator.json", "w") as outfile:
outfile.write(json_data)
# with open(str(mesg.pk)+'_'+agent_name+"_KG_nodes_annotator.json", "w") as outfile:
# outfile.write(json_data)
r = requests.post(ANNOTATOR_URL,data=json_data,headers=headers)
r.raise_for_status()
rj=r.json()
Expand Down

0 comments on commit 9389b13

Please sign in to comment.