【发布时间】:2019-10-31 08:52:56
【问题描述】:
我正在处理一个包含许多小任务的项目。其中一些任务是相关的,需要重叠的 api。
task_1/
main.py
task_2/
main.py
apis/
api_1/
api_2/
api_3/
test/
test_api_1.py
test_api_2.py
test_task_1.py
test_task_2.py
test_task_3.py
例如,task_1 需要 api_1 和 api_3,而 task_2 需要 api_1 和 api_2。起初我尝试使用 Google Cloud Functions 来执行这些任务,但我遇到了GCF needs local dependencies installed in the same folder as the task 的问题。这意味着将代码从api_1 复制到task_1。此外,由于 GCF 进行导入的方式,本地测试会变得更加复杂(与 .mylocalpackage.myscript 相反):
然后您可以使用本地依赖项 mylocalpackage 中的代码:
from mylocalpackage.myscript import foo
有没有办法构建我的代码库以更轻松地部署 GCF?由于我的要求,我无法将每个 API 部署为自己的 GCF。 Google Cloud Run 会解决我的问题吗?
谢谢!
【问题讨论】:
标签: python-3.x google-cloud-platform google-cloud-functions google-cloud-run