我正在尝试将Python项目部署到AWS lambda并使用无服务器。该项目有多个我创建的自定义包,以及一个导入约20个包的主要功能。我还使用numpy,scipy等python包。
现在排除开发缺陷需要3个多小时,并且此后未正确上传lambda函数,因此理想情况下,我想查看是否可以测试更快的部署,我知道可以离线测试,但我宁愿我认为应该在AWS上进行测试。我不确定我是否做错了什么。
这是我的yml文件现在的样子:
service: test-aws-lamnda
plugins:
- serverless-python-requirements
- serverless-plugin-optimize
custom:
pythonRequirements:
zip: true
dockerizePip: non-linux
provider:
name: aws
runtime: python3.6
stage: dev
region: us-west-2
package:
#individually: true #I tried to see if individually would be faster because i tried using plugin-optimize which requires individually but it didn't help
include:
- env/Lib/site-packages/**
- StudentPackage/
- SchoolPackage/
- GPAPackage/
- TeacherPackage/
- TestsPackage/
- ClassesPackage/
- StudentAttributes/
- ClassAttributes/
- TestAttributes/
- MainPackage/
- GlobalVariablesPackage/
.... [a few other packages]
- Students.jsonl
- Teachers.json
- Tests.json
exclude:
- TestFuncsPackage/
functions:
main:
handler: handler.main
events:
- http:
path: main
method: get
此外,我知道拥有这么多软件包真的很糟糕,并且这也是python不好的实践,重组该项目需要花费很多时间,目前还不值得。非常感谢。