DAG: multi_interest_2024_dag

schedule: 10 03 * * *


multi_interest_2024_dag

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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
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=2023, month=12, day=8).astimezone(tz),
    'email': ['tian23.li@tcl.com'],
    'email_on_failure': True,
    'email_on_retry': True,
    'retries': 2,
    'retry_delay': timedelta(minutes=8),
}

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

dag = DAG(
    dag_id='multi_interest_2024_dag',
    description='flow for multi-interest modeling',
    default_args=default_args,
    schedule_interval='10 03 * * *',#30 05
)

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,
)
# kill_large_processes = BashOperator(
#     task_id='kill_large_processes',
#     ## 
#     bash_command="cd /data/gangyanyuan/scheduled_jobs /data/gangyanyuan/scheduled_jobs/kill-large-processes.sh ",
#     dag=dag,
# )
update_jx_lst_media = BashOperator(
    task_id='update_jx_lst_media',
    bash_command="cd /data/gangyanyuan/terry/terry-recsys-2024/multi-interest/script && /data/dev/miniconda/envs/recsys2/bin/python 0_update_jx_lst_media.py",
    depends_on_past =False,
    dag=dag,
)

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

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

# ## jx data flow. 
update_user_click_all_channelname_60days_012468 = BashOperator(
    task_id='update_user_click_all_channelname_60days_012468',
    bash_command="cd /data/gangyanyuan/terry/terry-recsys-2024/multi-interest/script/jx_lst_july && /data/dev/miniconda/envs/deepmatch/bin/python 2_3_update_user_click_all_channelname_60days_012468.py",
    depends_on_past =False,
    dag=dag,
)
update_user_click_all_channelname_60days_3579 = BashOperator(
    task_id='update_user_click_all_channelname_60days_3579',
    bash_command="cd /data/gangyanyuan/terry/terry-recsys-2024/multi-interest/script/jx_lst_sep && /data/dev/miniconda/envs/deepmatch/bin/python 2_4_update_user_click_all_channelname_60days_3579.py",
    depends_on_past =False,
    dag=dag,
)

generate_diffurec_dataset_all_channelname_012468 = BashOperator(
    task_id='generate_diffurec_dataset_all_channelname_012468',
    bash_command="cd /data/gangyanyuan/terry/terry-recsys-2024/multi-interest/script/jx_lst_july && /data/dev/miniconda/envs/deepmatch/bin/python 3_generate_diffurec_dataset_all_channelname_012468.py",
    depends_on_past =False,
    dag=dag,
)

generate_diffurec_dataset_all_channelname_3579 = BashOperator(
    task_id='generate_diffurec_dataset_all_channelname_3579',
    bash_command="cd /data/gangyanyuan/terry/terry-recsys-2024/multi-interest/script/jx_lst_sep && /data/dev/miniconda/envs/deepmatch/bin/python 3_generate_diffurec_dataset_all_channelname_3579.py",
    depends_on_past =False,
    dag=dag,
)

# get_pretrained_text_embedding_jx_lst = BashOperator(
#     task_id='get_pretrained_text_embedding_jx_lst',
#     bash_command="cd /data/gangyanyuan/terry/terry-recsys-2024/multi-interest/script && /data/dev/miniconda/envs/deepmatch/bin/python get_pretrained_text_embedding.py",
#     depends_on_past =False,
#     dag=dag,
# )
get_pretrained_content_embedding_jx_lst = BashOperator(
    task_id='get_pretrained_content_embedding_jx_lst',
    bash_command="cd /data/gangyanyuan/terry/terry-recsys-2024/multi-interest/script && /data/dev/miniconda/envs/deepmatch/bin/python get_pretrained_content_embedding.py",
    depends_on_past =False,
    dag=dag,
)
get_pretrained_image_embedding_minicpm = BashOperator(
    task_id='get_pretrained_image_embedding_minicpm',
    bash_command="cd /data/gangyanyuan/terry/terry-recsys-2024/multi-interest/script && /data/dev/miniconda/envs/deepmatch/bin/python get_pretrained_image_embedding_minicpm.py",
    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 --text_feat --image_feat",
    depends_on_past =False,
    dag=dag,
)

train_diffurec = BashOperator(
    task_id='train_diffurec',
    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 --text_feat --image_feat --epochs 15",
    depends_on_past =False,
    dag=dag,
)

