Commit 6ff78a67 authored by 张彦钊's avatar 张彦钊

add prints for test

parent 524b17b0
......@@ -91,9 +91,7 @@ def feature_en(x_list, device_id):
def transform_ffm_format(df,queue_name):
with open(DIRECTORY_PATH + "ffm.pkl", "rb") as f:
ffm_format_pandas = pickle.load(f)
print("1")
data = ffm_format_pandas.transform(df)
predict_file_name = DIRECTORY_PATH + "result/{0}_{1}.csv".format(device_id, queue_name)
data.to_csv(predict_file_name, index=False, header=None)
print("done ffm")
......@@ -111,8 +109,9 @@ def predict(queue_name, x_list):
ffm_model.predict(DIRECTORY_PATH + "model.out",
DIRECTORY_PATH + "result/output{0}_{1}.csv".format(device_id,queue_name))
save_result(queue_name, x_list)
print("done predict")
save_result(queue_name, x_list)
def save_result(queue_name, x_list):
......@@ -126,6 +125,7 @@ def save_result(queue_name, x_list):
def merge_score(x_list, score_df):
db = pymysql.connect(host='10.66.157.22', port=4000, user='root',passwd='3SYz54LS9#^9sBvC', db='eagle')
cursor = db.cursor()
print("连接蔡成功")
score_list = []
# 去除diary_id 前面的"diary|"
x_list = list(map(lambda x:x[6:],x_list))
......@@ -136,13 +136,16 @@ def merge_score(x_list, score_df):
if cursor.execute(sql) != 0:
result = cursor.fetchone()[0]
score_list.append(result)
print("成功获取")
# 没有查到这个diary_id,默认score值是0
else:
print("结果是空")
score_list.append(0)
db.close()
score_df["score"] = score_df["score"] + score_list
print("done merge")
update_dairy_queue(score_df)
......@@ -170,17 +173,20 @@ def update_dairy_queue(score_df):
else:
score_df = score_df.sort_values(by="score", ascending=False)
return score_df["cid"].values.tolist()
print("排序成功")
def update_sql_dairy_queue(queue_name, diary_id):
db = pymysql.connect(host='rm-m5e842126ng59jrv6.mysql.rds.aliyuncs.com', port=3306, user='doris',
passwd='o5gbA27hXHHm', db='doris_prod')
cursor = db.cursor()
print("写入连接成功")
## 去除diary_id 前面的"diary|"
diary_id = list(map(lambda x:x[6:],diary_id))
sql = "update device_diary_queue set {}='{}' where device_id = '{}'".format(queue_name, diary_id, device_id)
cursor.execute(sql)
db.close()
print("成功写入")
def multi_update(key, name_dict):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment