07_ad_model_update_everyday.sh 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #!/bin/sh
  2. set -ex
  3. # 0 全局变量/参数
  4. originDataSavePath=/dw/recommend/model/31_ad_sample_data_auto/
  5. bucketFeatureSavePath=/dw/recommend/model/33_ad_train_data_nosparse_auto/
  6. model_name=ad_model_lr
  7. today="$(date +%Y%m%d)"
  8. today_early_1="$(date -d '1 days ago' +%Y%m%d)"
  9. beginTime=08
  10. endTime=23
  11. beginStr=${today_early_1}${beginTime}
  12. endStr=${today_early_1}${endTime}
  13. # 1 判断依赖的数据表是否生产完成
  14. source /root/anaconda3/bin/activate py37
  15. max_hour=15
  16. max_minute=00
  17. while true; do
  18. python_return_code=$(python zhangbo/utils.py --excute_program check_ad_origin_hive --partition ${today_early_1} --hh ${endTime})
  19. if [ $python_return_code -eq 0 ]; then
  20. echo "Python程序返回0,退出循环。"
  21. break
  22. fi
  23. echo "Python程序返回非0值,等待五分钟后再次调用。"
  24. sleep 300
  25. current_hour=$(date +%H)
  26. current_minute=$(date +%M)
  27. if (( current_hour > max_hour || (current_hour == max_hour && current_minute >= max_minute) )); then
  28. echo "最长等待时间已到,失败:${current_hour}-${current_minute}"
  29. exit 1
  30. fi
  31. done
  32. # 2 原始特征生成
  33. /opt/apps/SPARK2/spark-2.4.8-hadoop3.2-1.0.8/bin/spark-class2 org.apache.spark.deploy.SparkSubmit \
  34. --class com.aliyun.odps.spark.zhp.makedata_ad.makedata_ad_31_originData_20240620 \
  35. --master yarn --driver-memory 1G --executor-memory 2G --executor-cores 1 --num-executors 16 \
  36. ./target/spark-examples-1.0.0-SNAPSHOT-shaded.jar \
  37. tablePart:64 repartition:32 \
  38. beginStr:${beginStr} endStr:${endStr} \
  39. savePath:${originDataSavePath} \
  40. table:alg_recsys_ad_sample_all_new
  41. if [ $? -ne 0 ]; then
  42. echo "Spark原始样本生产任务执行失败"
  43. exit 1
  44. else
  45. echo "spark原始样本生产执行成功"
  46. fi
  47. # 3 特征分桶
  48. /opt/apps/SPARK2/spark-2.4.8-hadoop3.2-1.0.8/bin/spark-class2 org.apache.spark.deploy.SparkSubmit \
  49. --class com.aliyun.odps.spark.zhp.makedata_ad.makedata_ad_33_bucketData_20240622 \
  50. --master yarn --driver-memory 2G --executor-memory 4G --executor-cores 1 --num-executors 16 \
  51. ./target/spark-examples-1.0.0-SNAPSHOT-shaded.jar \
  52. beginStr:${today_early_1} endStr:${today_early_1} repartition:400 \
  53. filterNames:XXXXX \
  54. bucketFileName:20240620_ad_bucket_249_fix.txt \
  55. readPath:${originDataSavePath} \
  56. savePath:${bucketFeatureSavePath}
  57. if [ $? -ne 0 ]: then
  58. echo "Spark特征分桶处理任务执行失败"
  59. exit 1
  60. else
  61. echo "spark特征分桶处理执行成功"
  62. fi
  63. # 4 模型训练
  64. # 5 对比AUC
  65. # 6 模型格式转换
  66. # 7 模型文件上传OSS