get_pretrained_content_embedding_sep = BashOperator(
    task_id='get_pretrained_content_embedding_sep',
    bash_command="cd /data/gangyanyuan/terry/terry-recsys-2024/multi-interest/script/jx_lst_sep && /data/dev/miniconda/envs/deepmatch/bin/python get_pretrained_content_embedding_sep.py",
    depends_on_past =False,
    dag=dag,
)
get_pretrained_image_embedding_minicpm_sep = BashOperator(
    task_id='get_pretrained_image_embedding_minicpm_sep',
    bash_command="cd /data/gangyanyuan/terry/terry-recsys-2024/multi-interest/script/jx_lst_sep && /data/dev/miniconda/envs/deepmatch/bin/python get_pretrained_image_embedding_minicpm_sep.py",
    depends_on_past =False,
    dag=dag,
)

pca_text_image_v2 = BashOperator(
    task_id='pca_text_image_v2',
    bash_command="cd /data/gangyanyuan/terry/terry-recsys-2024/multi-interest/script && /data/dev/miniconda/envs/deepmatch/bin/python pca_v2.py --text_feat --image_feat",
    depends_on_past =False,
    dag=dag,
)

train_llm_diffurec_v2 = BashOperator(
    task_id='train_llm_diffurec_v2',
    bash_command="cd /data/gangyanyuan/terry/terry-recsys-2024/multi-interest/DiffuRec/src_v2 && /data/dev/miniconda/envs/pt1.0/bin/python main_daily_llm_v2.py --text_feat --image_feat --epochs 15",
    depends_on_past =False,
    dag=dag,
)
generate_inference_dataset_012468 = BashOperator(
    task_id='generate_inference_dataset_012468',
    bash_command="cd /data/gangyanyuan/terry/terry-recsys-2024/multi-interest/script/jx_lst_july && /data/dev/miniconda/envs/deepmatch/bin/python 4_1_generate_inference_dataset_012468.py",
    depends_on_past =False,
    dag=dag,
)
generate_inference_dataset_3579 = BashOperator(
    task_id='generate_inference_dataset_3579',
    bash_command="cd /data/gangyanyuan/terry/terry-recsys-2024/multi-interest/script/jx_lst_sep && /data/dev/miniconda/envs/deepmatch/bin/python 4_2_generate_inference_dataset_3579.py",
    depends_on_past =False,
    dag=dag,
)


generate_diffurec_recall_result_2468 = BashOperator(
    task_id='generate_diffurec_recall_result_2468',
    bash_command="cd /data/gangyanyuan/terry/terry-recsys-2024/multi-interest/script/jx_lst_july && /data/dev/miniconda/envs/pt1.0/bin/python 6_1_generate_diffurec_recall_result_2468.py --text_feat --image_feat",
    depends_on_past =False,
    dag=dag,
)

generate_diffurec_recall_result_3579 = BashOperator(
    task_id='generate_diffurec_recall_result_3579',
    bash_command="cd /data/gangyanyuan/terry/terry-recsys-2024/multi-interest/script/jx_lst_sep && /data/dev/miniconda/envs/pt1.0/bin/python 6_2_generate_diffurec_recall_result_3579.py --text_feat --image_feat",
    depends_on_past =False,
    dag=dag,
)
# generate_diffurec_recall_result_7 = BashOperator(
#     task_id='generate_diffurec_recall_result_7',
#     bash_command="cd /data/gangyanyuan/terry/terry-recsys-2024/multi-interest/script/jx_lst_sep && /data/dev/miniconda/envs/pt1.0/bin/python 6_3_generate_diffurec_recall_result_7.py --text_feat --image_feat",
#     depends_on_past =False,
#     dag=dag,
# )


