Kyle Boucher
09/07/2021, 7:20 AMhandler.py and service.py
The handler.py imports the service.py as normal (import service) so that it can delegate the work off to that service.
The issue is that when running with npx sst start and in the aws console they both error with "ModuleNotFoundError: No module named 'service'",
I made a test to replicate the issue from SST code:
new sst.Function(this, "testFunc", {
handler: "services/test/handler.process_job",
srcPath: "src",
layers: [dbDriverLayer],
role: functionRole,
tracing: Tracing.ACTIVE
});
However, if I create a function within aws or upload my own package not through sst, the exact same code works fine (see attached image).
Any ideas on what SST is doing differently to package and deploy lambdas that would break the python imports?thdxr
09/07/2021, 1:31 PMsrcFrank
servicer?Kyle Boucher
09/07/2021, 9:00 PMimport service But here's the code for handler.py and service.pythdxr
09/07/2021, 9:05 PMservices/test/ and handler to handler.process_jobKyle Boucher
09/07/2021, 9:59 PMthdxr
09/07/2021, 10:01 PMKyle Boucher
09/07/2021, 10:02 PMfrom services.x import service as per the folder structure but as my module x contained a - it didn't work. When I recreated the problem with the test function I did not retest this style.
eg. users-api would indicate an import of services.users_api which didn't work. removing the - allows the import to find it locally and in aws.thdxr
09/07/2021, 10:02 PMsrc. Is it possible that python needs a different import style for relative imports?Kyle Boucher
09/07/2021, 10:03 PMFrank
require service work? (ie. did it work in Serverless Framework)