Commit aeec2f94 by BoxuanXu

Edit Wrong code

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