【问题标题】:Airflow - BashOperator - error running 2 CLI commandsAirflow - BashOperator - 运行 2 个 CLI 命令时出错
【发布时间】:2021-03-29 08:25:34
【问题描述】:

我使用的是 Ubuntu 20.04 和 Airflow 2.0.1。

我在 DAG 中有 BashOperator 任务,如下所示:

proxy_update_getProxies = BashOperator(
    task_id='proxy_update_getProxies',
    bash_command="scripts/proxies-update-get.sh",
    dag=dag)

scripts 文件夹位于 dag 文件夹中,因此根据文档应该可以这样运行它。

proxies-update-get.sh 脚本包含 2 行:

proxy-lists updateGeoIpData --license-key Y00qKC2A9ZoWVXJW
proxy-lists getProxies --protocols="https" --output-format="txt" --output-file="httpsproxies.txt"

proxy-listsnmp 包,可以使用 CLI 中的这两个命令运行以更新和获取代理列表。 脚本在任何文件夹中都可以正常工作,因此 $PATH 应该没有问题,但我收到此错误:

can't open file 'proxy-lists': [Errno 2] No such file or directory

我做错了什么?

【问题讨论】:

  • 尝试使用proxy-lists 的完整路径和/或./proxy-lists 运行。如果其中任何一个有效,您就知道这是$PATH 的问题。
  • 请记住,您的$PATH 设置可能不会转移到BashOperator。我不知道操作员是如何工作的(我希望它确实会考虑您的路径设置),但这可能是一个问题。
  • 对于“新”脚本/包,与我的第一条评论相同的问题/检查?
  • 我不太了解 npm,但是“运行”包听起来很奇怪:通常,一个人使用/导入包,并运行一个使用包的(包装器)脚本。
  • 气流 bash 用户无权访问代理列表。它没有看到安装,要么与它共享它,要么你可以使用安装本身启动 bash 脚本,然后你可以运行它。

标签: python bash npm airflow directed-acyclic-graphs


【解决方案1】:

谢谢@00@PeterRing

我刚刚在我的 bash 脚本中使用了节点 CLI 脚本的完整路径,它运行良好:

/home/username/.nvm/versions/node/v14.16.0/lib/node_modules/proxy-lists/cli.js updateGeoIpData --license-key hshshhshshshsh
/home/username/.nvm/versions/node/v14.16.0/lib/node_modules/proxy-lists/cli.js getProxies --protocols="https" --output-format="txt" --output-file="/home/username/airflow/dags/scripts/httpsproxies.txt"

【讨论】:

    猜你喜欢
    • 2017-06-28
    • 2022-10-31
    • 1970-01-01
    • 1970-01-01
    • 2022-08-18
    • 2021-12-31
    • 2022-08-19
    • 1970-01-01
    • 2018-11-20
    相关资源
    最近更新 更多