Skip to content

Commit

Permalink
rm magrittr dependency.
Browse files Browse the repository at this point in the history
declare imports from paws
rd files auto update
  • Loading branch information
teofiln committed Oct 16, 2024
1 parent fa0b0ce commit aeec46d
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 51 deletions.
1 change: 0 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ Imports:
jsonlite,
lambdr,
logger,
magrittr,
paws,
rlang,
stevedore,
Expand Down
7 changes: 5 additions & 2 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
# Generated by roxygen2: do not edit by hand

export("%>%")
export(aws_connect)
export(build_lambda)
export(deploy_lambda)
export(invoke_lambda)
export(schedule_lambda)
export(test_lambda)
importFrom(magrittr,"%>%")
importFrom(paws,ecr)
importFrom(paws,eventbridge)
importFrom(paws,iam)
importFrom(paws,lambda)
importFrom(paws,s3)
3 changes: 2 additions & 1 deletion R/lambda-deploy.R
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ test_lambda <- function(tag, payload) {

logger::log_info("[test_lambda] Checking image tag exists.")
images <- docker_cli$image$list()
tags <- images[["repo_tags"]] %>% unlist()
tags <- images[["repo_tags"]] |> unlist()
tag_exists <- repo_tag %in% tags

if (!tag_exists) {
Expand Down Expand Up @@ -149,6 +149,7 @@ test_lambda <- function(tag, payload) {
#' )
#'
#' }
#' @importFrom paws ecr iam lambda s3 eventbridge
#' @export
deploy_lambda <-
function(tag, set_aws_envvars = FALSE, ...) {
Expand Down
12 changes: 6 additions & 6 deletions R/lambda-util.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ 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")`)
#' be a function exported by `paws` (see `getNamespaceExports("paws")`)
#' @examples
#' \dontrun{
#' aws_connect("lambda")
Expand Down Expand Up @@ -66,10 +66,10 @@ runtime_line <- function(runtime) {
#' parse password from ecr token
#' @noRd
parse_password <- function(ecr_token) {
ecr_token %>%
jsonlite::base64_dec() %>%
rawToChar() %>%
gsub(pattern = "^AWS:", replacement = "", x = .)
ecr_token |>
jsonlite::base64_dec() |>
rawToChar() |>
gsub(pattern = "^AWS:", replacement = "")
}

#' create_lambda_dockerfile
Expand Down Expand Up @@ -267,7 +267,7 @@ push_lambda_image <- function(tag) {
ecr_token <- ecr_service$get_authorization_token()
ecr_password <- parse_password(ecr_token$authorizationData[[1]]$authorizationToken)
repo_uri <- fetch_ecr_repo(tag)
server_address <- repo_uri %>% gsub(pattern = "/.*$", replacement = "", x = .)
server_address <- gsub(pattern = "/.*$", replacement = "", x = repo_uri)

docker_cli <- stevedore::docker_client()
docker_cli$login(
Expand Down
14 changes: 0 additions & 14 deletions R/utils-pipe.R

This file was deleted.

2 changes: 1 addition & 1 deletion man/aws_connect.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 0 additions & 20 deletions man/pipe.Rd

This file was deleted.

2 changes: 1 addition & 1 deletion vignettes/lambda-s3.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ tt_dataset <- s3_service$get_object(
)
# convert from raw and show the first few rows
tt_dataset$Body %>% unserialize() %>% head()
tt_dataset$Body |> unserialize() |> head()
```

Now we should have everything we need to write our Lambda function.
Expand Down
6 changes: 3 additions & 3 deletions vignettes/schedule-lambda.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ the rule.
# connect to the EventBridge service
events_service <- r2lambda::aws_connect("eventbridge")
# find the names of all rules we need
schedule_rules <- events_service$list_rules()[[1]] %>% sapply("[[", 1)
schedule_rules <- events_service$list_rules()[[1]] |> sapply("[[", 1)
# find the targets associated with the rule we want to remove
rule_to_remove <- schedule_rules[[1]]
Expand All @@ -188,15 +188,15 @@ target_arn_to_remove <- events_service$list_targets_by_rule(Rule = rule_to_remov
events_service$remove_targets(Rule = rule_to_remove, Ids = target_arn_to_remove)
events_service$delete_rule(Name = rule_to_remove)
events_service$list_rules()[[1]] %>% sapply("[[", 1)
events_service$list_rules()[[1]] |> sapply("[[", 1)
```

Finally, to remove the Lambda:

```{r}
lambda_service <- r2lambda::aws_connect("lambda")
lambda_service$list_functions()$Functions %>% sapply("[[","FunctionName")
lambda_service$list_functions()$Functions |> sapply("[[","FunctionName")
lambda_service$delete_function(FunctionName = "parity1")
```

4 changes: 2 additions & 2 deletions vignettes/tt-lambda.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,8 @@ Just like in the local test, the response payload comes as a raw vector that nee
be parsed into a data.frame:

```{r}
tidytuesday_dataset <- response$Payload %>%
rawToChar() %>%
tidytuesday_dataset <- response$Payload |>
rawToChar() |>
jsonlite::fromJSON(simplifyDataFrame = TRUE)
tidytuesday_dataset[[1]][1:5, 1:5]
Expand Down

0 comments on commit aeec46d

Please sign in to comment.