Quellcode durchsuchen

update video_rank

linfan vor 1 Jahr
Ursprung
Commit
e4c8b9f749
1 geänderte Dateien mit 57 neuen und 68 gelöschten Zeilen
  1. 57 68
      video_recall.py

+ 57 - 68
video_recall.py

@@ -2386,25 +2386,21 @@ class PoolRecall(object):
 
     def get_3days_hot_item_reall(self, exp_config=None):
         recall_key = "hot_3day:"
-        #print("recall_key:", recall_key)
         data = self.redis_helper.get_data_from_redis(key_name=recall_key)
-
-        #print(data)
         recall_result = []
         recall_dict  = {}
         video_ids = []
-        if data is not None:
-            json_result = json.loads(data)
-            #print("json_result:", json_result)
-            for per_item in json_result:
-                try:
-                    vid = int(per_item[0])
-                    video_ids.append(vid)
-                    recall_dict[vid] = {'videoId': vid, 'flowPool': '',
-                         'rovScore': per_item[1], 'pushFrom': config_.PUSH_FROM['hot_3_day_recall'],
-                         'abCode': self.ab_code}
-                except Exception as e:
-                    continue
+        if data is not None and data!="":
+            try:
+                json_result = json.loads(data)
+                for per_item in json_result:
+                        vid = int(per_item[0])
+                        video_ids.append(vid)
+                        recall_dict[vid] = {'videoId': vid, 'flowPool': '',
+                             'rovScore': per_item[1], 'pushFrom': config_.PUSH_FROM['hot_3_day_recall'],
+                             'abCode': self.ab_code}
+            except Exception as e:
+                return  recall_result
         #print("vid len:", len(video_ids))
         if len(video_ids)<=0:
             return  recall_result
@@ -2434,23 +2430,20 @@ class PoolRecall(object):
         recall_key = "hot_video:"
         #print("recall_key:", recall_key)
         data = self.redis_helper.get_data_from_redis(key_name=recall_key)
-
-        #print(data)
         recall_result = []
         recall_dict  = {}
         video_ids = []
-        if data is not None:
-            json_result = json.loads(data)
-            # print("json_result:", json_result)
-            for per_item in json_result:
-                try:
+        if data is not None and data!="":
+            try:
+                json_result = json.loads(data)
+                for per_item in json_result:
                     vid = int(per_item[0])
                     video_ids.append(vid)
                     recall_dict[vid] = {'videoId': vid, 'flowPool': '',
-                         'rovScore': per_item[1], 'pushFrom': config_.PUSH_FROM['hot_recall'],
-                         'abCode': self.ab_code}
-                except Exception as e:
-                    continue
+                             'rovScore': per_item[1], 'pushFrom': config_.PUSH_FROM['hot_recall'],
+                             'abCode': self.ab_code}
+            except Exception as e:
+                recall_result
         if len(video_ids)<=0:
             return  recall_result
         recall_num = 20
@@ -2485,18 +2478,17 @@ class PoolRecall(object):
         recall_result = []
         recall_dict = {}
         video_ids = []
-        if data is not None:
-            json_result = json.loads(data)
-            # print("json_result:", json_result)
-            for per_item in json_result:
-                try:
-                    vid = int(per_item[0])
-                    video_ids.append(vid)
-                    recall_dict[vid] = {'videoId': vid, 'flowPool': '',
-                                        'rovScore': per_item[1], 'pushFrom': config_.PUSH_FROM['title_i2i_recall'],
-                                        'abCode': self.ab_code}
-                except Exception as e:
-                    continue
+        if data is not None and data!="":
+            try:
+                json_result = json.loads(data)
+                for per_item in json_result:
+                        vid = int(per_item[0])
+                        video_ids.append(vid)
+                        recall_dict[vid] = {'videoId': vid, 'flowPool': '',
+                                            'rovScore': per_item[1], 'pushFrom': config_.PUSH_FROM['title_i2i_recall'],
+                                            'abCode': self.ab_code}
+            except Exception as e:
+                return recall_result
         if len(video_ids) <= 0:
             return recall_result
         video_ids = video_ids[:50]
@@ -2524,17 +2516,16 @@ class PoolRecall(object):
         recall_dict  = {}
         video_ids = []
         if data is not None and data.strip()!="":
