Commit aeec2f94 by BoxuanXu

Edit Wrong code

1 parent 7bac27b1
Showing with 29 additions and 22 deletions
......@@ -57,8 +57,8 @@ def get_path_from_db(modelid,seetanet_model):
if len(result_atlas) != 1:
logging('get wrong mxnet model path');
#return
logging.info('get wrong mxnet model path')
return None,None
else:
path_name = str(result_atlas[0])
path_list = path_name.split("::")
......@@ -95,14 +95,13 @@ def get_path_from_db(modelid,seetanet_model):
#download file from fastdfs
if(stbf_down(graph_name_path,download_path)):
logging.info("download params file: %s success" % graph_name)
else:
return None,None
#Driver converter model by params and model graph
#Run_Converter(params_name,graph_name,seetanet_model)
Run_Converter("model-0015.params","model-symbol.json",seetanet_model)
Run_Converter(params_name,graph_name,seetanet_model)
#Run_Converter("model-0015.params","model-symbol.json",seetanet_model)
return params_name,graph_name
......@@ -124,10 +123,13 @@ def get_info_from_queue(arg):
logging.info("Begin Convert Info is : modelid = %s, output_layer = %s ,Post_Host = %s" % (Info["modelid"],Info["output_layer"],Info["post_url"]))
return_flag = "FALSE"
post_url = "http://127.0.0.1"
try:
modelid = Info["modelid"]
output_layer = Info["output_layer"]
Post_Host = Info["post_url"]
post_url = Info["post_url"]
seetanet_model = "model_" + str(modelid) + ".data"
......@@ -139,9 +141,10 @@ def get_info_from_queue(arg):
else:
stmodel_fid = upload_filetoFastDFS(params_name, graph_name,seetanet_model)
stmodel_fid = "fidtest.data"
if stmodel_fid is None:
logging.info("upload filed")
return_flag = "false"
return_flag = "FALSE"
else:
#remove params file and graph file
......@@ -152,7 +155,7 @@ def get_info_from_queue(arg):
except subprocess.CalledProcessError as err:
logging.info("shell command error!")
return_flag = "false"
return_flag = "FALSE"
logging.info("convert successfully!")
......@@ -162,44 +165,48 @@ def get_info_from_queue(arg):
job = J['SeetaNetLite-pro']
params = "{\'MODEL_ID\': \'" + modelid + "\',\'OUTPUT_LAYER\':\'" + output_layer + "\',\'STMODEL_FID\':\'" + stmodel_fid + "\'}"
#convert string to dict
params = eval(params)
job.invoke(block=True,build_params=params)
params = { "MODEL_ID": modelid, "OUTPUT_LAYER" : output_layer,"STMODEL_FID" : stmodel_fid}
return_flag = "true"
r = job.invoke(block=True, build_params=params)
b = r.get_build()
logging.info('Finish JenkIn,build #: {} ,status : {}'.format(b.get_number(),b.get_status()))
if b.get_status() == "SUCCESS":
return_flag = "SUCCESS"
else:
return_flag = "FALSE"
finally:
#curl_atlas_exe.close()
#curl_atlas.close()
#db_atlas.close()
logging('return %s',return_flag)
post_return = { "modelid": modelid, "return_flag" : return_flag }
requests.post(post_url, data=post_return)
t = threading.Thread(target=get_info_from_queue,args=(1,))
#get parameters and driver the transition function
@app.route('/convert',methods=['POST'])
def Dirver_Convert():
#get parameter modelid from post stream
return_flag = "queue"
print("haha")
try:
modelid=request.form['modelid']
output_layer=request.form['output_layer']
post_url=request.form['post_url']
logging.info("New Post Connect: modelid : %s , post_url : %s, Queue size : %d" % (modelid,post_url,Info_Queue.qsize()))
logging.info("New Post Connect: modelid : %s , post_url : %s, Queue size : %d" % (modelid,post_url,(Info_Queue.qsize() + 1)))
Post_Info = { "modelid": modelid, "output_layer" : output_layer,"post_url" : post_url}
Info_Queue.put(Post_Info)
if t.is_alive():
t.stop()
t = threading.Thread(target=get_info_from_queue,args=(1,))
t.start()
finally:
return return_flag
if __name__ == '__main__':
try:
t = threading.Thread(target=get_info_from_queue,args=(1,))
t.start();
app.run(host='0.0.0.0')
finally:
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!