aws-samples / aws-samples/aws-textract-document-data-extraction-platform
"No module named ...._python_runtime" error happened when lambda running
- Dominant language
- HTML
- Stars
- 14
- Forks
- 3
- PR merge metrics
- No merged PRs in 30d
Description
Got the below run time error when lambda function running in AWS: "_[ERROR] Runtime.ImportModuleError: Unable to import module 'aws_document_extraction_platform_api_python_handlers.get_metrics': No module named 'aws_document_extraction_platform_api_python_runtime' Traceback (most recent call last):_"
And looks like the issue caused by the folder of "aws_document_extraction_platform_api_python_runtime" not included in the folder of "packages/lib/dist/lambda"
After inserting the below codes into .projerc.ts, the issue fixed in my testing:
// this line code to resolve the ...python_runtime dependencies for step functions
```
pythonLibrary.packageTask.exec(
`cp -r ${path.join('../api/generated/runtime/python/aws_document_extraction_platform_api_python_runtime')} dist/lambda/`
);
```
// this line code to resolve the ...python_runtime dependencies for api handlers
```
api.handlers.python!.packageTask.exec(
`cp -r ${path.join('../../generated/runtime/python/aws_document_extraction_platform_api_python_runtime')} dist/lambda/`
);
```
Contributor guide
Research direction
Start in .projerc.ts and inspect how packages/lib/dist/lambda is assembled for the AWS Lambda handlers and step functions. Reproduce the reported import failure, verify that aws_document_extraction_platform_api_python_runtime is included in the deployment folder, and confirm the get_metrics handler loads successfully.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, python, typescript
- Domain
- backend, cloud
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100