Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ Title: Generalized Processing Helper with R
Version: 0.0.0.9000
Authors@R:
person("Daniel", "RAKOTOMALALA", , "rakdanielh@gmail.com", role = c("aut", "cre"))
Description: PoC Shiny app / Package that provides tools for applying a user-defined function over a parameterized input table with logging and parallel execution.
Description: PoC Shiny app / Package that provides tools for applying a
user-defined function over a parameterized input table with logging
and parallel execution.
License: MIT + file LICENSE
Imports:
callr,
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Generated by roxygen2: do not edit by hand

export(create_demo_framework)
export(from_function_to_mask)
export(run_app)
import(shiny)
importFrom(golem,activate_js)
Expand Down
23 changes: 23 additions & 0 deletions R/fct_from_function_to_mask.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#' From function to mask
#'
#' @description Transform a function into a genproc compatible mask
#'
#' @param func Function 1L. Input function
#' @return data.frame. Corresponding mask
#'
#' @export
from_function_to_mask <- function(func) {

if (! is.function(func)) stop("func must be a function")
formals <- formals(func)

# minimal iteration: values must be atomic
check_atomic <- unlist(lapply(formals,
\(x) (is.atomic(x) & (length(x) == 1)) |
is.name(x)))
if (! all(check_atomic)) {
stop("In this PoC version, values in each func argument must be an atomic of length 1 or 0")
}
values <- lapply(formals, \(x) if (is.name(x)) as.character(x) else x)
data.frame(values)
}
1 change: 1 addition & 0 deletions dev/02_dev.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ golem::add_module(name = "log", with_test = TRUE) # Name of the module
golem::add_fct("add_trycatch_logrow", with_test = TRUE)
golem::add_fct("rename_function_params", with_test = TRUE)
golem::add_fct("create_demo_framework", with_test = FALSE)
golem::add_fct("from_function_to_mask", with_test = TRUE)
golem::add_fct("genproc", with_test = TRUE)
golem::add_utils("helpers", with_test = TRUE)

Expand Down
17 changes: 17 additions & 0 deletions man/from_function_to_mask.Rd

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

8 changes: 8 additions & 0 deletions tests/testthat/test-fct_from_function_to_mask.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
test_that("from_function_to_mask is consistent", {
expect_error(from_function_to_mask(function (x = list(1), y = 2) x + y),
"In this PoC version, values in each func argument must be an atomic of length 1 or 0")
expect_equal(from_function_to_mask(function (x = 1, y) x / y),
structure(list(x = 1, y = ""),
class = "data.frame",
row.names = c(NA, -1L)))
})
Loading