【发布时间】:2021-01-28 10:45:52
【问题描述】:
我无法执行第二个 arg 语句:
"python", "-c", "from main import foo;print(foo('hello'))"
我正在使用 Airflow 运算符 CloudBuildCreateBuildOperator 触发 Cloud Build。 触发 DAG 和 Cloud Build 均返回成功。
根据 Cloud Build 返回的日志消息,安装 requirements.txt 文件的第一个参数似乎可以工作:
Requirement already satisfied: setuptools>=40.3.0 in /usr/local/lib/python3.7/site-packages (from google-auth>=1.2->gcsfs>=0.6.2
我的功能是使用 gcsfs 包。我在问题中使用的功能只是为了演示。
在使用 Airflow 之前,我在 yaml 文件中进行了这项工作。 尝试了多种不同的方式来陈述论点,例如:
"args":["-c","pip install -V -r requirements.txt; python -c from main import foo;print(foo('hello'))"]
但现在在绕圈子。
我将非常感谢任何帮助使该 args 语句正常工作。
这是来自 DAG 的 CloudBuildCreateBuildOperator:
create_build_from_storage_body = {
"source": {
"repoSource": {
"projectId": "dev-6767",
"repoName": "bq-pipeline",
"branchName": "master",
}
},
"steps": [{
"name": "docker.io/library/python:3.7",
"entrypoint": "/bin/bash",
"args": ["-c", "pip install -V -r requirements.txt",
"python", "-c", "from main import foo;print(foo('hello'))"
],
}],
}
【问题讨论】:
-
嗨@BPsinoza 你能按照这个例子here中使用的模式试一试吗?如图所示,您似乎需要将 args 拆分为多个
args以便更好地执行。 -
嗨@gso_gabriel 感谢您的链接。该示例使用了 && ,它允许我链接命令。这现在有效:“args”:[“-c”,“pip install -r requirements.txt && python main.py”]
-
嗨@BSpnioza 很高兴听到它对你有帮助!你介意我发表我的评论 - 提供更多信息 - 作为答案,以便你接受吗?
-
嗨@gso_gabriel,请接受,很高兴接受。
-
我已经发布了。谢谢@BSpinoza!
标签: python google-cloud-platform yaml airflow google-cloud-build