import redis import random from models.model import R from utils import filter_utils from configs import config_redis, config_algo class pool_manager: def __init__(self, k, p, mid, scene,counts=10): self.k = k self.p = p self.mid = mid self.scene = scene self.counts = counts #前k个按rov分值排序,后面total-k个,按p的概率从测试池取值,1-p的概率从召回池取 def get_rov_data(self, k,p): res_all = [] res_recall = self._get_data_from_cache(config_redis.ROV_SERVICE_RECALL_VIDS, self.counts, self.mid) res_pool = self._get_data_from_cache(config_redis.ROV_SERVICE_POOL_VIDS, self.counts, self.mid) head_recall = 0 head_pool = 0 #TODO #添加score及from来源 i = 0 item = None while(ires_pool[head_pool]['score']: item = res_recall[head_recall] head_recall += 1 else: item = res_pool[head_pool] head_pool += 1 res_all.append(item) i += 1 i = 0 while(i