我有这段代码用于在docker内部执行python脚本的气流:
a02_retrieve_2 = SSHExecuteOperator(
task_id='a02_retrieve_2',
ssh_hook=sshHook,
dag=dag,
bash_command= 'docker exec myDocker -i bash -c " /opt/conda/bin/python aretrieve_2.py --myarg 45 --myarg 35 " '
)
不幸的是,它不起作用。
但是,不带参数的版本有效。
a02_retrieve_2 = SSHExecuteOperator(
task_id='a02_retrieve_2',
ssh_hook=sshHook,
dag=dag,
bash_command= 'docker exec myDocker -i bash -c " /opt/conda/bin/python aretrieve_2.py " '
)
错误是:
Python script starts to run but Airflow is unable to catch up the python script parameters...
如何使带有python脚本参数的版本有效?
这和神社模板有关吗?
BashOperator doen't run bash file apache airflow
最佳答案
我通过查看bashoperator的源代码找到了答案:
这使用popen
self.log.info("Running command: %s", bash_command)
sp = Popen(
['bash', fname],
stdout=PIPE, stderr=STDOUT,
cwd=tmp_dir, env=self.env,
preexec_fn=pre_exec)
https://airflow.incubator.apache.org/_modules/bash_operator.html
关于python - 在Airflow的docker内部运行python脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50036712/