# vip model
get_pretrained_content_embedding_vip = BashOperator(
    task_id='get_pretrained_content_embedding_vip',
    bash_command="cd /data/gangyanyuan/terry/terry-recsys-2024/multi-interest/script/jx_lst_sep/vip && /data/dev/miniconda/envs/deepmatch/bin/python get_pretrained_content_embedding_vip.py",
    depends_on_past =False,
    dag=dag,
)
get_pretrained_image_embedding_minicpm_vip = BashOperator(
    task_id='get_pretrained_image_embedding_minicpm_vip',
    bash_command="cd /data/gangyanyuan/terry/terry-recsys-2024/multi-interest/script/jx_lst_sep/vip && /data/dev/miniconda/envs/deepmatch/bin/python get_pretrained_image_embedding_minicpm_vip.py",
    depends_on_past =False,
    dag=dag,
)
generate_diffurec_dataset_all_channelname_vip = BashOperator(
    task_id='generate_diffurec_dataset_all_channelname_vip',
    bash_command="cd /data/gangyanyuan/terry/terry-recsys-2024/multi-interest/script/jx_lst_sep/vip && /data/dev/miniconda/envs/deepmatch/bin/python 3_generate_diffurec_dataset_all_channelname_vip.py",
    depends_on_past =False,
    dag=dag,
)

pca_text_image_vip = BashOperator(
    task_id='pca_text_image_vip',
    bash_command="cd /data/gangyanyuan/terry/terry-recsys-2024/multi-interest/script && /data/dev/miniconda/envs/deepmatch/bin/python pca_vip.py --text_feat --image_feat",
    depends_on_past =False,
    dag=dag,
)

train_diffurec_vip = BashOperator(
    task_id='train_diffurec_vip',
    bash_command="cd /data/gangyanyuan/terry/terry-recsys-2024/multi-interest/DiffuRec/src_v2 && /data/dev/miniconda/envs/pt1.0/bin/python main_daily_vip.py --max_len 10 --text_feat --image_feat --epochs 15",
    depends_on_past =False,
    dag=dag,
)

generate_inference_dataset_vip = BashOperator(
    task_id='generate_inference_dataset_vip',
    bash_command="cd /data/gangyanyuan/terry/terry-recsys-2024/multi-interest/script/jx_lst_sep/vip && /data/dev/miniconda/envs/deepmatch/bin/python 4_generate_inference_dataset_vip.py",
    depends_on_past =False,
    dag=dag,
)
generate_diffurec_recall_result_vip = BashOperator(
    task_id='generate_diffurec_recall_result_vip',
    bash_command="cd /data/gangyanyuan/terry/terry-recsys-2024/multi-interest/script/jx_lst_sep/vip && /data/dev/miniconda/envs/pt1.0/bin/python 5_generate_diffurec_recall_result_vip.py --text_feat --image_feat",
    depends_on_past =False,
    dag=dag,
)

save_recall_to_hive = SparkSubmitOperator(
    task_id='save_recall_to_hive',
    dag=dag,
    **_config,
    application= '/data/gangyanyuan/terry/terry-recsys-2024/multi-interest/script/save_recall_to_hive.py',
    conn_id = "spark_local",
)
# save_recall_to_hive_v2 = SparkSubmitOperator(
#     task_id='save_recall_to_hive_v2',
#     dag=dag,
#     **_config,
#     application= '/data/gangyanyuan/terry/terry-recsys-2024/multi-interest/script/save_recall_to_hive_v2.py',
#     conn_id = "spark_local",
# )
# generate_diffurec_test_result = BashOperator(
#     task_id='generate_diffurec_test_result',
#     bash_command="cd /data/gangyanyuan/terry/terry-recsys-2024/multi-interest/script && /data/dev/miniconda/envs/pt1.0/bin/python 5_generate_diffurec_test_result.py --text_feat",
#     depends_on_past =False,
#     dag=dag,
# )
save_user_click_seq_to_hive = SparkSubmitOperator(
    task_id='save_user_click_seq_to_hive',
    dag=dag,
    **_config,
    application= '/data/gangyanyuan/terry/terry-recsys-2024/multi-interest/script/jx_lst_july/save_user_click_seq_to_hive.py',
    conn_id = "spark_local",
)

# modal embedding. 
update_text_embedding = BashOperator(
    task_id='update_text_embedding',
    bash_command="cd /data/gangyanyuan/terry/terry-recsys-2024/script && /data/dev/miniconda/envs/deepmatch/bin/python update_text_embedding_v2.py",
    depends_on_past =False,
    dag=dag,
)
update_content_embedding = BashOperator(
    task_id='update_content_embedding',
    bash_command="cd /data/gangyanyuan/terry/terry-recsys-2024/script && /data/dev/miniconda/envs/easyrec/bin/python update_content_embedding.py",
    depends_on_past =False,
    dag=dag,
)


