Sage-Bionetworks/nbconvert-webapp

Name: nbconvert-webapp

Owner: Sage Bionetworks

Description: Converts ipynb file into html. Packaged for Lambda deployment

Created: 2017-11-14 16:30:35.0

Updated: 2017-11-14 16:37:14.0

Pushed: 2017-11-20 22:05:15.0

Homepage:

Size: 104692

Language: Python

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

nbconvert-webapp

Converts ipynb file into html. This is a light wrapper around nbconvert, packaged to deploy as an AWS Lambda function.

Note, I used python-lambda as a starting point.

How to create the deployment package

Note that a prebuilt package is included in the dist directory. To rebuild… As described in the AWS Lambda “Creating a Deployment Package (Python)” doc, use the Virtualenv tool. Install all dependencies within this environment

install requests
install nbconvert

Now zip up your site-packages directory. I named the archive app.zip

Then add the handler file, service.py, to the app.zip

-g app.zip service.py
How to deploy the AWS Lambda Function deployment package

To create the function:

bucket_name> is the name of the bucket where the package resides
lambda_role_arn> is the arn of the role to be assumed by the lambda function
lambda create-function --region <region> --function-name nbconvert --code S3Bucket=<bucket_name>,S3Key=app.zip --role <lambda_role_arn> --handler service.handler --runtime python3.6 --timeout 10 --memory-size 1024

To update the function:

lambda update-function-code --function-name nbconvert --s3-bucket <bucket_name> --s3-key=app.zip --publish
How to test locally

Install the python-lambda helper project:

install python-lambda

Now call the lambda handler (service.py using event.json as input) by executing the command:

da invoke -v

This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.