question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

dnachisel not working on AWS Lambda

See original GitHub issue

Importing the library doesn’t seem to work in AWS Lambda.

Something like the following:

import dnachisel as dc

def lambda_handler(event, context):  
    return "test"

When run on lambda throws:

{
  "errorMessage": "Unable to import module 'lambda_function': cannot import name '_aligners' from partially initialized module 'Bio.Align' (most likely due to a circular import) (/var/task/Bio/Align/__init__.py)",
  "errorType": "Runtime.ImportModuleError",
  "stackTrace": []
}

Everything works fine if I mock the lambda locally. I uploaded the lambda code and the dependencies as a zip file, but also tried uploading dnachisel as a lambda layer and got the same error.

Python version: 3.8 dnachisel version: 3.2.9

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
guzmanvigcommented, May 6, 2022

Unfortunately we can’t use code build as it would imply changing the whole infrastructure of our project. However, you are right, the problem is with biopython. I tried the following code and got the same issue.

from Bio.Align import _aligners

def lambda_handler(event, context):
    return "test"

Thank you!

0reactions
veghpcommented, May 6, 2022

I have one more suggestion. I believe this problem is not related to DNA Chisel, but Biopython.

When we import /site-packages/Bio/Align/__init__.py it starts with

import sys

from Bio.Align import _aligners

which is the line that causes problem according to your error. This is an .so file, and these discussions suggest “Problem is solved by deploying the package through AWS codeBuild”:

https://stackoverflow.com/questions/64450587/error-trying-to-import-pysftp-in-lambda-cannot-import-name-bcrypt-from-parti

https://github.com/pymupdf/PyMuPDF/issues/430#issuecomment-576231408

Read more comments on GitHub >

github_iconTop Results From Across the Web

DNA Chisel - a versatile sequence optimizer
DNA Chisel (complete documentation here) is a Python library for optimizing DNA sequences with respect to a set of constraints and optimization objectives....
Read more >
Operating Lambda: Isolating and resolving issues
This post walks through troubleshooting application issues in an example walkthrough and monitoring Lambda code storage usage.
Read more >
dnachisel - PyPI
DNA Chisel (complete documentation here) is a Python library for optimizing DNA sequences with respect to a set of constraints and optimization objectives....
Read more >
multiprocessing.SemLock is not implemented when running ...
As far as I can tell, multiprocessing won't work on AWS Lambda because the execution environment/container is missing /dev/shm - see ...
Read more >
Our summer 2019 interns and their adventures in DNA ...
To make this work, I integrated the open-source DNA Chisel library into Benchling ... Our custom integrations are deployed on AWS Lambda, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found