diff --git a/DESCRIPTION b/DESCRIPTION index b17a810..01c1bbc 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: r2lambda Type: Package -Title: Deploy 'R' Scripts as 'AWS Lambda' Functions +Title: Deploy 'R' Scripts as AWS Lambda Functions Version: 0.3.0 Authors@R: c( person("Teofil", "Nakov", , "teofiln@gmail.com", role = "aut", @@ -10,12 +10,12 @@ Authors@R: c( person("Discindo", role = "cph") ) 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 + (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. See - for the 'AWS Lambda' service. + for the AWS Lambda service. License: GPL (>= 3) Depends: R (>= 4.1.0) Encoding: UTF-8 diff --git a/R/lambda-deploy.R b/R/lambda-deploy.R index 6a3450d..ff8346c 100644 --- a/R/lambda-deploy.R +++ b/R/lambda-deploy.R @@ -27,12 +27,14 @@ #' @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") -#' ) +#' \donttest{ +#' if (interactive()) { +#' 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 @@ -127,9 +129,11 @@ build_lambda <- function( #' S3, can run more than once. #' #' @examples -#' \dontrun{ -#' payload <- list(number = 2) -#' test_lambda(tag = "parity1", payload) +#' \donttest{ +#' if (interactive()) { +#' payload <- list(number = 2) +#' test_lambda(tag = "parity1", payload) +#' } #' } #' @importFrom glue glue glue_collapse single_quote double_quote #' @export @@ -201,27 +205,27 @@ test_lambda <- function(tag, payload) { #' `Lambda_function_arn`. #' #' @examples -#' \dontrun{ -#' -#' runtime_function <- "parity" -#' runtime_path <- system.file("parity.R", package = "r2lambda") -#' dependencies <- NULL -#' -#' build_lambda( -#' tag = "myrepo52", -#' runtime_function = runtime_function, -#' runtime_path = runtime_path, -#' dependencies = dependencies -#' ) +#' \donttest{ +#' if (interactive()) { +#' runtime_function <- "parity" +#' runtime_path <- system.file("parity.R", package = "r2lambda") +#' dependencies <- NULL #' -#' deploy_lambda(tag = "myrepo52") +#' build_lambda( +#' tag = "myrepo52", +#' runtime_function = runtime_function, +#' runtime_path = runtime_path, +#' dependencies = dependencies +#' ) #' -#' invoke_lambda( -#' function_name = "myrepo52", -#' payload = list(number = 3), -#' invocation_type = "RequestResponse" -#' ) +#' deploy_lambda(tag = "myrepo52") #' +#' invoke_lambda( +#' function_name = "myrepo52", +#' payload = list(number = 3), +#' invocation_type = "RequestResponse" +#' ) +#' } #' } #' @importFrom paws ecr iam lambda s3 eventbridge cloudwatchlogs #' @export @@ -372,12 +376,14 @@ deploy_lambda <- #' elements such as `StatusCode` and `Payload` (a raw vector). The payload is #' also printed. #' @examples -#' \dontrun{ -#' invoke_lambda( -#' function_name = "parity", -#' payload = list(number = 3), -#' invocation_type = "RequestResponse" -#' ) +#' \donttest{ +#' if (interactive()) { +#' invoke_lambda( +#' function_name = "parity", +#' payload = list(number = 3), +#' invocation_type = "RequestResponse" +#' ) +#' } #' } #' @export invoke_lambda <- @@ -435,10 +441,12 @@ invoke_lambda <- #' @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)") +#' \donttest{ +#' if (interactive()) { +#' # Make Tidytuesday lambda fetch the Tidytuesday dataset every Wednesday +#' # at 8 am +#' schedule_lambda("Tidytuesday3", "cron(0 8 * * Wed)") +#' } #' } #' #' @export @@ -561,8 +569,10 @@ schedule_lambda <- function(lambda_function, execution_rate) { #' @return Invisibly, a list with the names of the deleted resources. #' #' @examples -#' \dontrun{ -#' delete_lambda("parity1") +#' \donttest{ +#' if (interactive()) { +#' delete_lambda("parity1") +#' } #' } #' @export delete_lambda <- function( diff --git a/cran-comments.md b/cran-comments.md index 8fa3361..3200eae 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -1,3 +1,15 @@ +## Resubmission + +This is a resubmission. In this version I have: + +* Removed the single quotes around AWS and AWS Lambda in the Title and + Description. +* Replaced `\dontrun{}` in the examples with `\donttest{}`, with an + `if (interactive())` guard inside. + The examples need AWS credentials and a running Docker daemon, and they + create, invoke or delete billable AWS resources, so they run only in an + interactive session. + ## R CMD check results 0 errors | 0 warnings | 1 note @@ -8,7 +20,7 @@ The `aws_connect()` example runs: it only creates a 'paws' client object, which needs no credentials and sends no request to AWS. The other examples -are wrapped in `\dontrun{}`: they need AWS credentials, and they create, +run only in interactive sessions: they need AWS credentials, and they create, invoke or delete billable AWS resources (ECR repositories, IAM roles, Lambda functions and EventBridge schedules). `build_lambda()`, `test_lambda()`, `deploy_lambda()` and `delete_lambda()` also need a running Docker daemon. diff --git a/man/build_lambda.Rd b/man/build_lambda.Rd index 06a1a78..17c0e94 100644 --- a/man/build_lambda.Rd +++ b/man/build_lambda.Rd @@ -55,11 +55,13 @@ 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") - ) +\donttest{ +if (interactive()) { + build_lambda( + tag = "parity1", + runtime_function = "parity", + runtime_path = system.file("parity.R", package = "r2lambda") + ) +} } } diff --git a/man/delete_lambda.Rd b/man/delete_lambda.Rd index fba8e66..b68d188 100644 --- a/man/delete_lambda.Rd +++ b/man/delete_lambda.Rd @@ -34,7 +34,9 @@ schedule rule that also targets other resources is kept, without this function as a target. } \examples{ -\dontrun{ - delete_lambda("parity1") +\donttest{ +if (interactive()) { + delete_lambda("parity1") +} } } diff --git a/man/deploy_lambda.Rd b/man/deploy_lambda.Rd index a6176e8..3379027 100644 --- a/man/deploy_lambda.Rd +++ b/man/deploy_lambda.Rd @@ -32,26 +32,26 @@ Invisibly, a list with `ECR_image_uri`, `IAM_lambda_role_arn` and deploy a local lambda image to AWS Lambda } \examples{ -\dontrun{ - - runtime_function <- "parity" - runtime_path <- system.file("parity.R", package = "r2lambda") - dependencies <- NULL - - build_lambda( - tag = "myrepo52", - runtime_function = runtime_function, - runtime_path = runtime_path, - dependencies = dependencies - ) - - deploy_lambda(tag = "myrepo52") - - invoke_lambda( - function_name = "myrepo52", - payload = list(number = 3), - invocation_type = "RequestResponse" - ) - +\donttest{ +if (interactive()) { + runtime_function <- "parity" + runtime_path <- system.file("parity.R", package = "r2lambda") + dependencies <- NULL + + build_lambda( + tag = "myrepo52", + runtime_function = runtime_function, + runtime_path = runtime_path, + dependencies = dependencies + ) + + deploy_lambda(tag = "myrepo52") + + invoke_lambda( + function_name = "myrepo52", + payload = list(number = 3), + invocation_type = "RequestResponse" + ) +} } } diff --git a/man/invoke_lambda.Rd b/man/invoke_lambda.Rd index dd9118d..06acafa 100644 --- a/man/invoke_lambda.Rd +++ b/man/invoke_lambda.Rd @@ -25,11 +25,13 @@ also printed. invoke a lambda function } \examples{ -\dontrun{ - invoke_lambda( - function_name = "parity", - payload = list(number = 3), - invocation_type = "RequestResponse" - ) +\donttest{ +if (interactive()) { + invoke_lambda( + function_name = "parity", + payload = list(number = 3), + invocation_type = "RequestResponse" + ) +} } } diff --git a/man/schedule_lambda.Rd b/man/schedule_lambda.Rd index f1e06e3..769d245 100644 --- a/man/schedule_lambda.Rd +++ b/man/schedule_lambda.Rd @@ -21,10 +21,12 @@ None, called for its side effect of creating the schedule. 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)") +\donttest{ +if (interactive()) { + # 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 f720717..606d59b 100644 --- a/man/test_lambda.Rd +++ b/man/test_lambda.Rd @@ -27,8 +27,10 @@ function runs again, so a function with side effects, such as writing to S3, can run more than once. } \examples{ -\dontrun{ - payload <- list(number = 2) - test_lambda(tag = "parity1", payload) +\donttest{ +if (interactive()) { + payload <- list(number = 2) + test_lambda(tag = "parity1", payload) +} } }