【发布时间】:2019-05-03 15:44:08
【问题描述】:
我正在尝试通过 Airlfow 运行 .jar DAG
我有一个.sh 文件,它调用了执行相关jar 所需的所有库,但我仍然面临BashOperator 的相同错误,这是.py 文件的内容:
from airflow import DAG
from airflow.operators.bash_operator import BashOperator
from datetime import datetime
import os
import sys
create_command = "/home/user/Images/Job senority new colecttion /Skill/Skill_run.sh "
default_args = {
'owner': 'me',
'depends_on_past': False,
'start_date': datetime(2019, 5, 03),
'email_on_failure': False,
'email_on_success': False,
'provide_context': True
}
dag = DAG(dag_id='Skill_batch', default_args=default_args)
t1 = BashOperator(
task_id= 'Batch_file_sh',
bash_command='create_command',
dag=dag
)
t2 = BashOperator(
task_id='task_1',
bash_command='echo Hello, This is my first DAG in Airflow!',
dag=dag
)
t3 = BashOperator(
task_id = 'runjar',
dag = dag,
bash_command = 'java -cp /home/user/Images/Job senority new colecttion /Skill/skill.jar '
t2 >> t1 >> t3
`
这是来自气流 ui 的日志:
[2019-05-08 15:33:24,523] {bash_operator.py:104} INFO - Temporary script location: /tmp/airflowtmpIghU_M/Batch_file_shPuscAS
[2019-05-08 15:33:24,523] {bash_operator.py:114} INFO - Running command: create_command
[2019-05-08 15:33:24,527] {bash_operator.py:123} INFO - Output:
[2019-05-08 15:33:24,528] {bash_operator.py:127} INFO - /tmp/airflowtmpIghU_M/Batch_file_shPuscAS: ligne 1: create_command : commande introuvable
[2019-05-08 15:33:24,528] {bash_operator.py:131} INFO - Command exited with return code 127
[2019-05-08 15:33:24,532] {__init__.py:1580} ERROR - Bash command failed
Traceback (most recent call last):
File "/home/user/.local/lib/python2.7/site-packages/airflow/models/__init__.py", line 1441, in _run_raw_task
result = task_copy.execute(context=context)
File "/home/user/.local/lib/python2.7/site-packages/airflow/operators/bash_operator.py", line 135, in execute
raise AirflowException("Bash command failed")
AirflowException: Bash command failed
我检查了 DAG 是否在 AIRFLOW_HOME/dags 存储库下,并允许使用 chmod +x file.sh 执行 .sh 和 .jar 文件
我也尝试了一些答案here,但同样的情况气流无法识别.jar 路径目录。
【问题讨论】:
-
cmd是特定于 Windows 的。你好像是在linux上吧? -
对,对不起,只是在复制代码时出错了,是的,我在 Ubuntu 16.04 和
Airflow versionv1.10.3 上 -
如果仍然存在问题,请更正您的代码,因为不清楚是否已解决?
-
@bosnjak 它还没有旋转,我确实检查了代码中的错误
-
但现在错误部分与代码无关。该错误仍然与您删除的缺少的
cmd命令有关。
标签: python bash jar sh airflow