bakdata / aws-lambda-r-runtime

Serverless execution of R code on AWS Lambda
https://medium.com/bakdata/running-r-on-aws-lambda-9d40643551a6
MIT License
143 stars 52 forks source link

Please provide pre-compiled layers #45

Closed mojimi closed 5 years ago

mojimi commented 5 years ago

Sorry but I don't understand what to do here, I'm on windows and I don't understand how to run these .sh files.

I see that you provided arns for your layers but I also don't understand how to download someone else's layer by arn.

Could you just provide a pre-compiled zip for the R custom runtime?

I tried running using git but I got the following error :

The command '/bin/sh -c wget -q https://cran.r-project.org/src/base/R-3/R-${VERSION}.tar.gz && mkdir ${R_DIR} && tar -xf R-${VERSION}.tar.gz && mv R-${VERSION}/* ${R_DIR} && rm R-${VERSION}.tar.gz' returned a non-zero code: 8

philipp94831 commented 5 years ago

You do not need to compile it yourself. Just follow the example to use our provided layer:

cd example/
chmod 755 script.R
zip function.zip script.R
# current region
region=$(aws configure get region)
# latest runtime layer ARN for R 3.6.0
runtime_layer=$(aws lambda list-layer-versions --max-items 1 --no-paginate  \
    --layer-name arn:aws:lambda:${region}:131329294410:layer:r-runtime-3_6_0 \
    --query 'LayerVersions[0].LayerVersionArn' --output text)
aws lambda create-function --function-name r-example \
    --zip-file fileb://function.zip --handler script.handler \
    --runtime provided --timeout 60 \
    --layers ${runtime_layer} \
    --role <role-arn>
mojimi commented 5 years ago

@philipp94831 Thanks, I got that working to get testing but I need a specific R library (knitr), unfortunately I don't have enough knowledge to follow the instruction on README

I managed to got as far as succesfully running docker_build.sh but I don't see any output from it and where to go from here.

philipp94831 commented 5 years ago

If you run

docker build -t lambda-r:build-${VERSION} --build-arg VERSION=${VERSION} .

you should have a valid base image with compiled R.

You can then build your own layer using docker. See https://github.com/bakdata/aws-lambda-r-runtime/blob/master/awspack/build.sh

mojimi commented 5 years ago

If you run

docker build -t lambda-r:build-${VERSION} --build-arg VERSION=${VERSION} .

you should have a valid base image with compiled R.

You can then build your own layer using docker. See https://github.com/bakdata/aws-lambda-r-runtime/blob/master/awspack/build.sh

Yes I got a lambda-r image called build-3.6.0

So, do I need to run the build.sh inside the docker image? Its not clear to me I have little docker knowledge

philipp94831 commented 5 years ago

Just run it in your machine

mojimi commented 5 years ago

Just run it in your machine

Thanks, I eventually managed to do it on windows using git bash, but I had to export MSYS_NO_PATHCONV=1 so that it stopped converting paths.

If I get further than this I'll try to do a PR with instructions for Windows