无法使用BashOperator运行Python脚本。

0

【以下的问题经过翻译处理】 我需要使用BashOperator运行一个Python脚本。我把脚本放在S3存储桶的dags文件夹中,并使用BashOperator运行我的DAG。然而它显示错误:python3: can't open file 'hello_world.py': No such file or directory

我还注意到Airflow worker在一个临时脚本位置运行命令,例如 /tmp/airflowtmpx03mq_qp/run_scriptlolkuw_q。此路径在每个DAG运行时都会更改。在这种情况下,我该如何运行脚本?请帮我提供Managed Airflow中最简单的方法。谢谢。

profile picture
EXPERT
asked 6 months ago19 views
1 Answer
0

【以下的回答经过翻译处理】 你好!

放置在包含 DAG 的 S3 文件夹中的任何内容都将同步到 MWAA worker 上的 /usr/local/airflow/dags。因此,要运行名为“hello_world.py”的文件,您可以使用 bash 命令“python3 /usr/local/airflow/dags/hello_world.py”

谢谢!

profile picture
EXPERT
answered 6 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions