Jelajahi Sumber

update rank

linfan 1 tahun lalu
induk
melakukan
4096ddb70b
2 mengubah file dengan 19 tambahan dan 14 penghapusan
  1. 6 7
      rank_service.py
  2. 13 7
      video_rank.py

+ 6 - 7
rank_service.py

@@ -8,7 +8,7 @@ log_ = Log()
 
 
 config_ = set_config()
-def get_featurs(mid, data, size, top_K, flow_pool_P, env_dict=None, video_static_info=None, video_hour_static_info=None, ):
+def get_featurs(mid, data, size, top_K, flow_pool_P, rec_recall_vid_list, env_dict=None, video_static_info=None, video_hour_static_info=None):
     feature_dict = {}
     # defult value
     apptype = 4
@@ -73,13 +73,12 @@ def get_featurs(mid, data, size, top_K, flow_pool_P, env_dict=None, video_static
     day_share_users = []
     recommendsource_list = []
     relevant_video_list = []
-    recall_list = env_dict.get('recall_list', [])
     city_list = []
     province_list = []
-    if recall_list and len(recall_list)>0:
-        for i in range(len(recall_list)):
+    if rec_recall_vid_list and len(rec_recall_vid_list)>0:
+        for i in range(len(rec_recall_vid_list)):
             mid_list.append(mid)
-            videoid_list.append(int(recall_list[i]))
+            videoid_list.append(rec_recall_vid_list[i])
             apptype_list.append(apptype)
             pagesource_list.append(pagesource)
             versioncode_list.append(versioncode)
@@ -119,7 +118,7 @@ def get_featurs(mid, data, size, top_K, flow_pool_P, env_dict=None, video_static
                                           day_share_pv_list, day_share_return_score_list, day_share_score_list,
                                           day_share_users, day_view_pv_list, day_view_users_list)
     else:
-        for i in range(len(recall_list)):
+        for i in range(len(rec_recall_vid_list)):
             insert_static_default_fea(day_ctr_score_list, day_play_pv_list, day_play_users_list,
                                       day_return_rate_list, day_return_users_list, day_rov_list,
                                       day_share_pv_list, day_share_return_score_list, day_share_score_list,
@@ -153,7 +152,7 @@ def get_featurs(mid, data, size, top_K, flow_pool_P, env_dict=None, video_static
                     hour_return_rate_list.append(0.0)
                     hour_ctr_score_list.append(0.0)
     else:
-        for i in range(len(recall_list)):
+        for i in range(len(rec_recall_vid_list)):
             hour_rov_list.append(0.0)
             hour_share_return_score_list.append(0.0)
             hour_share_score_list.append(0.0)

+ 13 - 7
video_rank.py

@@ -618,21 +618,27 @@ def video_new_rank2(data, size, top_K, flow_pool_P, ab_code, mid, exp_config=Non
     redisObj = RedisHelper()
     vidKeys = []
     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']:
-        vid = recall_item.get("videoId", 0)
-        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))
+        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:
+    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)
-        feature_dict = get_featurs(mid, data, size, top_K, flow_pool_P, env_dict, video_static_info, video_hour_static_info)
+        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)
         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):