Skip to content

Commit

Permalink
Merge pull request #898 from DyfanJones/main
Browse files Browse the repository at this point in the history
bump version to dev
  • Loading branch information
DyfanJones authored Feb 13, 2025
2 parents d65becd + 6bce336 commit be3cdae
Show file tree
Hide file tree
Showing 101 changed files with 4,577 additions and 2,799 deletions.
38 changes: 26 additions & 12 deletions make.paws/R/aws_services.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,14 @@ list_aws_services <- function(in_dir = "../vendor/botocore") {
api <- read_api(x, in_dir)
data.frame(
services = package_name(api),
operations = vapply(api$operations, function(x) {
get_operation_name(x)
}, FUN.VALUE = "", USE.NAMES = F)
operations = vapply(
api$operations,
function(x) {
get_operation_name(x)
},
FUN.VALUE = "",
USE.NAMES = F
)
)
})
return(do.call(rbind, aws_service_ops))
Expand All @@ -33,17 +38,26 @@ category_service_ops_count <- function(in_dir = "../vendor/botocore") {
data.frame(name = rep(x$name, length(x$services)), services = x$services)
})
paws_cat <- rbindlist(paws_cat, fill = T)
paws_cat_service_ops <- merge(paws_cat, aws_service_ops, by = "services", all.y = T)
paws_cat_service_ops <- merge(
paws_cat,
aws_service_ops,
by = "services",
all.y = T
)
setcolorder(paws_cat_service_ops, "name")
names(paws_cat_service_ops) <- c("category", "services", "operations")
paws_cat_service_ops_count <- paws_cat_service_ops[, list(
total_operations = .N
), by = c("category", "services")][, list(
services = get("services"),
total_services = uniqueN(get("services")),
total_operations = get("total_operations"),
sum_operations = sum(get("total_operations"))
), by = "category"]
paws_cat_service_ops_count <- paws_cat_service_ops[,
list(total_operations = .N),
by = c("category", "services")
][,
list(
services = get("services"),
total_services = uniqueN(get("services")),
total_operations = get("total_operations"),
sum_operations = sum(get("total_operations"))
),
by = "category"
]
paws_cat_service_ops_count <- paws_cat_service_ops_count[
order(get("category"), -get("total_services"), -get("total_operations"))
]
Expand Down
26 changes: 13 additions & 13 deletions make.paws/R/cache.R
Original file line number Diff line number Diff line change
Expand Up @@ -114,28 +114,28 @@ maybe_spot_check <- function(cache_result, value_expr, key_label) {
if (!identical(cache_result, value)) {
warning(
"Random cache spot-check failed! You may want to `make clean`!",
immediate. = TRUE, call. = FALSE
immediate. = TRUE,
call. = FALSE
)
cat(file = stderr(), "Key:\n")
cat(
file = stderr(),
paste0(
collapse = "\n",
" ",
key_label
)
)
cat(file = stderr(), paste0(collapse = "\n", " ", key_label))
cat(file = stderr(), "\n")
cat(file = stderr(), "Difference:\n")
cat(
file = stderr(),
paste0(
collapse = "\n",
" ",
utils::capture.output(print(waldo::compare(
cache_result, value,
x_arg = "cached", y_arg = "live"
)))
utils::capture.output(
print(
waldo::compare(
cache_result,
value,
x_arg = "cached",
y_arg = "live"
)
)
)
)
)
cat(file = stderr(), "\n")
Expand Down
19 changes: 15 additions & 4 deletions make.paws/R/cran_category.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,12 @@ make_category <- function(category, service_names, sdk_dir, out_dir) {
package_dir <- file.path(out_dir, name)
write_skeleton_category(package_dir)
write_description_category(
package_dir, name, title, description,
version, imports
package_dir,
name,
title,
description,
version,
imports
)
for (service in services) {
copy_files(service_names[[service]], from = sdk_dir, to = package_dir)
Expand All @@ -50,7 +54,10 @@ get_package_name <- function(suffix) {

# Get the stored AWS service categories and which services they include.
get_categories <- function() {
path <- system_file("extdata/packages.yml", package = methods::getPackageName())
path <- system_file(
"extdata/packages.yml",
package = methods::getPackageName()
)
yaml::read_yaml(path)
}

Expand Down Expand Up @@ -81,7 +88,11 @@ copy_files <- function(name, from, to) {
list(dir = "tests/testthat", pattern = "^test_%s.R$")
)
for (r in resources) {
copy <- list.files(file.path(from, r$dir), pattern = sprintf(r$pattern, name), full.names = TRUE)
copy <- list.files(
file.path(from, r$dir),
pattern = sprintf(r$pattern, name),
full.names = TRUE
)
if (length(copy) == 0) {
# skip warning as there is no reexports files in tests
if (r$dir == "tests/testthat" & name != "reexports") {
Expand Down
25 changes: 13 additions & 12 deletions make.paws/R/cran_collection.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,14 @@ make_collection <- function(sdk_dir, out_dir, categories, service_names) {

# Write the R source files for the collection package, which import and
# re-export the API client objects for each AWS API.
write_source_collection <- function(sdk_dir,
out_dir,
categories,
service_names,
expand_doc_links = FALSE,
use_parents = FALSE) {
write_source_collection <- function(
sdk_dir,
out_dir,
categories,
service_names,
expand_doc_links = FALSE,
use_parents = FALSE
) {
clients <- list()
for (category in categories) {
for (service in category$service) {
Expand All @@ -62,7 +64,10 @@ write_source_collection <- function(sdk_dir,
}
}
write_list(clients, file.path(out_dir, "R", "paws.R"))
write_list(make_reexports(), file.path(out_dir, "R", "reexports_paws.common.R"))
write_list(
make_reexports(),
file.path(out_dir, "R", "reexports_paws.common.R")
)
}

# Add the category packages to the DESCRIPTION file's Imports.
Expand Down Expand Up @@ -104,11 +109,7 @@ collection_client_template <- template(
)

make_collection_client_source <- function(package, service) {
render(
collection_client_template,
service = service,
package = package
)
render(collection_client_template, service = service, package = package)
}

service_exists <- function(path, service) {
Expand Down
46 changes: 35 additions & 11 deletions make.paws/R/cran_sub_category.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Make the categories from collection of sub-categories
make_category_collection <- function(sdk_dir, out_dir, categories, package, service_names) {
make_category_collection <- function(
sdk_dir,
out_dir,
categories,
package,
service_names
) {
version <- get_version(minor = 1)
package <- sprintf("paws.%s", package)
package_dir <- file.path(out_dir, package)
Expand All @@ -16,9 +22,13 @@ make_category_collection <- function(sdk_dir, out_dir, categories, package, serv
imports = c()
)
# Create packages that contain services
active <- vapply(categories, function(cat) {
!is.null(cat$services)
}, FUN.VALUE = logical(1))
active <- vapply(
categories,
function(cat) {
!is.null(cat$services)
},
FUN.VALUE = logical(1)
)
categories <- categories[active]
write_source_collection(
sdk_dir,
Expand All @@ -28,20 +38,34 @@ make_category_collection <- function(sdk_dir, out_dir, categories, package, serv
expand_doc_links = TRUE
)
write_documentation(package_dir)
write_imports_collection(package_dir, version, get_category_packages(categories))
write_imports_collection(
package_dir,
version,
get_category_packages(categories)
)
}

# Identify sub-categories
find_sub_categories <- function(categories) {
return(vapply(categories, function(cat) {
!is.null(cat$category_description)
}, logical(1)))
return(
vapply(
categories,
function(cat) {
!is.null(cat$category_description)
},
logical(1)
)
)
}

# Group sub-categories
group_categories <- function(categories) {
grp <- vapply(categories, function(cat) {
gsub(".p[0-9]+$", "", cat$name)
}, FUN.VALUE = "")
grp <- vapply(
categories,
function(cat) {
gsub(".p[0-9]+$", "", cat$name)
},
FUN.VALUE = ""
)
return(split(categories, grp))
}
Loading

0 comments on commit be3cdae

Please sign in to comment.