Airflow 为什么看不到它的 HOME 文件夹?

huangapple go评论53阅读模式
英文:

Why is Airflow not seeing it's HOME folder?

问题

Airflow实例设置时遇到问题,Airflow似乎无法看到它的$AIRFLOW_HOME文件夹。

使用官方Airflow镜像(2.6.1/py3.8)进行设置,默认的$AIRFLOW_HOME/opt/airflow/。我挂载了一个本地文件夹- ./files:/opt/airflow/files,但出于某种原因,这似乎不起作用,Airflow无法运行该文件夹中的任务。

使用BashOperator,我可以使此任务运行:

bash_command='cd /opt/airflow/files/my-repo/ && python taskpy'

但不可以使用这个:

bash_command=' python files/my-repo/task.py'

我以为将任何添加到$AIRFLOW_HOME文件夹的内容都会被Airflow映射并可以立即使用。这是不正确的吗?

我注意到一些奇怪的事情,当我尝试从Airflow用户访问此环境变量($AIRFLOW_HOME)时,我会收到权限被拒绝的错误:

(airflow)$AIRFLOW_HOME
/bin/sh: 1: /opt/airflow: Permission denied

我是否遗漏了什么?

英文:

I'm setting up an Airflow instance but for some reason Airflow is not seeing it's $AIRFLOW_HOME folder.

The setup is using the official Airflow image (2.6.1/py3.8) with the default $AIRFLOW_HOME being /opt/airflow/. I mounted a local folder - ./files:/opt/airflow/files but for some reason this isn't working as inteded and Airflow is not running the tasks from this folder.

Using a BashOperator i can get this task to run:

bash_command='cd /opt/airflow/files/my-repo/ && python taskpy'

But not this one:

bash_command=' python files/my-repo/task.py'

I was under the impresion that anything added to the $AIRFLOW_HOME folder would be mapped by Airflow and could be used right away. Is this wrong?

Something strange that i've noticed is that when i try to access this env variable ($AIRFLOW_HOME) from the airflow user i get a Permission denied error:

(airflow)$AIRFLOW_HOME
/bin/sh: 1: /opt/airflow: Permission denied

Is there anything i'm missing?

答案1

得分: 1

如果执行命令echo $AIRFLOW_HOME没有显示任何输出,意味着环境变量AIRFLOW_HOME要么未设置,要么设置为空值。

要设置AIRFLOW_HOME变量,您可以执行以下操作之一:

  1. 在终端中显式设置它:

    export AIRFLOW_HOME=/path/to/airflow/home
    

    /path/to/airflow/home替换为您要设置Airflow主目录的实际路径。

  2. export命令添加到您的shell配置文件(例如,对于Bash是~/.bashrc),以使其在会话之间持久存在:

    echo "export AIRFLOW_HOME=/path/to/airflow/home" >> ~/.bashrc
    source ~/.bashrc
    

    再次替换/path/to/airflow/home为所需的路径。

设置AIRFLOW_HOME变量后,您可以通过再次运行echo $AIRFLOW_HOME来验证是否已正确配置它。它应该显示您分配给它的路径。请记住,在步骤2中修改配置文件后,重新启动终端或源配置文件以使更改生效。

英文:

If executing the command echo $AIRFLOW_HOME does not display any output, it means that the environment variable AIRFLOW_HOME is either not set or is set to an empty value.

To set the AIRFLOW_HOME variable, you can do one of the following:

  1. Set it explicitly in the terminal:

    export AIRFLOW_HOME=/path/to/airflow/home
    

    Replace /path/to/airflow/home with the actual path where you want to set your Airflow home directory.

  2. Add the export command to your shell configuration file (e.g., ~/.bashrc for Bash) to make it persist across sessions:

    echo "export AIRFLOW_HOME=/path/to/airflow/home" >> ~/.bashrc
    source ~/.bashrc
    

    Again, replace /path/to/airflow/home with the desired path.

After setting the AIRFLOW_HOME variable, you can verify if it is properly configured by running echo $AIRFLOW_HOME again. It should display the path you assigned to it. Remember to restart your terminal or source the configuration file if you modified it in step 2 for the changes to take effect.

huangapple
  • 本文由 发表于 2023年6月9日 02:53:32
  • 转载请务必保留本文链接:https://go.coder-hub.com/76434908.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定