# jx feed 
update_jx_feed_media = BashOperator(
    task_id='update_jx_feed_media',
    bash_command="cd /data/gangyanyuan/terry/terry-recsys-2024/multi-interest/script && /data/dev/miniconda/envs/recsys2/bin/python 0_1_update_feed_media.py",
    depends_on_past =False,
    dag=dag,
)
update_jx_feed_media_v2 = BashOperator(
    task_id='update_jx_feed_media_v2',
    bash_command="cd /data/gangyanyuan/terry/terry-recsys-2024/multi-interest/script && /data/dev/miniconda/envs/recsys2/bin/python 0_3_update_feed_media_v2.py",
    depends_on_past =False,
    dag=dag,
)
update_content_embedding_jx_feed = BashOperator(
    task_id='update_content_embedding_jx_feed',
    bash_command="cd /data/gangyanyuan/terry/terry-recsys-2024/script && /data/dev/miniconda/envs/easyrec/bin/python update_content_embedding_jx_feed.py",
    depends_on_past =False,
    dag=dag,
)
# i2i recommendation
generate_inference_dataset_i2i = BashOperator(
    task_id='generate_inference_dataset_i2i',
    bash_command="cd /data/gangyanyuan/terry/terry-recsys-2024/multi-interest/script/i2i && /data/dev/miniconda/envs/deepmatch/bin/python generate_inference_dataset_i2i.py",
    depends_on_past =False,
    dag=dag,
)
generate_diffurec_recall_result_i2i = BashOperator(
    task_id='generate_diffurec_recall_result_i2i',
    bash_command="cd /data/gangyanyuan/terry/terry-recsys-2024/multi-interest/script/i2i && /data/dev/miniconda/envs/pt1.0/bin/python generate_diffurec_recall_result_i2i.py --text_feat --image_feat",
    depends_on_past =False,
    dag=dag,
)

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

# for summary & content embedding
update_jx_lst_media_v2 = BashOperator(
    task_id='update_jx_lst_media_v2',
    bash_command="cd /data/gangyanyuan/terry/terry-recsys-2024/multi-interest/script && /data/dev/miniconda/envs/recsys2/bin/python 0_2_update_jx_lst_media_v2.py",
    depends_on_past =False,
    dag=dag,
)

kill_iPython_job 

update_jx_lst_media >> update_jx_feed_media >> update_text_embedding >> update_jx_lst_media_v2 >> update_content_embedding >> update_jx_feed_media_v2 >> update_content_embedding_jx_feed

# jx lst
update_jx_lst_media >> get_ecpm_aids >> generate_user_click_data  >> update_user_click_all_channelname_60days_012468 >> generate_diffurec_dataset_all_channelname_012468  >> get_pretrained_content_embedding_jx_lst >> get_pretrained_image_embedding_minicpm >> pca_text_image >> train_diffurec >> generate_inference_dataset_012468 >> generate_diffurec_recall_result_2468

generate_user_click_data >> update_user_click_all_channelname_60days_3579 >> generate_diffurec_dataset_all_channelname_3579 >> get_pretrained_content_embedding_sep >> get_pretrained_image_embedding_minicpm_sep >> pca_text_image_v2 >> train_llm_diffurec_v2 >> generate_inference_dataset_3579 >> generate_diffurec_recall_result_3579  >> train_diffurec_vip >> generate_inference_dataset_vip >> generate_diffurec_recall_result_vip

# vip
generate_inference_dataset_3579 >> generate_diffurec_dataset_all_channelname_vip >> get_pretrained_content_embedding_vip >> get_pretrained_image_embedding_minicpm_vip >> pca_text_image_vip


[generate_diffurec_recall_result_2468,generate_diffurec_recall_result_vip] >> save_recall_to_hive >> save_user_click_seq_to_hive

save_recall_to_hive >> generate_inference_dataset_i2i >> generate_diffurec_recall_result_i2i #>> save_i2i_recall_to_hive
# movie
# generate_user_click_data >> update_training_data_movie_tv_60days >> generate_diffurec_dataset_movie >> get_pretrained_text_embedding >> get_pretrained_image_embedding >> train_diffurec_movie_text >> generate_inference_dataset_movie >> generate_diffurec_recall_result_movie_text >> merge_xsimgcl_recall_movie >> save_movie_recall_to_hive