AWS Lambdas for Simularium
- 9/8/2021
- We added new Makefile scripts to carry out some routine AWS tasks via the command line (see "Commands You Need to Know" below).
- We published the cellpack converter Lambda and verified that we can use it to convert CellPack data to a Simularium file through a REST API. The Lambda and the API configuration are under the aics-ac AWS account, in the region us-west-2. The API Gateway API is named cellpack-API.
- In order to keep the simulariumio layer under the size limit, we had to remove numpy and Pandas from the simulariumio package and attach the SciPy and Pandas layers to the Lambda separately. Pandas layer ARN:
arn:aws:lambda:us-west-2:770693421928:layer:Klayers-python38-pandas:38
- We started to write a Lambda function for converting Readdy files but realized that the converter needs a filepath in a local operating system as an input, as do the other converters. We need to think more about the best way to handle this issue.
- Store values and retain the prior value in memory
- ... some other functionality
- Install AWS CLI
- Install Conda
- create a virtual env:
conda create -n simularium-lambdas python=3.8
conda activate simularium-lambdas
pip install -e .[dev]
- Configure user
make build-simulariumio-layer
: installs a fresh version of simulularimio insimulariumio-layer/lib/python3.8/site-packages
make publish-simulariumio-layer
: will create a new layer version and upload the new version of simulariumio to aws
- the publish layer command will print out the new ARN for the layer
make update-lambda-config function=smoldyn simulariumio_arn=[ARN from publish script]
. This will update the smoldyn lambda function to use this new layer.
Stable Release: pip install simularium_lambdas
Development Head: pip install git+https://github.com/allen-cell-animated/simularium_lambdas.git
For full package documentation please visit allen-cell-animated.github.io/simularium_lambdas.
See CONTRIBUTING.md for information related to developing the code.
-
pip install -e .[dev]
This will install your package in editable mode with all the required development dependencies (i.e.
tox
). -
make build
This will run
tox
which will run all your tests in both Python 3.7 and Python 3.8 as well as linting your code. -
make clean
This will clean up various Python and build generated files so that you can ensure that you are working in a clean environment.
-
make docs
This will generate and launch a web browser to view the most up-to-date documentation for your Python package.
-
make update-simulariumio-layer function=xxx
This will prepare a new version of the simulariumio layer and publish it to AWS, automatically incrementing the published version number as well. Then, it will update the layer in the Lambda function named [function] to the latest version.
-
make create-lambda function=xxx iam=xxx
This will create a new AWS Lambda named [function] from a file with the name [function] inside the scripts directory, given the AWS IAM account ID [iam].
-
make add-layers function=xxx
This will add the SciPy, Pandas, and Simulariumio layers (the latest published version) to the Lambda function named [function].
-
make invoke-lambda function=xxx
This will call an AWS Lambda function named [function] for testing.
- Lambda times out
- Go to the Configuration tab in the Lambda page, then General configuration. You can edit the timeout there (max 15 minutes).
- 403 error when making POST request
- Actually deploy the API endpoint
- Turn your project into a GitHub repository:
- Make an account on github.com
- Go to make a new repository
- Recommendations:
- It is strongly recommended to make the repository name the same as the Python package name
- A lot of the following optional steps are free if the repository is Public, plus open source is cool
- After a GitHub repo has been created, run the commands listed under: "...or push an existing repository from the command line"
- Register your project with Codecov:
- Make an account on codecov.io(Recommended to sign in with GitHub) everything else will be handled for you.
- Ensure that you have set GitHub pages to build the
gh-pages
branch by selecting thegh-pages
branch in the dropdown in the "GitHub Pages" section of the repository settings. (Repo Settings) - Register your project with PyPI:
- Make an account on pypi.org
- Go to your GitHub repository's settings and under the
Secrets tab,
add a secret called
PYPI_TOKEN
with your password for your PyPI account. Don't worry, no one will see this password because it will be encrypted. - Next time you push to the branch
main
after usingbump2version
, GitHub actions will build and deploy your Python package to PyPI.
main
is for the most up-to-date development, very rarely should you directly commit to this branch. GitHub Actions will run on every push and on a CRON to this branch but still recommended to commit to your development branches and make pull requests to main. If you push a tagged commit with bumpversion, this will also release to PyPI.- Your day-to-day work should exist on branches separate from
main
. Even if it is just yourself working on the repository, make a PR from your working branch tomain
so that you can ensure your commits don't break the development head. GitHub Actions will run on every push to any branch or any pull request from any branch to any other branch. - It is recommended to use "Squash and Merge" commits when committing PR's. It makes
each set of changes to
main
atomic and as a side effect naturally encourages small well defined PR's.
MIT license