|  | @@ -593,7 +593,7 @@ def video_rank_with_old_video(rank_result, old_video_recall, size, top_K, old_vi
 | 
	
		
			
				|  |  |      return new_rank_result[:size]
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -def video_new_rank2(data, size, top_K, flow_pool_P, ab_code, mid, exp_config=None, env_dict=None, rec_recall_item_list=None):
 | 
	
		
			
				|  |  | +def video_new_rank2(data, size, top_K, flow_pool_P, ab_code, mid, exp_config=None, env_dict=None):
 | 
	
		
			
				|  |  |      """
 | 
	
		
			
				|  |  |          视频分发排序
 | 
	
		
			
				|  |  |          :param data: 各路召回的视频 type-dict {'rov_pool_recall': [], 'flow_pool_recall': []}
 | 
	
	
		
			
				|  | @@ -602,14 +602,14 @@ def video_new_rank2(data, size, top_K, flow_pool_P, ab_code, mid, exp_config=Non
 | 
	
		
			
				|  |  |          :param flow_pool_P: size-top_K视频为流量池视频的概率 type-float
 | 
	
		
			
				|  |  |          :return: rank_result
 | 
	
		
			
				|  |  |          """
 | 
	
		
			
				|  |  | -    if not rec_recall_item_list and not data['flow_pool_recall']:
 | 
	
		
			
				|  |  | +    if not data['rov_pool_recall'] and not data['flow_pool_recall']:
 | 
	
		
			
				|  |  |          return [], 0
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      #全量的是vlog,票圈精选, 334,60057,
 | 
	
		
			
				|  |  |      # 60054: simrecall,
 | 
	
		
			
				|  |  |      pre_str = "k_p2:"
 | 
	
		
			
				|  |  | -    #print("pre_str:", pre_str)
 | 
	
		
			
				|  |  | -    rov_recall_rank = rec_recall_item_list
 | 
	
		
			
				|  |  | +    rov_recall_rank = data['rov_pool_recall']
 | 
	
		
			
				|  |  | +    #print(rov_recall_rank)
 | 
	
		
			
				|  |  |      #call rank service
 | 
	
		
			
				|  |  |      #flag_call_service = 0
 | 
	
		
			
				|  |  |      sort_index = 0
 | 
	
	
		
			
				|  | @@ -618,32 +618,63 @@ def video_new_rank2(data, size, top_K, flow_pool_P, ab_code, mid, exp_config=Non
 | 
	
		
			
				|  |  |      #print("sort_index:", sort_index)
 | 
	
		
			
				|  |  |      redisObj = RedisHelper()
 | 
	
		
			
				|  |  |      vidKeys = []
 | 
	
		
			
				|  |  | -    for recall_item in rec_recall_item_list:
 | 
	
		
			
				|  |  | -        vid = recall_item.get("videoId", 0)
 | 
	
		
			
				|  |  | -        vidKeys.append(pre_str + str(vid))
 | 
	
		
			
				|  |  | +    rec_recall_item_list = []
 | 
	
		
			
				|  |  | +    rec_recall_vid_list = []
 | 
	
		
			
				|  |  | +    day_vidKeys = []
 | 
	
		
			
				|  |  | +    hour_vidKeys = []
 | 
	
		
			
				|  |  | +    pre_day_str = "v_ctr:"
 | 
	
		
			
				|  |  | +    pre_hour_str = "v_hour_ctr:"
 | 
	
		
			
				|  |  | +    for recall_item in data['rov_pool_recall']:
 | 
	
		
			
				|  |  | +        try:
 | 
	
		
			
				|  |  | +            vid = int(recall_item.get("videoId", 0))
 | 
	
		
			
				|  |  | +            rec_recall_vid_list.append(vid)
 | 
	
		
			
				|  |  | +            rec_recall_item_list.append(recall_item)
 | 
	
		
			
				|  |  | +            vidKeys.append(pre_str + str(vid))
 | 
	
		
			
				|  |  | +            day_vidKeys.append(pre_day_str+str(vid))
 | 
	
		
			
				|  |  | +            hour_vidKeys.append(pre_hour_str+str(vid))
 | 
	
		
			
				|  |  | +        except:
 | 
	
		
			
				|  |  | +            continue
 | 
	
		
			
				|  |  |      video_scores = redisObj.get_batch_key(vidKeys)
 | 
	
		
			
				|  |  | -    if ab_code == 60066 or ab_code == 60069 or ab_code == 60070 or ab_code == 60071:
 | 
	
		
			
				|  |  | -        feature_dict = get_featurs(mid, data, size, top_K, flow_pool_P, env_dict)
 | 
	
		
			
				|  |  | +    #print("video_scores:", video_scores)
 | 
	
		
			
				|  |  | +    if (ab_code == 60066 or ab_code == 60069 or ab_code == 60070 or ab_code == 60071) and len(rec_recall_vid_list)>0:
 | 
	
		
			
				|  |  | +        video_static_info = redisObj.get_batch_key(day_vidKeys)
 | 
	
		
			
				|  |  | +        video_hour_static_info = redisObj.get_batch_key(hour_vidKeys)
 | 
	
		
			
				|  |  | +        #print("env_dict:", env_dict)
 | 
	
		
			
				|  |  | +        feature_dict = get_featurs(mid, data, size, top_K, flow_pool_P, rec_recall_vid_list,env_dict, video_static_info, video_hour_static_info)
 | 
	
		
			
				|  |  |          score_result = get_tf_serving_sores(feature_dict)
 | 
	
		
			
				|  |  | +        #print("score_result:", score_result)
 | 
	
		
			
				|  |  |          if video_scores and len(video_scores)>0  and rec_recall_item_list and score_result and len(score_result) > 0\
 | 
	
		
			
				|  |  |                  and len(score_result) == len(rec_recall_item_list) and len(video_scores)== len(score_result):
 | 
	
		
			
				|  |  |              for i in range(len(score_result)):
 | 
	
		
			
				|  |  |                  try:
 | 
	
		
			
				|  |  |                      if video_scores[i] is None and len(score_result[i])>0:
 | 
	
		
			
				|  |  |                          return_score = 0.000000001
 | 
	
		
			
				|  |  | -                        total_score = return_score * score_result[i][0]
 | 
	
		
			
				|  |  | +                        # sore_index :10 = model score
 | 
	
		
			
				|  |  | +                        if sort_index == 10:
 | 
	
		
			
				|  |  | +                            total_score = score_result[i][0]
 | 
	
		
			
				|  |  | +                        else:
 | 
	
		
			
				|  |  | +                            total_score = return_score * score_result[i][0]
 | 
	
		
			
				|  |  |                          rec_recall_item_list[i]['sort_score'] = total_score
 | 
	
		
			
				|  |  |                      else:
 | 
	
		
			
				|  |  |                          video_score_str = json.loads(video_scores[i])
 | 
	
		
			
				|  |  | -                        if len(video_score_str)>= sort_index and  len(video_score_str)>0:
 | 
	
		
			
				|  |  | -                            return_score = video_score_str[sort_index]
 | 
	
		
			
				|  |  | +                        # sore_index :10 = model score
 | 
	
		
			
				|  |  | +                        if sort_index == 10:
 | 
	
		
			
				|  |  | +                            total_score = score_result[i][0]
 | 
	
		
			
				|  |  |                          else:
 | 
	
		
			
				|  |  | -                            return_score = 0.000000001
 | 
	
		
			
				|  |  | -                        total_score = return_score * score_result[i][0]
 | 
	
		
			
				|  |  | +                            return_score  = 0.000000001
 | 
	
		
			
				|  |  | +                            if len(video_score_str)>= sort_index and  len(video_score_str)>0:
 | 
	
		
			
				|  |  | +                                return_score = video_score_str[sort_index]
 | 
	
		
			
				|  |  | +                            total_score = return_score * score_result[i][0]
 | 
	
		
			
				|  |  | +                            #print("total_score:", total_score, " model score :", score_result[i][0], "return_score:",
 | 
	
		
			
				|  |  | +                             #     return_score)
 | 
	
		
			
				|  |  |                          rec_recall_item_list[i]['sort_score'] = total_score
 | 
	
		
			
				|  |  | -                except Exception:
 | 
	
		
			
				|  |  | -                    return_score = 0.000000001
 | 
	
		
			
				|  |  | -                    total_score = return_score * 0.00000001
 | 
	
		
			
				|  |  | +                except Exception as e:
 | 
	
		
			
				|  |  | +                    #print('exception: {}:', e)
 | 
	
		
			
				|  |  | +                    if sort_index == 10:
 | 
	
		
			
				|  |  | +                        total_score = 0.00000001
 | 
	
		
			
				|  |  | +                    else:
 | 
	
		
			
				|  |  | +                        return_score = 0.000000001
 | 
	
		
			
				|  |  | +                        total_score = return_score * 0.00000001
 | 
	
		
			
				|  |  |                      rec_recall_item_list[i]['sort_score'] = total_score
 | 
	
		
			
				|  |  |                  rec_recall_item_list[i]['flag_call_service'] = 1
 | 
	
		
			
				|  |  |              rov_recall_rank = sorted(rec_recall_item_list, key=lambda k: k.get('sort_score', 0), reverse=True)
 |