Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-cloud-platform/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
气流云构建操作符未执行python函数_Python_Google Cloud Platform_Yaml_Airflow_Google Cloud Build - Fatal编程技术网

气流云构建操作符未执行python函数

气流云构建操作符未执行python函数,python,google-cloud-platform,yaml,airflow,google-cloud-build,Python,Google Cloud Platform,Yaml,Airflow,Google Cloud Build,我无法执行第二条arg语句: "python", "-c", "from main import foo;print(foo('hello'))" 我正在使用气流操作符CloudBuildCreateBuildOperator触发云构建。 触发DAG和云构建都返回成功 安装requirements.txt文件的第一个参数根据Cloud Build返回的日志消息显示正常工作: Requirement already satisfied:

我无法执行第二条arg语句:

"python", "-c", "from main import foo;print(foo('hello'))"
我正在使用气流操作符CloudBuildCreateBuildOperator触发云构建。 触发DAG和云构建都返回成功

安装requirements.txt文件的第一个参数根据Cloud Build返回的日志消息显示正常工作:

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'))"
    ],
  }],
}

如本例所述,使用Python链接命令和发送多个
arg
的最佳方法是在它们之间添加一个
&

下面是如何使用此格式发送命令链的参数的示例

#testing1
steps:
- name: 'docker.io/library/python:3.7'
  id: Test
  entrypoint: /bin/sh
  args:
  - -c
  - 'pip install pytest && pip install -r requirements.txt && pytest test/*_test.py'
- name: gcr.io/google.com/cloudsdktool/cloud-sdk

这样,就可以在Cloud Build触发器中使用多个参数。

Hi@BPsinoza您能按照本例中使用的模式尝试一下吗?如图所示,您似乎需要将arg拆分为多个
arg
,以便更好地执行。Hi@gso_gabriel感谢您的链接。该示例使用了&&来链接命令。现在可以使用了:“args”:[“-c”,“pip安装-r requirements.txt&&python main.py”]Hi@BSpnioza很高兴听到它对您有所帮助!你介意我发表我的评论,提供更多信息,作为你可以接受的答案吗?嗨@gso_gabriel,请接受,很高兴接受。我已经发布了。谢谢@BSpinoza!