Commit 1e511264 by BoxuanXu

add code to operate jenkins

1 parent 380acb8d
Showing with 19 additions and 14 deletions
......@@ -10,6 +10,8 @@ from libpywrap import *
from converter import Run_Converter
from flask import Flask,request
from jenkinsapi.jenkins import Jenkins
__website__ = "www.seetatech.com"
__author__ = "seetatech"
__editor__ = "xuboxuan"
......@@ -23,6 +25,9 @@ stbf_stcnf("/etc/fdfs/client.conf")
download_path="."
#be userd to jenkins
host = 'http://192.168.1.242:8080/'
#initlization the logging
logging.basicConfig(
level=logging.INFO,
......@@ -87,7 +92,7 @@ def get_path_from_db(modelid,seetanet_model):
#Driver converter model by params and model graph
Run_Converter(params_name,graph_name,seetanet_model)
#Run_Converter(params_name,graph_name,seetanet_model)
return params_name,graph_name
......@@ -102,22 +107,13 @@ def upload_filetoFastDFS(params_name, graph_name,seetanet_model):
return None
return stmodel_fid
def update_pkg_info_db(modelid,sdk_fid,stmodel_fid):
#update pkg info table
logging.info("begin insert model_id ,sdk_fid,mxnet_modelid into pkg_info table")
sql_cmd = "insert into seetaAtlas.pkg_info (modelid,sdk_fid,stmodel_fid) values(" + str(modelid) +",\'" + sdk_fid + "\',\'" + stmodel_fid + "\')" + " ON DUPLICATE KEY UPDATE sdk_fid=\'" + sdk_fid + "\',stmodel_fid=\'" + stmodel_fid +"\'"
curl_atlas_exe.execute(sql_cmd)
db_atlas.commit()
#get parameters and driver the transition function
@app.route('/',methods=['POST'])
def Dirver_Convert():
#get parameter modelid from post stream
modelid=request.form['modelid']
output_layer=request.form['output_layer']
logging.info("We get modelid :%s from post stream,Start conversion:" % modelid)
try:
......@@ -134,8 +130,6 @@ def Dirver_Convert():
if stmodel_fid is None:
logging.info("upload filed")
else:
sdk_fid = ""
update_pkg_info_db(modelid,sdk_fid,stmodel_fid)
#remove params file and graph file
try:
......@@ -146,8 +140,19 @@ def Dirver_Convert():
logging.info("shell command error!")
return "finish"
logging.info("successfully,Finish!")
logging.info("convert successfully!")
logging.info("Begin Run JenkIn!")
J = Jenkins(host, username='shenyizhong', password='shenyizhong')
job = J['SeetaNetLite-pro']
params = "{\'MODEL_ID\': \'" + modelid + "\',\'OUTPUT_LAYER\':\'" + output_layer + "\',\'STMODEL_FID\':\'" + stmodel_fid + "\'}"
params = eval(params)
job.invoke(block=True,build_params=params)
finally:
curl_atlas_exe.close()
curl_atlas.close()
db_atlas.close()
return "finish"
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!