我使用bashOperator调用了现有的python脚本,但是在执行DAG之后没有打印输出,并且被认为是失败的。
这是气流的日志:
***读取本地文件:/home/test/airflow/logs/CallP/execution/2020-07-02T01:10:37.440062+00:00/1.log
[2020-07-02 10:41:04,068] {taskinstance.py:669} INFO - Dependencies all met for <TaskInstance: CallP.execution 2020-07-02T01:10:37.440062+00:00 [queued]>
[2020-07-02 10:41:04,094] {taskinstance.py:669} INFO - Dependencies all met for <TaskInstance: CallP.execution 2020-07-02T01:10:37.440062+00:00 [queued]>
[2020-07-02 10:41:04,095] {taskinstance.py:879} INFO -
--------------------------------------------------------------------------------
[2020-07-02 10:41:04,095] {taskinstance.py:880} INFO - Starting attempt 1 of 1
[2020-07-02 10:41:04,095] {taskinstance.py:881} INFO -
--------------------------------------------------------------------------------
[2020-07-02 10:41:04,111] {taskinstance.py:900} INFO - Executing <Task(BashOperator): execution> on 2020-07-02T01:10:37.440062+00:00
[2020-07-02 10:41:04,113] {standard_task_runner.py:53} INFO - Started process 86541 to run task
[2020-07-02 10:41:04,189] {logging_mixin.py:112} INFO - Running %s on host %s <TaskInstance: CallP.execution 2020-07-02T01:10:37.440062+00:00 [running]> test-HP-Z210-Workstation
[2020-07-02 10:41:04,219] {bash_operator.py:82} INFO - Tmp dir root location:
/tmp
[2020-07-02 10:41:04,220] {bash_operator.py:103} INFO - Temporary script location: /tmp/airflowtmpu511x1ra/execution3ydgjnkm
[2020-07-02 10:41:04,220] {bash_operator.py:115} INFO - Running command: python3 /home/test/airflow/scripts/CallTypes.py
[2020-07-02 10:41:04,226] {bash_operator.py:122} **INFO - Output:**
[2020-07-02 10:41:57,434] {bash_operator.py:128} INFO - Command exited with return code 1
[2020-07-02 10:41:57,446] {taskinstance.py:1145} ERROR - Bash command failed
Traceback (most recent call last):
File "/usr/local/lib/python3.8/dist-packages/airflow/models/taskinstance.py", line 983, in _run_raw_task
result = task_copy.execute(context=context)
File "/usr/local/lib/python3.8/dist-packages/airflow/operators/bash_operator.py", line 134, in execute
raise AirflowException("Bash command failed")
airflow.exceptions.AirflowException: Bash command failed
[2020-07-02 10:41:57,447] {taskinstance.py:1189} INFO - Marking task as FAILED.dag_id=CallP, task_id=execution, execution_date=20200702T011037, start_date=20200702T011104, end_date=20200702T011157
[2020-07-02 10:41:59,394] {logging_mixin.py:112} INFO - [2020-07-02 10:41:59,394] {local_task_job.py:103} INFO - Task exited with return code 1
dag = DAG(dag_id ='CallP',schedule_interval = None,tags = ['CallP'])
task = BashOperator(
task_id='execution',
dag=dag,
bash_command="python3 /home/test/airflow/scripts/CallTypes.py",
start_date=days_ago(2),
owner='airflow',
)