|
@@ -626,36 +626,38 @@ def video_new_rank2(data, size, top_K, flow_pool_P, ab_code, exp_config=None):
|
|
|
pre_str = "k_p7:"
|
|
|
#print("pre_str:", pre_str)
|
|
|
recall_list = []
|
|
|
+ rov_recall_rank = data['rov_pool_recall']
|
|
|
#call rank service
|
|
|
- # if ab_code == 60066:
|
|
|
- # get_featurs()
|
|
|
- #
|
|
|
- # else:
|
|
|
- redisObj = RedisHelper()
|
|
|
- vidKeys = []
|
|
|
- for recall_item in data['rov_pool_recall']:
|
|
|
- if len(recall_item) <= 0:
|
|
|
- continue
|
|
|
- vid = recall_item.get("videoId", 0)
|
|
|
- vidKeys.append(pre_str + str(vid))
|
|
|
- recall_list.append(recall_item)
|
|
|
- # print("vidKeys:", vidKeys)
|
|
|
- video_scores = redisObj.get_batch_key(vidKeys)
|
|
|
- # print("video_score:",video_scores)
|
|
|
- for i in range(len(video_scores)):
|
|
|
- try:
|
|
|
- # print(video_scores[i])
|
|
|
- if video_scores[i] is None:
|
|
|
- recall_list[i]['sort_score'] = 0.0
|
|
|
- else:
|
|
|
- video_score_str = json.loads(video_scores[i])
|
|
|
- # print("video_score_str:", video_score_str)
|
|
|
- recall_list[i]['sort_score'] = video_score_str[0]
|
|
|
- except Exception:
|
|
|
- recall_list[i]['sort_score'] = 0.0
|
|
|
- #sort_items = sorted(video_items, key=lambda k: k[1], reverse=True)
|
|
|
- rov_recall_rank =sorted(recall_list, key=lambda k: k.get('sort_score', 0), reverse=True)
|
|
|
- #print(rov_recall_rank)
|
|
|
+ if ab_code == 60066:
|
|
|
+ feature_dict, recall_list = get_featurs(data, size, top_K, flow_pool_P)
|
|
|
+ score_result = get_tf_serving_sores(feature_dict)
|
|
|
+ if score_result and len(score_result) > 0 and len(score_result) == len(recall_list):
|
|
|
+ for i in range(len(score_result)):
|
|
|
+ recall_list[i]['sort_score'] = score_result[i]
|
|
|
+ rov_recall_rank = sorted(recall_list, key=lambda k: k.get('sort_score', 0), reverse=True)
|
|
|
+ else:
|
|
|
+ redisObj = RedisHelper()
|
|
|
+ vidKeys = []
|
|
|
+ for recall_item in data['rov_pool_recall']:
|
|
|
+ if len(recall_item) <= 0:
|
|
|
+ continue
|
|
|
+ vid = recall_item.get("videoId", 0)
|
|
|
+ vidKeys.append(pre_str + str(vid))
|
|
|
+ recall_list.append(recall_item)
|
|
|
+ video_scores = redisObj.get_batch_key(vidKeys)
|
|
|
+ if video_scores and len(recall_list) > 0:
|
|
|
+ for i in range(len(video_scores)):
|
|
|
+ try:
|
|
|
+ if video_scores[i] is None:
|
|
|
+ recall_list[i]['sort_score'] = 0.0
|
|
|
+ else:
|
|
|
+ video_score_str = json.loads(video_scores[i])
|
|
|
+ # print("video_score_str:", video_score_str)
|
|
|
+ recall_list[i]['sort_score'] = video_score_str[0]
|
|
|
+ except Exception:
|
|
|
+ recall_list[i]['sort_score'] = 0.0
|
|
|
+ rov_recall_rank = sorted(recall_list, key=lambda k: k.get('sort_score', 0), reverse=True)
|
|
|
+ print(rov_recall_rank)
|
|
|
flow_recall_rank = sorted(data['flow_pool_recall'], key=lambda k: k.get('rovScore', 0), reverse=True)
|
|
|
rov_recall_rank, flow_recall_rank = remove_duplicate(rov_recall=rov_recall_rank, flow_recall=flow_recall_rank,
|
|
|
top_K=top_K)
|