DAG: multi_interest_ldd

schedule: 00 07 * * *


multi_interest_ldd

Toggle wrap
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
from airflow import DAG
from airflow.operators.bash_operator import BashOperator
from datetime import datetime, timedelta
from airflow.contrib.operators.spark_submit_operator import SparkSubmitOperator
from datetime import timedelta,datetime
import pendulum
import pytz

tz = pytz.timezone('Asia/Shanghai')

default_args = {
    'owner': 'Terry',
    'depends_on_past': False,
    'start_date': pendulum.datetime(year=2024, month=8, day=20).astimezone(tz),
    'email': ['tian23.li@tcl.com'],
    'email_on_failure': True,
    'email_on_retry': True,
    'retries': 2,
    'retry_delay': timedelta(minutes=20),
}

_config = {
    'conf': {
        'spark.executor.extraJavaOptions': '-XX:+UseConcMarkSweepGC',
        "spark.dynamicAllocation.minExecutors":8,
        "spark.dynamicAllocation.maxExecutors":8,
        "spark.yarn.executor.memoryOverhead":2648,
        "spark.driver.maxResultSize": "4g",
        "spark.yarn.maxAppAttempts": 1,
        "spark.network.timeout": 1000000,
        "spark.executor.heartbeatInterval" : 1000000
    },
    'executor_cores': 4,
    'executor_memory': '6g',
    'name': '{{ task_instance.task_id }}',
    
    'driver_memory': '6g',
}

dag = DAG(
    dag_id='multi_interest_ldd',
    description='flow for multi-interest ldd',
    default_args=default_args,
    schedule_interval='00 07 * * *',
)

# kill_iPython_job = BashOperator(
#     task_id='kill_iPython_job',
#     bash_command="ps -ef | grep ipykernel | grep -v grep | awk '{print $2}' | xargs kill -9",
#     #bash_command="kill $(nvidia-smi -g 0)",
#     dag=dag,
# )


update_ldd_media = BashOperator(
    task_id='update_ldd_media',
    bash_command="cd /data/gangyanyuan/terry/terry-recsys-2024/multi-interest/script/ldd && /data/dev/miniconda/envs/recsys2/bin/python 0_update_ldd_media.py",
    depends_on_past =False,
    dag=dag,
)
update_ldd_media_v2 = BashOperator(
    task_id='update_ldd_media_v2',
    bash_command="cd /data/gangyanyuan/terry/terry-recsys-2024/multi-interest/script/ldd && /data/dev/miniconda/envs/recsys2/bin/python 0_1_update_ldd_media_v2.py",
    depends_on_past =False,
    dag=dag,
)
update_content_embedding_ldd = BashOperator(
    task_id='update_content_embedding_ldd',
    bash_command="cd /data/gangyanyuan/terry/terry-recsys-2024/script && /data/dev/miniconda/envs/easyrec/bin/python update_content_embedding_ldd.py",
    depends_on_past =False,
    dag=dag,
)
get_pretrained_content_embedding_ldd = BashOperator(
    task_id='get_pretrained_content_embedding_ldd',
    bash_command="cd /data/gangyanyuan/terry/terry-recsys-2024/multi-interest/script/ldd && /data/dev/miniconda/envs/deepmatch/bin/python get_pretrained_content_embedding_ldd.py --dataset ldd",
    depends_on_past =False,
    dag=dag,
)
get_pretrained_image_embedding_minicpm_ldd = BashOperator(
    task_id='get_pretrained_image_embedding_minicpm_ldd',
    bash_command="cd /data/gangyanyuan/terry/terry-recsys-2024/multi-interest/script/ldd && /data/dev/miniconda/envs/deepmatch/bin/python get_pretrained_image_embedding_minicpm_ldd.py --dataset ldd",
    depends_on_past =False,
    dag=dag,
)
pca_text_image = BashOperator(
    task_id='pca_text_image',
    bash_command="cd /data/gangyanyuan/terry/terry-recsys-2024/multi-interest/script && /data/dev/miniconda/envs/deepmatch/bin/python pca.py --dataset ldd --text_feat --image_feat",
    depends_on_past =False,
    dag=dag,
)
get_top300_aids = BashOperator(
    task_id='get_top300_aids',
    bash_command="cd /data/gangyanyuan/terry/terry-recsys-2024/multi-interest/script/ldd && /data/dev/miniconda/envs/recsys2/bin/python get_top300_aids.py",
    depends_on_past =False,
    dag=dag,
)

generate_user_click_data_ldd = BashOperator(
    task_id='generate_user_click_data_ldd',
    bash_command="cd /data/gangyanyuan/terry/terry-recsys-2024/multi-interest/script/ldd && /data/dev/miniconda/envs/recsys2/bin/python 1_get_user_click_data_ldd.py",
    depends_on_past =False,
    dag=dag,
)

