idl_subdag.py 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #!/usr/bin/env python
  2. #coding=utf-8
  3. from airflow.models import DAG
  4. from airflow.operators.bash_operator import BashOperator
  5. def idl_subdag(parent_dag_name, child_dag_name, args):
  6. idl_subdag = DAG(
  7. dag_id='%s.%s' % (parent_dag_name, child_dag_name),
  8. default_args=args,
  9. schedule_interval='@daily',
  10. )
  11. # 收视率趋势
  12. BashOperator(
  13. task_id='idl_trending-task',
  14. bash_command='cd /Users/wudancheng/huoju/code/huoju_fty/py_script; python idl_trending.py',
  15. default_args=args,
  16. dag=idl_subdag,
  17. )
  18. # 类型统计
  19. BashOperator(
  20. task_id='idl_tv_station_type_stat-task',
  21. bash_command='cd /Users/wudancheng/huoju/code/huoju_fty/py_script; python idl_tv_station_type_stat.py',
  22. default_args=args,
  23. dag=idl_subdag,
  24. )
  25. # 收视指数统计
  26. BashOperator(
  27. task_id='idl_tv_station_ratings_index_stat-task',
  28. bash_command='cd /Users/wudancheng/huoju/code/huoju_fty/py_script; python idl_tv_station_ratings_index_stat.py',
  29. default_args=args,
  30. dag=idl_subdag,
  31. )
  32. # 电视台推荐
  33. BashOperator(
  34. task_id='idl_tv_station_recommend-task',
  35. bash_command='cd /Users/wudancheng/huoju/code/huoju_fty/py_script; python idl_tv_station_recommend.py',
  36. default_args=args,
  37. dag=idl_subdag,
  38. )
  39. # 电视台收视率统计
  40. BashOperator(
  41. task_id='idl_ad_television_stat-task',
  42. bash_command='cd /Users/wudancheng/huoju/code/huoju_fty/py_script; python idl_ad_television_stat.py',
  43. default_args=args,
  44. dag=idl_subdag,
  45. )
  46. # 备案发行数据
  47. BashOperator(
  48. task_id='idl_ad_tv_record_distribution-task',
  49. bash_command='cd /Users/wudancheng/huoju/code/huoju_fty/py_script; python idl_ad_tv_record_distribution.py',
  50. default_args=args,
  51. dag=idl_subdag,
  52. )
  53. # idl_tv_station_rank
  54. BashOperator(
  55. task_id='idl_tv_station_rank-task',
  56. bash_command='cd /Users/wudancheng/huoju/code/huoju_fty/py_script; python idl_tv_station_rank.py',
  57. default_args=args,
  58. dag=idl_subdag,
  59. )
  60. return idl_subdag