Commit f7f58d41 authored by 赵威's avatar 赵威

add exception checking

parent 763159f7
...@@ -8,13 +8,17 @@ from utils.cache import get_essm_model_save_path, redis_client4 ...@@ -8,13 +8,17 @@ from utils.cache import get_essm_model_save_path, redis_client4
def predict_with_city_changed(device_dict, diary_dict, tractate_dict, diary_predict_fn, tractate_predict_fn): def predict_with_city_changed(device_dict, diary_dict, tractate_dict, diary_predict_fn, tractate_predict_fn):
key = "doris:user_portrait:city_changed:device:queue" key = "doris:user_portrait:city_changed:device:queue"
total = redis_client4.llen(key) try:
while (total > 0): total = redis_client4.llen(key)
device_id = redis_client4.lpop(key) while (total > 0):
device_id = str(device_id, "utf-8") device_id = redis_client4.lpop(key)
offline_predict_diary(device_id, device_dict, diary_dict, diary_predict_fn) device_id = str(device_id, "utf-8")
offline_predict_tractate(device_id, device_dict, tractate_dict, tractate_predict_fn) print(device_id)
print("=========================================\n") offline_predict_diary(device_id, device_dict, diary_dict, diary_predict_fn)
offline_predict_tractate(device_id, device_dict, tractate_dict, tractate_predict_fn)
print("=========================================\n")
except Exception as e:
print(e)
if __name__ == "__main__": if __name__ == "__main__":
...@@ -36,4 +40,5 @@ if __name__ == "__main__": ...@@ -36,4 +40,5 @@ if __name__ == "__main__":
tractate_save_path = "/home/gmuser/data/models/tractate/1596509299" tractate_save_path = "/home/gmuser/data/models/tractate/1596509299"
print(tractate_save_path + "!!!!!!!!!!!!!!!!!!!!!!!!!!!") print(tractate_save_path + "!!!!!!!!!!!!!!!!!!!!!!!!!!!")
tractate_predict_fn = tf.contrib.predictor.from_saved_model(tractate_save_path) tractate_predict_fn = tf.contrib.predictor.from_saved_model(tractate_save_path)
predict_with_city_changed(device_dict, diary_dict, tractate_dict, diary_predict_fn, tractate_predict_fn) predict_with_city_changed(device_dict, diary_dict, tractate_dict, diary_predict_fn, tractate_predict_fn)
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