I try to wrap an R based application that is deployed to a docker container. I changed the base image to lambda/python3.9 and added another app with its own Dockerfile. This contains a simple python script as the handler for the function. In this handler I call the code to run the R script and upload the result to S3. Now when I'm testing locally everything works fine. But when I push the image to ECR and deploy the container as a Lambda Function I get following error:
{
"errorMessage": "Unable to import module 'app': No module named 'app'",
"errorType": "Runtime.ImportModuleError",
"requestId": "1a7fa818-62e4-4374-8318-625b15e2ae8a",
"stackTrace": []
}
Further logs of the AWS call:
2021-09-25T17:11:32.570+02:00 START RequestId: 1a7fa818-62e4-4374-8318-625b15e2ae8a Version: $LATEST
2021-09-25T17:11:32.571+02:00 [ERROR] Runtime.ImportModuleError: Unable to import module 'app': No module named 'app' Traceback (most recent call last):
2021-09-25T17:11:32.574+02:00 END RequestId: 1a7fa818-62e4-4374-8318-625b15e2ae8a
2021-09-25T17:11:32.574+02:00 REPORT RequestId: 1a7fa818-62e4-4374-8318-625b15e2ae8a Duration: 1.40 ms Billed Duration: 2395 ms Memory Size: 3200 MB Max Memory Used: 48 MB Init Duration: 2393.47 ms
Command to run the container locally:
docker run -e AWS_SECRET_ACCESS_KEY=XXX -e AWS_ACCESS_KEY_ID=YYY -p 9000:8080 palmid-lambda:latest
Output of the local run:
EY=XXXX -e AWS_ACCESS_KEY_ID=YYYY -p 9000:8080 palmid-lambda:latest
time="2021-09-25T14:29:42.318" level=info msg="exec '/var/runtime/bootstrap' (cwd=/home/palmid, handler=)"
time="2021-09-25T14:29:47.899" level=info msg="extensionsDisabledByLayer(/opt/disable-extensions-jwigqn8j) -> stat /opt/disable-extensions-jwigqn8j: no such file or directory"
time="2021-09-25T14:29:47.899" level=warning msg="Cannot list external agents" error="open /opt/extensions: no such file or directory"
START RequestId: 1b867a67-e778-4418-9139-ff1123331b34 Version: $LATEST
... application logs
Command to call the Lambda function locally:
curl -XPOST "http://localhost:9000/2015-03-31/functions/function/invocations" -d '{ "sequence": ">SRR9968562_waxsystermes_virus_microassembly\nPIWDRVLEPLMRASPGIGRYMLTDVSPVGLLRVFKEKVDTTPHMPPEGMEDFKKASKEVE\nKTLPTTLRELSWDEVKEMIRNDAAVGDPRWKTALEAKESEEFWREVQAEDLNHRNGVCLR\nGVFHTMAKREKKEKNKWGQKTSRMIAYYDLIERACEMRTLGALNADHWAGEENTPEGVSG\nIPQHLYGEKALNRLKMNRMTGETTEGQVFQGDIAGWDTRVSEYELQNEQRICEERAESED\nHRRKIRTIYECYRSPIIRVQDADGNLMWLHGRGQRMSGTIVTYAMNTITNAIIQQAVSKD\nLGNTYGRENRLISGDDCLVLYDTQHPEETLVAAFAKYGKVLKFEPGEPTWSKNIENTWFC\nSHTYSRVKVGNDIRIMLDRSEIEILGKARIVLGGYKTGEVEQAMAKGYANYLLLTFPQRR\nNVRLAANMVRAIVPRGLLPMGRAKDPWWREQPWMSTNNMIQAFNQIWEGWPPISSMKDIK\nYVGRAREQMLDST", "hash": "132xx"}'
Base Image built with: https://github.com/ababaian/palmid
Building with following Python Code: https://github.com/ababaian/palmid-lambda
__init__.pyfile on same level asapp.pywithin docker container