【发布时间】:2020-07-13 11:43:38
【问题描述】:
我正在使用 Fn Project 作为 Oracle Cloud Functions 的一部分,我希望包含一些我自己编写的帮助函数,这些函数目前在其他一些程序中使用。我想包含这些函数,而不必将它们复制并粘贴到我的源代码中,而且我觉得有一种方法可以做到这一点,但我还没有找到。
这是我的目录结构。名称已更改,以便于理解。
- helper
- foo.py
- other
- example.py
- functions
- myfunc
- func.py
- func.yaml
- requirements.txt
目前,在example.py 我有以下内容:
from helper import foo
...
foo.bar()
当我写 func.py 时,我写了同样的东西,但是当我运行 fn deploy -app test_app 然后 fn invoke test_app myfunc 它在 import 语句上出错(我运行基本的 hello world 函数,顶部是 from helper import foo:
Error invoking function. status: 502 message: function failed
我的第一反应是将helper 放在 requirements.txt 文件中,但这仅适用于pip 包。如何确保包含我自己的代码?
任何帮助将不胜感激!
更新
到目前为止,我唯一的解决方案是将我的代码复制并粘贴到源文件中,这不是很容易维护。
【问题讨论】:
标签: python docker kubernetes libraries fn