【发布时间】:2019-04-05 14:11:04
【问题描述】:
我是 Airflow 的新手,正在努力使用 BashOperator。我想在我的 dag.py 中使用 bash 操作符访问 shell 脚本。
我检查了: How to run bash script file in Airflow 和 BashOperator doen't run bash file apache airflow
关于如何通过 bash 操作符访问 shell 脚本。
这就是我所做的:
cmd = "./myfirstdag/dag/lib/script.sh "
t_1 = BashOperator(
task_id='start',
bash_command=cmd
)
在运行我的食谱并检查气流时,我收到以下错误:
[2018-11-01 10:44:05,078] {bash_operator.py:77} INFO - /tmp/airflowtmp7VmPci/startUDmFWW: line 1: ./myfirstdag/dag/lib/script.sh: No such file or directory
[2018-11-01 10:44:05,082] {bash_operator.py:80} INFO - Command exited with return code 127
[2018-11-01 10:44:05,083] {models.py:1361} ERROR - Bash command failed
不知道为什么会这样。任何帮助将不胜感激。
谢谢!
编辑注意:我假设它在某些气流 tmp 位置而不是我提供的路径中搜索。但是如何让它搜索正确的路径。
【问题讨论】:
-
./myfirstdag/dag/lib/script.sh是否相对于$AIRFLOW_HOME/dags目录? -
@SergiyKolesnikov 不,不是。 /myfirstdag/dag/lib/ 是不同的路径,而 $AIRFLOW_HOME 在我尝试时给出了不同的路径。
-
那么
script.sh的绝对路径是什么? -
@SergiyKolesnikov 这个 /home/notebook/work/myfirstdag/dag/lib/ 。我也试过给这个。它会引发同样的错误。
-
显然,它正在创建的 tmp 目录中进行搜索。这就是我从源代码中理解的。 github.com/apache/incubator-airflow/blob/… 。不知道如何让它在我给的路径中搜索。
标签: python bash airflow directed-acyclic-graphs