From aa9fd1f2b313661186b08ce6ce8c9aa8e8d41116 Mon Sep 17 00:00:00 2001 From: novica Date: Sat, 17 Oct 2026 17:10:37 +0200 Subject: [PATCH] docs: meet CRAN extra checks Add cph, return values and install instructions that CRAN reviewers ask for, and skip tests when withr is not installed (noSuggests). Assisted-by: Claude Opus 5.5 --- DESCRIPTION | 14 +++++++++----- R/lambda-deploy.R | 29 +++++++++++++++++++++++++++-- R/lambda-util.R | 2 ++ README.md | 8 +++++++- cran-comments.md | 5 +++++ man/aws_connect.Rd | 4 ++++ man/build_lambda.Rd | 12 ++++++++++++ man/deploy_lambda.Rd | 4 ++++ man/invoke_lambda.Rd | 5 +++++ man/schedule_lambda.Rd | 8 ++++++-- man/test_lambda.Rd | 5 +++++ tests/testthat.R | 6 +++++- 12 files changed, 91 insertions(+), 11 deletions(-) create mode 100644 cran-comments.md diff --git a/DESCRIPTION b/DESCRIPTION index e06d5df..adee698 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,16 +1,20 @@ Package: r2lambda Type: Package -Title: Deploy R Scripts as AWS Lambda Functions +Title: Deploy 'R' Scripts as 'AWS Lambda' Functions Version: 0.1.0 Authors@R: c( person("Teofil", "Nakov", , "teofiln@gmail.com", role = "aut", comment = c(ORCID = "0009-0000-9589-5748")), person("Novica", "Nakov", , "nnovica@gmail.com", role = c("aut", "cre"), - comment = c(ORCID = "0009-0005-7773-7718")) + comment = c(ORCID = "0009-0005-7773-7718")), + person("Discindo", role = "cph") ) -Description: Build, test and deploy R scripts as 'AWS Lambda' functions - packaged in 'Docker' container images. Wraps functionality from the - 'paws' and 'lambdr' packages. +Description: Build, test and deploy 'R' scripts as Amazon Web Services + ('AWS') 'Lambda' functions packaged in 'Docker' container images. + Images are built and tested locally, pushed to the 'AWS' Elastic + Container Registry, and deployed with an execution role; deployed + functions can be invoked, scheduled and deleted from 'R'. Wraps + functionality from the 'paws' and 'lambdr' packages. License: GPL (>= 3) Encoding: UTF-8 Imports: diff --git a/R/lambda-deploy.R b/R/lambda-deploy.R index ac460c8..1b6c8bd 100644 --- a/R/lambda-deploy.R +++ b/R/lambda-deploy.R @@ -24,6 +24,16 @@ #' packages, not both. By default, both are `NULL`, so the Docker image will #' have no additional packages installed. #' +#' @return None, called for its side effect of building a local Docker image. +#' +#' @examples +#' \dontrun{ +#' build_lambda( +#' tag = "parity1", +#' runtime_function = "parity", +#' runtime_path = system.file("parity.R", package = "r2lambda") +#' ) +#' } #' @importFrom glue glue glue_collapse single_quote double_quote #' @export build_lambda <- function( @@ -92,6 +102,7 @@ build_lambda <- function( ) logger::log_success("[build_lambda] Done.") + invisible(NULL) } #' test a lambda locally @@ -100,6 +111,10 @@ build_lambda <- function( #' (see `build_lambda`) #' @param payload Named list. Arguments to lambda function. #' +#' @return Invisibly, the result of [sys::exec_internal()] for the `curl` call +#' to the local container: a list with `status`, and `stdout` and `stderr` as +#' raw vectors. The response is also printed. +#' #' @examples #' \dontrun{ #' payload <- list(number = 2) @@ -171,6 +186,9 @@ test_lambda <- function(tag, payload) { #' example `Timeout`, `MemorySize` or `Environment`. `Architectures` is set #' from the image's architecture. #' +#' @return Invisibly, a list with `ECR_image_uri`, `IAM_lambda_role_arn` and +#' `Lambda_function_arn`. +#' #' @examples #' \dontrun{ #' @@ -315,6 +333,9 @@ deploy_lambda <- #' or ‘Event’ see `?paws.compute::lambda_invoke` #' @param payload A named list internally converted to json #' @param include_logs logical, whether to show the lambda logs (default: FALSE) +#' @return Invisibly, the response of `paws::lambda()$invoke()`, a list with +#' elements such as `StatusCode` and `Payload` (a raw vector). The payload is +#' also printed. #' @examples #' \dontrun{ #' invoke_lambda( @@ -377,10 +398,13 @@ invoke_lambda <- #' `rate` or `cron` specification. For details see the official documentation: #' https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-create-rule-schedule.html #' +#' @return None, called for its side effect of creating the schedule. +#' #' @examples #' \dontrun{ -#' # Make Tidytuesday lambda fetch the Tidytuesday dataset every wednesday -#' at 8 am schedule_lambda("Tidytuesday3", "cron(0 8 * * Wed)") +#' # Make Tidytuesday lambda fetch the Tidytuesday dataset every Wednesday +#' # at 8 am +#' schedule_lambda("Tidytuesday3", "cron(0 8 * * Wed)") #' } #' #' @export @@ -465,6 +489,7 @@ schedule_lambda <- function(lambda_function, execution_rate) { ) logger::log_info("[schedule_lambda] Done.") + invisible(NULL) } #' Delete a Lambda function and the AWS resources created for it diff --git a/R/lambda-util.R b/R/lambda-util.R index ead7ca5..55e0751 100644 --- a/R/lambda-util.R +++ b/R/lambda-util.R @@ -20,6 +20,8 @@ check_system_dependencies <- function() { #' connect to an aws service #' @param service character, the name of a service, e.g., "lambda" or "iam". #' Should be a function exported by `paws` (see `getNamespaceExports("paws")`) +#' @return A `paws` client for the service: a list of functions, one per +#' service operation. #' @examples #' \dontrun{ #' aws_connect("lambda") diff --git a/README.md b/README.md index 12f2c39..2c69243 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,13 @@ to a deployed `AWS Lambda` function. ## Installation -You can install the development version of `{r2lambda}` like so: +You can install the released version of `{r2lambda}` from CRAN with: + +``` r +install.packages("r2lambda") +``` + +You can install the development version of `{r2lambda}` from GitHub with: ``` r # install.packages("remotes") diff --git a/cran-comments.md b/cran-comments.md new file mode 100644 index 0000000..858617d --- /dev/null +++ b/cran-comments.md @@ -0,0 +1,5 @@ +## R CMD check results + +0 errors | 0 warnings | 1 note + +* This is a new release. diff --git a/man/aws_connect.Rd b/man/aws_connect.Rd index 4d4a2ce..870e49d 100644 --- a/man/aws_connect.Rd +++ b/man/aws_connect.Rd @@ -10,6 +10,10 @@ aws_connect(service) \item{service}{character, the name of a service, e.g., "lambda" or "iam". Should be a function exported by `paws` (see `getNamespaceExports("paws")`)} } +\value{ +A `paws` client for the service: a list of functions, one per +service operation. +} \description{ connect to an aws service } diff --git a/man/build_lambda.Rd b/man/build_lambda.Rd index 1f8103b..06a1a78 100644 --- a/man/build_lambda.Rd +++ b/man/build_lambda.Rd @@ -43,6 +43,9 @@ some libraries, such as GDAL, are not available. Default is NULL.} an arm64 image on an x86_64 machine, or the reverse, needs Docker's QEMU emulation.} } +\value{ +None, called for its side effect of building a local Docker image. +} \description{ build and tag lambda image locally } @@ -51,3 +54,12 @@ Use either `renvlock_path` or `dependencies` to install required packages, not both. By default, both are `NULL`, so the Docker image will have no additional packages installed. } +\examples{ +\dontrun{ + build_lambda( + tag = "parity1", + runtime_function = "parity", + runtime_path = system.file("parity.R", package = "r2lambda") + ) +} +} diff --git a/man/deploy_lambda.Rd b/man/deploy_lambda.Rd index 03f3f98..a6176e8 100644 --- a/man/deploy_lambda.Rd +++ b/man/deploy_lambda.Rd @@ -24,6 +24,10 @@ must trust `lambda.amazonaws.com`.} example `Timeout`, `MemorySize` or `Environment`. `Architectures` is set from the image's architecture.} } +\value{ +Invisibly, a list with `ECR_image_uri`, `IAM_lambda_role_arn` and +`Lambda_function_arn`. +} \description{ deploy a local lambda image to AWS Lambda } diff --git a/man/invoke_lambda.Rd b/man/invoke_lambda.Rd index af8ba47..dd9118d 100644 --- a/man/invoke_lambda.Rd +++ b/man/invoke_lambda.Rd @@ -16,6 +16,11 @@ or ‘Event’ see `?paws.compute::lambda_invoke`} \item{include_logs}{logical, whether to show the lambda logs (default: FALSE)} } +\value{ +Invisibly, the response of `paws::lambda()$invoke()`, a list with +elements such as `StatusCode` and `Payload` (a raw vector). The payload is +also printed. +} \description{ invoke a lambda function } diff --git a/man/schedule_lambda.Rd b/man/schedule_lambda.Rd index a61a811..f1e06e3 100644 --- a/man/schedule_lambda.Rd +++ b/man/schedule_lambda.Rd @@ -14,13 +14,17 @@ is done internally make sure the Lambda exists and fetch its ARN.} `rate` or `cron` specification. For details see the official documentation: https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-create-rule-schedule.html} } +\value{ +None, called for its side effect of creating the schedule. +} \description{ Put a deployed lambda function on a schedule } \examples{ \dontrun{ - # Make Tidytuesday lambda fetch the Tidytuesday dataset every wednesday -at 8 am schedule_lambda("Tidytuesday3", "cron(0 8 * * Wed)") + # Make Tidytuesday lambda fetch the Tidytuesday dataset every Wednesday + # at 8 am + schedule_lambda("Tidytuesday3", "cron(0 8 * * Wed)") } } diff --git a/man/test_lambda.Rd b/man/test_lambda.Rd index 0287c74..fa4a0e8 100644 --- a/man/test_lambda.Rd +++ b/man/test_lambda.Rd @@ -12,6 +12,11 @@ test_lambda(tag, payload) \item{payload}{Named list. Arguments to lambda function.} } +\value{ +Invisibly, the result of [sys::exec_internal()] for the `curl` call +to the local container: a list with `status`, and `stdout` and `stderr` as +raw vectors. The response is also printed. +} \description{ test a lambda locally } diff --git a/tests/testthat.R b/tests/testthat.R index 7809c30..50159de 100644 --- a/tests/testthat.R +++ b/tests/testthat.R @@ -9,4 +9,8 @@ library(testthat) library(r2lambda) -test_check("r2lambda") +# tests/testthat/setup.R uses withr to keep tests away from real AWS +# credentials, so the suite can't run without it. +if (requireNamespace("withr", quietly = TRUE)) { + test_check("r2lambda") +}