|
@@ -3,8 +3,11 @@ import time
|
|
|
import datetime
|
|
|
import pandas as pd
|
|
|
from odps import ODPS
|
|
|
-from utils import data_check
|
|
|
+from utils import data_check, RedisHelper
|
|
|
from threading import Timer
|
|
|
+from config import set_config
|
|
|
+config_, _ = set_config()
|
|
|
+redis_helper = RedisHelper()
|
|
|
|
|
|
# ODPS服务配置
|
|
|
odps_config = {
|
|
@@ -107,6 +110,25 @@ def user_data_process(project, table, dt, app_type):
|
|
|
if not os.path.exists(predict_data_dir):
|
|
|
os.makedirs(predict_data_dir)
|
|
|
user_df.to_csv(f"{predict_data_dir}/user_feature.csv", index=False)
|
|
|
+ # to redis
|
|
|
+ xgb_config = config_.AD_MODEL_ABTEST_CONFIG['xgb']
|
|
|
+ for ind, row in user_df.iterrows():
|
|
|
+ app_type = row['apptype']
|
|
|
+ mid = row['mid']
|
|
|
+ value = {
|
|
|
+ 'mid_preview_count_30day': row['mid_preview_count_30day'],
|
|
|
+ 'mid_view_count_30day': row['mid_view_count_30day'],
|
|
|
+ 'mid_view_count_pv_30day': row['mid_view_count_pv_30day'],
|
|
|
+ 'mid_play_count_30day': row['mid_play_count_30day'],
|
|
|
+ 'mid_play_count_pv_30day': row['mid_play_count_pv_30day'],
|
|
|
+ 'mid_share_count_30day': row['mid_share_count_30day'],
|
|
|
+ 'mid_share_count_pv_30day': row['mid_share_count_pv_30day'],
|
|
|
+ 'mid_return_count_30day': row['mid_return_count_30day'],
|
|
|
+ 'mid_share_rate_30day': row['mid_share_rate_30day'],
|
|
|
+ 'mid_return_rate_30day': row['mid_return_rate_30day']
|
|
|
+ }
|
|
|
+ key = f"{xgb_config['predict_user_feature_key_prefix']}{app_type}:{mid}"
|
|
|
+ redis_helper.set_data_to_redis(key_name=key, value=str(value), expire_time=48 * 3600)
|
|
|
|
|
|
|
|
|
def timer_check():
|