【发布时间】:2020-09-15 00:22:38
【问题描述】:
我的目录结构如下所示:
src/
main.py
requirements.txt
由于似乎没有any configurability 围绕在哪里寻找requirements.txt,我已经辞职在外部目录中运行gcloud functions deploy,我希望--entry-point 标志可能会给我在src 内定位main.py 有一些回旋余地。不幸的是,它似乎只定义了一个方法名。
那么除了强制main.py 和requirements.txt 在同一个目录中之外,还有什么方法可以使这项工作?
作为参考,我尝试运行的命令和相应的错误消息:
gcloud functions deploy refresh_classes --entry-point main --runtime python37 --trigger-resource send_refresh --trigger-event google.pubsub.topic.publish --timeout 540s
Deploying function (may take a while - up to 2 minutes)...failed.
ERROR: (gcloud.functions.deploy) OperationError: code=3, message=Function failed on loading user code. Error message: File main.py that is expected to define function doesn't exist
【问题讨论】:
-
只是好奇,你想用“推荐”的目录结构来避免什么?或者您的项目需要以这种方式构建的原因是什么?
-
另外,
--source选项允许您从默认(当前目录)更改源目录,但它仍然希望main.py和requirements.txt文件都在该目录中。 -
@DustinIngram 老实说,我刚接触云功能,不知道有推荐的目录结构
-
另外,我有一个在
main.py中引用的配置文件,这在云功能中也不允许吗? @DustinIngram -
您可以根据需要添加任意数量的其他文件。唯一的要求是
main.py文件和requirements.txt文件(如果要安装依赖项),位于同一目录中。
标签: python google-cloud-platform google-cloud-functions gcloud