The command which fails is:
/usr/local/bin/sam local invoke HelloWorldFunction --template /home/peter/Dropbox2/Dropbox/clothes_recco/production/bodyestimate/.aws-sam/build/template.yaml --event "/tmp/[Local] BodyEstimate-event109.json"
and it outputs an error:
{"errorMessage": "Unable to import module 'app': No module named 'bodyestimate'", "errorType": "Runtime.ImportModuleError", "requestId": "3b3bb307-9647-4171-99a6-24dae52b3b55", "stackTrace": []}END
My lambda function structure is:
bodyestimate/
bodyestimate/
template.yaml
packaged.yaml
app.py
requirements.txt
__init__.py
Dockerfile
test/
unit/
test_handler.py
The pytests pass when I run the test_handler.py which imports the app.py. It seems to me that sam invoke does not find the main app function when the project is ran as a programme.
Any thoughts on how I can get the sam local invoke to recognise the app in app.py?
The problem was to do with the app file not being copied into the container.
Adding a '''COPY app.py ./''' into the docker file solved the problem!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.