-            json_result = data.strip().split(",")
-            # print("json_result:", json_result)
-            for per_item in json_result:
-                try:
-                    vid = int(per_item)
-                    video_ids.append(vid)
-                    recall_dict[vid] = {'videoId': vid, 'flowPool': '',
-                         'rovScore': 0.0, 'pushFrom': config_.PUSH_FROM['w2v_recall'],
-                         'abCode': self.ab_code}
-                except Exception as e:
-                    continue
+            try:
+                json_result = data.strip().split(",")
+                for per_item in json_result:
+                        vid = int(per_item)
+                        video_ids.append(vid)
+                        recall_dict[vid] = {'videoId': vid, 'flowPool': '',
+                             'rovScore': 0.0, 'pushFrom': config_.PUSH_FROM['w2v_recall'],
+                             'abCode': self.ab_code}
+            except Exception as e:
+                return  recall_result
         if len(video_ids)<=0:
             return  recall_result
         recall_num = 20
@@ -2562,7 +2553,7 @@ class PoolRecall(object):
         recall_key = "test_exp_config_pos"
         # print("recall_key:", recall_key)
         data = self.redis_helper.get_data_from_redis(key_name=recall_key)
-        if data is not None:
+        if data is not None and  data!="":
             try:
                 #print(data)
                 json_result = json.loads(data)
@@ -2576,7 +2567,7 @@ class PoolRecall(object):
     def get_w2v_config(self):
         recall_key = "w2v_exp_config_pos_range"
         data = self.redis_helper.get_data_from_redis(key_name=recall_key)
-        if data is not None:
+        if data is not None and data!="":
             try:
                 #print(data)
                 json_result = json.loads(data)
@@ -2606,7 +2597,7 @@ class PoolRecall(object):
         recall_key = "simrecall_exp_config_range"
         #print("recall_key:", recall_key)
         data = self.redis_helper.get_data_from_redis(key_name=recall_key)
-        if data is not None:
+        if data is not None and data!="":
             try:
                 # print(data)
                 json_result = json.loads(data)
@@ -2634,7 +2625,7 @@ class PoolRecall(object):
     def get_U2I_config(self):
         recall_key = "u2i_exp_config_pos_range"
         data = self.redis_helper.get_data_from_redis(key_name=recall_key)
-        if data is not None:
+        if data is not None and data!="":
             try:
                 # print(data)
                 json_result = json.loads(data)
@@ -2734,18 +2725,17 @@ class PoolRecall(object):
         recall_result = []
         recall_dict  = {}
         video_ids = []
-        if data is not None:
-            json_result = json.loads(data)
-            #print("json_result:", json_result)
-            for per_item in json_result:
-                try:
+        if data is not None and data!="":
+            try:
+                json_result = json.loads(data)
+                for per_item in json_result:
                     vid = int(per_item[0])
                     video_ids.append(vid)
                     recall_dict[vid] = {'videoId': vid, 'flowPool': '',
                          'rovScore': float(per_item[1]), 'pushFrom': config_.PUSH_FROM['u2i_tag_recall'],
                          'abCode': self.ab_code}
-                except Exception as e:
-                    continue
+            except Exception as e:
+                return  recall_result
         if len(video_ids)<=0:
             return  recall_result
         recall_num = 20
@@ -2819,7 +2809,7 @@ class PoolRecall(object):
     def get_video_recall_config(self):
         recall_key = "vr_exp_pos_config_range"
         data = self.redis_helper.get_data_from_redis(key_name=recall_key)
-        if data is not None:
+        if data is not None and data!="":
             try:
                 # print(data)
                 json_result = json.loads(data)
@@ -2841,18 +2831,17 @@ class PoolRecall(object):
         recall_result = []
         recall_dict  = {}
         video_ids = []
-        if data is not None:
-            json_result = json.loads(data)
-            #print("json_result:", json_result)
-            for per_item in json_result:
-                try:
+        if data is not None and data!="" :
+            try:
+                json_result = json.loads(data)
+                for per_item in json_result:
                     vid = int(per_item[0])
                     video_ids.append(vid)
                     recall_dict[vid] = {'videoId': vid, 'flowPool': '',
                          'rovScore': float(per_item[1]), 'pushFrom': config_.PUSH_FROM['return_video_recall'],
                          'abCode': self.ab_code}
-                except Exception as e:
-                    continue
+            except Exception as e:
+                return recall_result
         if len(video_ids)<=0:
             return  recall_result
         recall_num = 20