import airflow from airflow import DAG from airflow.operators.bash import BashOperator from airflow.operators.python import PythonOperator from datetime import timedelta
#------------------------------------------------------------------------------- # these args will get passed on to each operator # you can override them on a per-task basis during operator initialization
➜ airflow tasks list example_hello_world_dag [2021-01-24 20:00:02,162] {dagbag.py:440} INFO - Filling up the DagBag from /Users/blair/airflow/dags [2021-01-24 20:00:02,200] {example_kubernetes_executor_config.py:174} WARNING - Could not import DAGs in example_kubernetes_executor_config.py: No module named 'kubernetes' [2021-01-24 20:00:02,200] {example_kubernetes_executor_config.py:175} WARNING - Install kubernetes dependencies with: pip install apache-airflow['cncf.kubernetes']
date_task hello_task sleep_task
2.1 测试 date_task
1
➜ airflow tasks test example_hello_world_dag date_task 20210124
2.2 测试 hello_task
1 2 3 4 5 6 7
AIRFLOW_CTX_DAG_EMAIL=779844881@qq.com AIRFLOW_CTX_DAG_OWNER=blair.chan AIRFLOW_CTX_DAG_ID=example_hello_world_dag AIRFLOW_CTX_TASK_ID=hello_task AIRFLOW_CTX_EXECUTION_DATE=2021-01-24T00:00:00+00:00 [2021-01-24 20:05:03,473] {python.py:118} INFO - Done. Returned value was: Hello world! [2021-01-24 20:05:03,480] {taskinstance.py:1142} INFO - Marking task as SUCCESS. dag_id=example_hello_world_dag, task_id=hello_task, execution_date=20210124T000000, start_date=20210124T120503, end_date=20210124T120503
2.3 测试 sleep_task
1 2 3 4 5
/var/folders/58/kj1q13hs3j52hwvj3t2g2plh0000gp/T [2021-01-24 20:04:30,923] {bash.py:158} INFO - Running command: sleep 5 [2021-01-24 20:04:30,929] {bash.py:169} INFO - Output: [2021-01-24 20:04:35,942] {bash.py:177} INFO - Command exited with return code 0 [2021-01-24 20:04:35,972] {taskinstance.py:1142} INFO - Marking task as SUCCESS. dag_id=example_hello_world_dag, task_id=sleep_task, execution_date=20210124T000000, start_date=20210124T120430, end_date=20210124T120435
Checking if Disqus is accessible...