numeract / aws-lambda-r Goto Github PK
View Code? Open in Web Editor NEWUsing R on AWS Lambda
Home Page: https://numeract.github.io/aws-lambda-r/
License: MIT License
Using R on AWS Lambda
Home Page: https://numeract.github.io/aws-lambda-r/
License: MIT License
.ini
file (instead of executing a user specific .sh
file)Note: remember to add the third party references in README and NOTICE files, see
Open list / wishes / references. Once fully defined, move them to separate issues
I think the tooling has improved considerably and its fairly straightforward to compile binaries within a docker image without having to spin up an ec2. I'm considering using this for working with some of my colleagues that work exclusively in R and was hoping to make it as easy and painless as possible for them to get an RScript scraper deployed with precompiled binaries
I used this repo to build some python library binaries in the past: https://github.com/AlJohri/aws-lambda-lxml. the whole thing boiled down to:
docker run -v $(pwd)/"$version/py36/":/outputs -it lambci/lambda:build-python3.6 pip install lxml=="4.2.4" -t /outputs/
tar -czvf "4.2.4/py36/lxml-4.2.4.tgz" "4.2.4/py36/lxml"
aws s3 cp 4.2.4/py36/lxml-4.2.4.tgz s3://mybucket/lambda-compiled-binaries/py36/
see build.sh
would you consider a PR switching to docker instead of ec2?
On the Amazon AMI I can install from inside R, but then I have this problem:
Installing package into ‘/usr/lib64/R/library’
(as ‘lib’ is unspecified)
Warning in install.packages("jsonlite", repos = "http://cran.r-project.org") :
'lib = "/usr/lib64/R/library"' is not writable
Would you like to use a personal library instead? (y/n)
I can install it this way also:
wget https://cran.r-project.org/src/contrib/jsonlite_1.5.tar.gz
sudo R CMD INSTALL jsonlite_1.5.tar.gz
which probably is the best way, or run R as sudo..
Hello,
Very nice job!
I'm confused about EC2. Reading your documentation, I can't figure out why do I need a EC2 instance to build the package. Is it possible to do that locally? Is there some reason for that?
As I understand, after setting up all variables, I just need to run 01_main.sh script, right?
Best regards,
Clovis
ALX_AMI_ID="ami-657bd20a"
: last version of Amazon Linux, w/o updatesEC2_AMI_ID=""
EC2_AMI_ID
not defined or there is no AMI with this ID -->
settings/settings_ami.txt
and whether it contains a string --> EC2_AMI_ID=stringEC2_AMI_ID
not defined or there is no AMI with this ID --> EC2_AMI_ID=""EC2_AMI_ID
is defined --> done, skip the steps belowsettings/settings_ami.txt
settings/settings_ami.txt
and if it contains a string --> EC2_AMI_ID=string
name/repo
formatGreat project!
I am trying to configure the setup_user.sh script file by following the example file.
I added:
#!/bin/bash
# user settings and secrets
# customize and rename to `setup_user.sh`
# overwrites `secrets_default.sh`, `settings_default.sh`, `setup_auto.sh`
PRJ_NAME ="myproj"
PRJ_BRANCH="myproj"
Then I run scripts/01_main.sh
Got error:
\e[32mINFO :\e[39m Checking project directories
\e[32mINFO :\e[39m Loading default settings and secrets
/Users/macos/Documents/r-ec2/myproj/settings/setup_user.sh: line 6: PRJ_NAME: command not found
\e[31mERROR:\e[39m PRJ_NAME is \e[95mMISSING\e[39m. Exiting.
Is there a simple way to configure the setup_user script?
I assume that the R script in the Lambda has access to the AWS OS it's running on so theoretically it could use for example Clodyr's R library aws.s3 and fetch files from s3.
# get file as raw vector
get_object("mtcars.Rdata", bucket = "my_bucket")
Then you don't have to pass it thru Python and also you avoid rewriting your existing R code base. Or am I missing something? Is this not possible?
Hi
running through a test deployment after setting up AWS, and am finding this:
INFO : Copy files to local lambda/
INFO : Copy file: python/lambda_get.py to lambda/
INFO : Copy file: python/lambda_post.py to lambda/
INFO : Copy file: example.R to lambda/
INFO : Remove EC2 directory ~/rtest-aws
INFO : Copying local lambda/ to EC2 ~/rtest-aws ...
.gitignore 100% 84 2.8KB/s 00:00
example.R 100% 1281 42.3KB/s 00:00
lambda_get.py 100% 672 22.2KB/s 00:00
lambda_post.py 100% 673 22.3KB/s 00:00
README.md 100% 267 8.8KB/s 00:00
INFO : Configure EC2, create Lambda package/function & API method ...
INFO : Configure AWS on EC2
INFO : Check AWS configuration on EC2 ...
INFO : AWS Account ID: ********3729
INFO : Lambda Function Name: rtest-aws-master-alpha-resource-v1-get
INFO : Creating deployment package
INFO : PWD: /home/ec2-user/rtest-aws
INFO : Transferring Python 3.6 packages to the deployment package
bash: line 392: /home/ec2-user/env/bin/activate: No such file or directory
ERROR: Cannot create Lambda package/function & API method. Terminating end exiting ...
one thought is that perhaps my custom ami is not right, or perhaps a bug somewhere?
Hi
in script 24-setup_lambda.sh I cant seem to be able to create the Lambda Authorizer Function.
It fails with the following (the permissions for the IAM user running this are full access to lambda)
INFO : Creating Lambda Authorizer Function ...
An error occurred (InvalidParameterValueException) when calling the CreateFunction operation: The role defined for the function cannot be assumed by Lambda.
An error occurred (ResourceNotFoundException) when calling the GetFunctionConfiguration operation: Function not found: arn:aws:lambda:ap-southeast-2:11111111111:function:aws-lambda-r-lambda-authorizer
ERROR: Failed to obtain ARN of Lambda Authorizer Function aws-lambda-r-lambda-authorizer. Exiting.```
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.