update_user_click_ldd_60days = BashOperator(
    task_id='update_user_click_ldd_60days',
    bash_command="cd /data/gangyanyuan/terry/terry-recsys-2024/multi-interest/script/ldd && /data/dev/miniconda/envs/deepmatch/bin/python 2_1_update_user_click_ldd_60days.py",
    depends_on_past =False,
    dag=dag,
)
generate_diffurec_dataset = BashOperator(
    task_id='generate_diffurec_dataset',
    bash_command="cd /data/gangyanyuan/terry/terry-recsys-2024/multi-interest/script/ldd && /data/dev/miniconda/envs/deepmatch/bin/python 3_generate_diffurec_dataset.py",
    depends_on_past =False,
    dag=dag,
)
# # # train
# train_diffurec_ldd = BashOperator(
#     task_id='train_diffurec_ldd',
#     bash_command="cd /data/gangyanyuan/terry/terry-recsys-2024/multi-interest/DiffuRec/src && /data/dev/miniconda/envs/pt1.0/bin/python main_daily.py --dataset ldd --max_len 10",
#     depends_on_past =False,
#     dag=dag,
# )
train_diffurec_ldd = BashOperator(
    task_id='train_diffurec_ldd',
    bash_command="cd /data/gangyanyuan/terry/terry-recsys-2024/multi-interest/DiffuRec/src_v2 && /data/dev/miniconda/envs/pt1.0/bin/python main_daily.py --dataset ldd --max_len 10 --text_feat --image_feat",
    depends_on_past =False,
    dag=dag,
)
generate_inference_dataset = BashOperator(
    task_id='generate_inference_dataset',
    bash_command="cd /data/gangyanyuan/terry/terry-recsys-2024/multi-interest/script/ldd && /data/dev/miniconda/envs/deepmatch/bin/python 4_generate_inference_dataset.py",
    depends_on_past =False,
    dag=dag,
)

generate_diffurec_recall_result = BashOperator(
    task_id='generate_diffurec_recall_result',
    bash_command="cd /data/gangyanyuan/terry/terry-recsys-2024/multi-interest/script/ldd && /data/dev/miniconda/envs/pt1.0/bin/python 5_generate_diffurec_recall_result.py --text_feat --image_feat",
    depends_on_past =False,
    dag=dag,
)
generate_diffurec_recall_result_234 = BashOperator(
    task_id='generate_diffurec_recall_result_234',
    bash_command="cd /data/gangyanyuan/terry/terry-recsys-2024/multi-interest/script/ldd && /data/dev/miniconda/envs/pt1.0/bin/python 5_1_generate_diffurec_recall_result_234.py --text_feat --image_feat",
    depends_on_past =False,
    dag=dag,
)

## jx lst ldd
"""
generate_diffurec_dataset_jx_ldd = BashOperator(
    task_id='generate_diffurec_dataset_jx_ldd',
    bash_command="cd /data/gangyanyuan/terry/terry-recsys-2024/multi-interest/script/ldd/jx_lst_sep && /data/dev/miniconda/envs/deepmatch/bin/python 3_generate_diffurec_dataset_jx_ldd.py",
    depends_on_past =False,
    dag=dag,
)
# # # train
train_diffurec_ldd_sep = BashOperator(
    task_id='train_diffurec_ldd_sep',
    bash_command="cd /data/gangyanyuan/terry/terry-recsys-2024/multi-interest/DiffuRec/src && /data/dev/miniconda/envs/pt1.0/bin/python main_daily_sep.py --dataset ldd --max_len 10",
    depends_on_past =False,
    dag=dag,
)
generate_inference_dataset_jx_ldd = BashOperator(
    task_id='generate_inference_dataset_jx_ldd',
    bash_command="cd /data/gangyanyuan/terry/terry-recsys-2024/multi-interest/script/ldd/jx_lst_sep && /data/dev/miniconda/envs/deepmatch/bin/python 4_generate_inference_dataset_jx_ldd.py",
    depends_on_past =False,
    dag=dag,
)

generate_diffurec_recall_result_jx_ldd = BashOperator(
    task_id='generate_diffurec_recall_result_jx_ldd',
    bash_command="cd /data/gangyanyuan/terry/terry-recsys-2024/multi-interest/script/ldd/jx_lst_sep && /data/dev/miniconda/envs/pt1.0/bin/python 5_generate_diffurec_recall_result_jx_ldd.py",
    depends_on_past =False,
    dag=dag,
)

"""
save_ldd_recall_to_hive = SparkSubmitOperator(
    task_id='save_ldd_recall_to_hive',
    dag=dag,
    **_config,
    application= '/data/gangyanyuan/terry/terry-recsys-2024/multi-interest/script/ldd/save_ldd_recall_to_hive.py',
    conn_id = "spark_local",
)
save_ldd_recall_to_hive_jx_lst = SparkSubmitOperator(
    task_id='save_ldd_recall_to_hive_jx_lst',
    dag=dag,
    **_config,
    application= '/data/gangyanyuan/terry/terry-recsys-2024/multi-interest/script/ldd/save_ldd_recall_to_hive_jx_lst.py',
    conn_id = "spark_local",
)


update_ldd_media >> update_ldd_media_v2 >> update_content_embedding_ldd

update_ldd_media >> get_top300_aids >> generate_user_click_data_ldd >> update_user_click_ldd_60days >> generate_diffurec_dataset >> get_pretrained_content_embedding_ldd >> get_pretrained_image_embedding_minicpm_ldd >> pca_text_image >> train_diffurec_ldd >> generate_inference_dataset >> [generate_diffurec_recall_result,generate_diffurec_recall_result_234] 

generate_diffurec_recall_result >> [save_ldd_recall_to_hive, save_ldd_recall_to_hive_jx_lst]

generate_diffurec_recall_result_234 >> [save_ldd_recall_to_hive, save_ldd_recall_to_hive_jx_lst]
# update_user_click_ldd_60days >> generate_diffurec_dataset_jx_ldd >> train_diffurec_ldd_sep >> generate_inference_dataset_jx_ldd >> generate_diffurec_recall_result_jx_ldd >> save_ldd_recall_to_hive_jx_lst