Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reorder post and time limit #690

Merged
merged 2 commits into from
Sep 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 22 additions & 17 deletions tr_sys/tr_ars/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -577,20 +577,15 @@ def pre_merge_process(data,key, agent_name,inforesid):
def post_process(mesg,key, agent_name):

data = mesg.decompress_dict()
logging.info("Pre node annotation for agent %s pk: %s" % (agent_name, str(key)))

logging.info("pre blocklist for "+str(key))
try:
annotate_nodes(mesg,data,agent_name)
logging.info("node annotation successful for agent %s and pk: %s" % (agent_name, str(key)))
remove_blocked(mesg, data)
except Exception as e:
status='E'
code=444
log_tuple =[
f'node annotation internal error: {str(e)}',
datetime.now().strftime('%H:%M:%S'),
"DEBUG"
]
add_log_entry(data,log_tuple)
logging.exception(f"problem with node annotation for agent: {agent_name} pk: {str(key)}")
logging.info(e.__cause__)
logging.exception(f"Problem with block list removal for agent: {agent_name} pk: {str(key)}")
mesg.status=status
mesg.code=code
mesg.save()
Expand All @@ -612,18 +607,28 @@ def post_process(mesg,key, agent_name):
mesg.status=status
mesg.code=code
mesg.save()
logging.info("pre blocklist for "+str(key))



logging.info("Pre node annotation for agent %s pk: %s" % (agent_name, str(key)))
try:
remove_blocked(mesg, data)
annotate_nodes(mesg,data,agent_name)
logging.info("node annotation successful for agent %s and pk: %s" % (agent_name, str(key)))
except Exception as e:
status='E'
code=444
logging.info(e.__cause__)
logging.exception(f"Problem with block list removal for agent: {agent_name} pk: {str(key)}")
log_tuple =[
f'node annotation internal error: {str(e)}',
datetime.now().strftime('%H:%M:%S'),
"DEBUG"
]
add_log_entry(data,log_tuple)
logging.exception(f"problem with node annotation for agent: {agent_name} pk: {str(key)}")
mesg.status=status
mesg.code=code
mesg.save()


logging.info("pre appraiser for agent %s and pk %s" % (agent_name, str(key)))
try:
appraise(mesg,data,agent_name)
Expand Down Expand Up @@ -671,7 +676,7 @@ def post_process(mesg,key, agent_name):
]
add_log_entry(data,log_tuple)
status ='E'
code=400
code=444
mesg.save_compressed_dict(data)
return mesg, code, status

Expand Down Expand Up @@ -970,13 +975,13 @@ def scrub_null_attributes(data):



def appraise(mesg,data, agent_name,retry_counter=0):
def appraise(mesg, data, agent_name,retry_counter=0):
headers = {'Content-type': 'application/json', 'Accept': 'text/plain'}
json_data = json.dumps(data)
logging.info('sending data for agent: %s to APPRAISER URL: %s' % (agent_name, APPRAISER_URL))
with tracer.start_as_current_span("get_appraisal") as span:
try:
with requests.post(APPRAISER_URL,data=json_data,headers=headers, stream=True) as r:
with requests.post(APPRAISER_URL,data=json_data,headers=headers, stream=True,timeout=600) as r:
logging.info("Appraiser being called at: "+APPRAISER_URL)
logging.info('the response for agent %s to appraiser code is: %s' % (agent_name, r.status_code))
if r.status_code==200:
Expand Down