From d861556366a44fff7155329d95c04ca84178fe1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Revilla?= Date: Fri, 13 Dec 2024 16:41:03 +0100 Subject: [PATCH 01/17] Internal srv_teal_data change --- R/module_teal_data.R | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/R/module_teal_data.R b/R/module_teal_data.R index bc8d92239..2119fd051 100644 --- a/R/module_teal_data.R +++ b/R/module_teal_data.R @@ -62,10 +62,10 @@ srv_teal_data <- function(id, moduleServer(id, function(input, output, session) { logger::log_debug("srv_teal_data initializing.") is_transform_failed[[id]] <- FALSE - data_out <- data_module(id = "data") - data_handled <- reactive(tryCatch(data_out(), error = function(e) e)) - observeEvent(data_handled(), { - if (!inherits(data_handled(), "teal_data")) { + module_out <- data_module(id = "data") + try_module_out <- reactive(tryCatch(module_out (), error = function(e) e)) + observeEvent(try_module_out(), { + if (!inherits(try_module_out(), "teal_data")) { is_transform_failed[[id]] <- TRUE } else { is_transform_failed[[id]] <- FALSE @@ -89,7 +89,7 @@ srv_teal_data <- function(id, srv_validate_reactive_teal_data( "validate", - data = data_handled, + data = try_module_out, modules = modules, validate_shiny_silent_error = validate_shiny_silent_error, hide_validation_error = is_previous_failed From 810c385dd551abcfb4aa0cd1a73aca350fb74d74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Revilla?= Date: Mon, 16 Dec 2024 12:25:40 +0100 Subject: [PATCH 02/17] Rename {ui,srv}_teal_data to {ui,srv}_teal_data_module. --- R/module_teal_data.R | 22 ++++++++++++++++------ man/module_teal_data.Rd | 11 +++++++++-- 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/R/module_teal_data.R b/R/module_teal_data.R index 2119fd051..81b8c9986 100644 --- a/R/module_teal_data.R +++ b/R/module_teal_data.R @@ -37,7 +37,10 @@ NULL #' @rdname module_teal_data -ui_teal_data <- function(id, data_module = function(id) NULL) { +#' @aliases ui_teal_data +#' @note +#' `ui_teal_data_module` was renamed from `ui_teal_data`. +ui_teal_data_module <- function(id, data_module = function(id) NULL) { checkmate::assert_string(id) checkmate::assert_function(data_module, args = "id") ns <- NS(id) @@ -48,12 +51,17 @@ ui_teal_data <- function(id, data_module = function(id) NULL) { ) } +ui_teal_data <- ui_teal_data_module + #' @rdname module_teal_data -srv_teal_data <- function(id, - data_module = function(id) NULL, - modules = NULL, - validate_shiny_silent_error = TRUE, - is_transform_failed = reactiveValues()) { +#' @aliases srv_teal_data +#' @note +#' `srv_teal_data_module` was renamed from `srv_teal_data`. +srv_teal_data_module <- function(id, + data_module = function(id) NULL, + modules = NULL, + validate_shiny_silent_error = TRUE, + is_transform_failed = reactiveValues()) { checkmate::assert_string(id) checkmate::assert_function(data_module, args = "id") checkmate::assert_multi_class(modules, c("teal_modules", "teal_module"), null.ok = TRUE) @@ -97,6 +105,8 @@ srv_teal_data <- function(id, }) } +srv_teal_data <- srv_teal_data_module + #' @rdname module_teal_data ui_validate_reactive_teal_data <- function(id) { ns <- NS(id) diff --git a/man/module_teal_data.Rd b/man/module_teal_data.Rd index 9c2e756b5..1a8afe9bf 100644 --- a/man/module_teal_data.Rd +++ b/man/module_teal_data.Rd @@ -2,15 +2,17 @@ % Please edit documentation in R/module_teal_data.R \name{module_teal_data} \alias{module_teal_data} +\alias{ui_teal_data_module} \alias{ui_teal_data} +\alias{srv_teal_data_module} \alias{srv_teal_data} \alias{ui_validate_reactive_teal_data} \alias{srv_validate_reactive_teal_data} \title{Execute and validate \code{teal_data_module}} \usage{ -ui_teal_data(id, data_module = function(id) NULL) +ui_teal_data_module(id, data_module = function(id) NULL) -srv_teal_data( +srv_teal_data_module( id, data_module = function(id) NULL, modules = NULL, @@ -52,6 +54,11 @@ This is a low level module to handle \code{teal_data_module} execution and valid \code{\link[=srv_teal]{srv_teal()}} accepts various \code{data} objects and eventually they are all transformed to \code{reactive} \code{\link[teal.data:teal_data]{teal.data::teal_data()}} which is a standard data class in whole \code{teal} framework. } +\note{ +\code{ui_teal_data_module} was renamed from \code{ui_teal_data}. + +\code{srv_teal_data_module} was renamed from \code{srv_teal_data}. +} \section{data validation}{ From 874aaf151559b6476aa5f106e8889945d827086d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Revilla?= Date: Mon, 16 Dec 2024 12:49:58 +0100 Subject: [PATCH 03/17] rename on srv_validate_reactive_teal_data data to teal_data_r --- R/module_teal_data.R | 14 +++++++------- R/module_transform_data.R | 8 ++++---- man/module_teal_data.Rd | 4 ++-- man/module_transform_data.Rd | 4 ++-- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/R/module_teal_data.R b/R/module_teal_data.R index 81b8c9986..81ec0331f 100644 --- a/R/module_teal_data.R +++ b/R/module_teal_data.R @@ -21,7 +21,7 @@ #' (except error 1). #' #' @param id (`character(1)`) Module id -#' @param data (`reactive teal_data`) +#' @param teal_data_r (`reactive teal_data`) #' @param data_module (`teal_data_module`) #' @param modules (`teal_modules` or `teal_module`) For `datanames` validation purpose #' @param validate_shiny_silent_error (`logical`) If `TRUE`, then `shiny.silent.error` is validated and @@ -97,7 +97,7 @@ srv_teal_data_module <- function(id, srv_validate_reactive_teal_data( "validate", - data = try_module_out, + teal_data_r = try_module_out, modules = modules, validate_shiny_silent_error = validate_shiny_silent_error, hide_validation_error = is_previous_failed @@ -127,7 +127,7 @@ ui_validate_reactive_teal_data <- function(id) { #' @rdname module_teal_data srv_validate_reactive_teal_data <- function(id, # nolint: object_length - data, + teal_data_r, modules = NULL, validate_shiny_silent_error = FALSE, hide_validation_error = reactive(FALSE)) { @@ -137,9 +137,9 @@ srv_validate_reactive_teal_data <- function(id, # nolint: object_length moduleServer(id, function(input, output, session) { # there is an empty reactive cycle on `init` and `data_rv` has `shiny.silent.error` class - srv_validate_error("silent_error", data, validate_shiny_silent_error) - srv_check_class_teal_data("class_teal_data", data) - srv_check_module_datanames("shiny_warnings", data, modules) + srv_validate_error("silent_error", teal_data_r, validate_shiny_silent_error) + srv_check_class_teal_data("class_teal_data", teal_data_r) + srv_check_module_datanames("shiny_warnings", teal_data_r, modules) output$previous_failed <- renderUI({ if (hide_validation_error()) { shinyjs::hide("validate_messages") @@ -150,7 +150,7 @@ srv_validate_reactive_teal_data <- function(id, # nolint: object_length } }) - .trigger_on_success(data) + .trigger_on_success(teal_data_r) }) } diff --git a/R/module_transform_data.R b/R/module_transform_data.R index 8acaa9538..fdd80a046 100644 --- a/R/module_transform_data.R +++ b/R/module_transform_data.R @@ -74,12 +74,12 @@ ui_transform_teal_data <- function(id, transformators, class = "well") { #' @export #' @rdname module_transform_data -srv_transform_teal_data <- function(id, data, transformators, modules = NULL, is_transform_failed = reactiveValues()) { +srv_transform_teal_data <- function(id, teal_data_r, transformators, modules = NULL, is_transform_failed = reactiveValues()) { checkmate::assert_string(id) - assert_reactive(data) + assert_reactive(teal_data_r) checkmate::assert_class(modules, "teal_module", null.ok = TRUE) if (length(transformators) == 0L) { - return(data) + return(teal_data_r) } if (inherits(transformators, "teal_transform_module")) { transformators <- list(transformators) @@ -142,7 +142,7 @@ srv_transform_teal_data <- function(id, data, transformators, modules = NULL, is }) }, x = names(transformators), - init = data + init = teal_data_r ) module_output }) diff --git a/man/module_teal_data.Rd b/man/module_teal_data.Rd index 1a8afe9bf..81424952e 100644 --- a/man/module_teal_data.Rd +++ b/man/module_teal_data.Rd @@ -24,7 +24,7 @@ ui_validate_reactive_teal_data(id) srv_validate_reactive_teal_data( id, - data, + teal_data_r, modules = NULL, validate_shiny_silent_error = FALSE, hide_validation_error = reactive(FALSE) @@ -43,7 +43,7 @@ srv_validate_reactive_teal_data( Help to determine if any previous transformator failed, so that following transformators can be disabled and display a generic failure message.} -\item{data}{(\verb{reactive teal_data})} +\item{teal_data_r}{(\verb{reactive teal_data})} } \value{ \code{reactive} \code{teal_data} diff --git a/man/module_transform_data.Rd b/man/module_transform_data.Rd index 4dcd515ae..416535c7b 100644 --- a/man/module_transform_data.Rd +++ b/man/module_transform_data.Rd @@ -10,7 +10,7 @@ ui_transform_teal_data(id, transformators, class = "well") srv_transform_teal_data( id, - data, + teal_data_r, transformators, modules = NULL, is_transform_failed = reactiveValues() @@ -23,7 +23,7 @@ srv_transform_teal_data( \item{class}{(character(1)) CSS class to be added in the \code{div} wrapper tag.} -\item{data}{(\verb{reactive teal_data})} +\item{teal_data_r}{(\verb{reactive teal_data})} \item{modules}{(\code{teal_modules} or \code{teal_module}) For \code{datanames} validation purpose} From 78499d92d6cd094a8dc352b29610999bcc1a3b1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Revilla?= Date: Mon, 16 Dec 2024 12:49:58 +0100 Subject: [PATCH 04/17] Update text message --- R/module_teal_data.R | 16 ++++++++-------- R/module_transform_data.R | 8 ++++---- man/module_teal_data.Rd | 4 ++-- man/module_transform_data.Rd | 4 ++-- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/R/module_teal_data.R b/R/module_teal_data.R index 81b8c9986..d053de307 100644 --- a/R/module_teal_data.R +++ b/R/module_teal_data.R @@ -21,7 +21,7 @@ #' (except error 1). #' #' @param id (`character(1)`) Module id -#' @param data (`reactive teal_data`) +#' @param teal_data_r (`reactive teal_data`) #' @param data_module (`teal_data_module`) #' @param modules (`teal_modules` or `teal_module`) For `datanames` validation purpose #' @param validate_shiny_silent_error (`logical`) If `TRUE`, then `shiny.silent.error` is validated and @@ -68,7 +68,7 @@ srv_teal_data_module <- function(id, checkmate::assert_class(is_transform_failed, "reactivevalues") moduleServer(id, function(input, output, session) { - logger::log_debug("srv_teal_data initializing.") + logger::log_debug("srv_teal_data_module initializing.") is_transform_failed[[id]] <- FALSE module_out <- data_module(id = "data") try_module_out <- reactive(tryCatch(module_out (), error = function(e) e)) @@ -97,7 +97,7 @@ srv_teal_data_module <- function(id, srv_validate_reactive_teal_data( "validate", - data = try_module_out, + teal_data_r = try_module_out, modules = modules, validate_shiny_silent_error = validate_shiny_silent_error, hide_validation_error = is_previous_failed @@ -127,7 +127,7 @@ ui_validate_reactive_teal_data <- function(id) { #' @rdname module_teal_data srv_validate_reactive_teal_data <- function(id, # nolint: object_length - data, + teal_data_r, modules = NULL, validate_shiny_silent_error = FALSE, hide_validation_error = reactive(FALSE)) { @@ -137,9 +137,9 @@ srv_validate_reactive_teal_data <- function(id, # nolint: object_length moduleServer(id, function(input, output, session) { # there is an empty reactive cycle on `init` and `data_rv` has `shiny.silent.error` class - srv_validate_error("silent_error", data, validate_shiny_silent_error) - srv_check_class_teal_data("class_teal_data", data) - srv_check_module_datanames("shiny_warnings", data, modules) + srv_validate_error("silent_error", teal_data_r, validate_shiny_silent_error) + srv_check_class_teal_data("class_teal_data", teal_data_r) + srv_check_module_datanames("shiny_warnings", teal_data_r, modules) output$previous_failed <- renderUI({ if (hide_validation_error()) { shinyjs::hide("validate_messages") @@ -150,7 +150,7 @@ srv_validate_reactive_teal_data <- function(id, # nolint: object_length } }) - .trigger_on_success(data) + .trigger_on_success(teal_data_r) }) } diff --git a/R/module_transform_data.R b/R/module_transform_data.R index 8acaa9538..fdd80a046 100644 --- a/R/module_transform_data.R +++ b/R/module_transform_data.R @@ -74,12 +74,12 @@ ui_transform_teal_data <- function(id, transformators, class = "well") { #' @export #' @rdname module_transform_data -srv_transform_teal_data <- function(id, data, transformators, modules = NULL, is_transform_failed = reactiveValues()) { +srv_transform_teal_data <- function(id, teal_data_r, transformators, modules = NULL, is_transform_failed = reactiveValues()) { checkmate::assert_string(id) - assert_reactive(data) + assert_reactive(teal_data_r) checkmate::assert_class(modules, "teal_module", null.ok = TRUE) if (length(transformators) == 0L) { - return(data) + return(teal_data_r) } if (inherits(transformators, "teal_transform_module")) { transformators <- list(transformators) @@ -142,7 +142,7 @@ srv_transform_teal_data <- function(id, data, transformators, modules = NULL, is }) }, x = names(transformators), - init = data + init = teal_data_r ) module_output }) diff --git a/man/module_teal_data.Rd b/man/module_teal_data.Rd index 1a8afe9bf..81424952e 100644 --- a/man/module_teal_data.Rd +++ b/man/module_teal_data.Rd @@ -24,7 +24,7 @@ ui_validate_reactive_teal_data(id) srv_validate_reactive_teal_data( id, - data, + teal_data_r, modules = NULL, validate_shiny_silent_error = FALSE, hide_validation_error = reactive(FALSE) @@ -43,7 +43,7 @@ srv_validate_reactive_teal_data( Help to determine if any previous transformator failed, so that following transformators can be disabled and display a generic failure message.} -\item{data}{(\verb{reactive teal_data})} +\item{teal_data_r}{(\verb{reactive teal_data})} } \value{ \code{reactive} \code{teal_data} diff --git a/man/module_transform_data.Rd b/man/module_transform_data.Rd index 4dcd515ae..416535c7b 100644 --- a/man/module_transform_data.Rd +++ b/man/module_transform_data.Rd @@ -10,7 +10,7 @@ ui_transform_teal_data(id, transformators, class = "well") srv_transform_teal_data( id, - data, + teal_data_r, transformators, modules = NULL, is_transform_failed = reactiveValues() @@ -23,7 +23,7 @@ srv_transform_teal_data( \item{class}{(character(1)) CSS class to be added in the \code{div} wrapper tag.} -\item{data}{(\verb{reactive teal_data})} +\item{teal_data_r}{(\verb{reactive teal_data})} \item{modules}{(\code{teal_modules} or \code{teal_module}) For \code{datanames} validation purpose} From 3e0eea953ba4e54c267777032fc14cb8d61d2c8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Revilla?= Date: Mon, 16 Dec 2024 18:33:26 +0100 Subject: [PATCH 05/17] Fix test failures --- R/dummy_functions.R | 2 +- R/module_nested_tabs.R | 2 +- tests/testthat/test-teal_transform_module.R | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/R/dummy_functions.R b/R/dummy_functions.R index b04c4a488..75de38b49 100644 --- a/R/dummy_functions.R +++ b/R/dummy_functions.R @@ -62,7 +62,7 @@ example_module <- function(label = "example teal module", table_data_decorated_no_print <- srv_transform_teal_data( "decorate", - data = table_data, + teal_data_r = table_data, transformators = decorators ) table_data_decorated <- reactive(within(req(table_data_decorated_no_print()), expr = object)) diff --git a/R/module_nested_tabs.R b/R/module_nested_tabs.R index e26533cc9..1bc6a799b 100644 --- a/R/module_nested_tabs.R +++ b/R/module_nested_tabs.R @@ -263,7 +263,7 @@ srv_teal_module.teal_module <- function(id, is_transform_failed <- reactiveValues() transformed_teal_data <- srv_transform_teal_data( "data_transform", - data = filtered_teal_data, + teal_data_r = filtered_teal_data, transformators = modules$transformators, modules = modules, is_transform_failed = is_transform_failed diff --git a/tests/testthat/test-teal_transform_module.R b/tests/testthat/test-teal_transform_module.R index 74c8837ac..9246d4ac0 100644 --- a/tests/testthat/test-teal_transform_module.R +++ b/tests/testthat/test-teal_transform_module.R @@ -12,7 +12,7 @@ testthat::describe("make_teal_transform_server produces a valid teal_transform_m app = srv_transform_teal_data, args = list( id = "test", - data = reactive(teal.data::teal_data(data1 = iris, data2 = mtcars)), + teal_data_r = reactive(teal.data::teal_data(data1 = iris, data2 = mtcars)), transformators = output_decorator ), expr = { @@ -35,7 +35,7 @@ testthat::describe("make_teal_transform_server produces a valid teal_transform_m app = srv_transform_teal_data, args = list( id = "test", - data = reactive(teal.data::teal_data(data1 = iris, data2 = mtcars)), + teal_data_r = reactive(teal.data::teal_data(data1 = iris, data2 = mtcars)), transformators = output_decorator ), expr = { @@ -68,7 +68,7 @@ testthat::test_that( app = srv_transform_teal_data, args = list( id = initial_id, - data = reactive(within(teal_data(), iris <- iris)), + teal_data_r = reactive(within(teal_data(), iris <- iris)), transformators = ttm ), expr = { From 6868ae2df9f1f1b9724a39aa9400a00fb2489e69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Revilla?= Date: Tue, 17 Dec 2024 10:21:13 +0100 Subject: [PATCH 06/17] Remove ui_teal_data and srv_teal_data in favor of ui_teal_data_module & srv_teal_data_module --- R/module_teal_data.R | 4 ---- 1 file changed, 4 deletions(-) diff --git a/R/module_teal_data.R b/R/module_teal_data.R index d053de307..966504b6d 100644 --- a/R/module_teal_data.R +++ b/R/module_teal_data.R @@ -51,8 +51,6 @@ ui_teal_data_module <- function(id, data_module = function(id) NULL) { ) } -ui_teal_data <- ui_teal_data_module - #' @rdname module_teal_data #' @aliases srv_teal_data #' @note @@ -105,8 +103,6 @@ srv_teal_data_module <- function(id, }) } -srv_teal_data <- srv_teal_data_module - #' @rdname module_teal_data ui_validate_reactive_teal_data <- function(id) { ns <- NS(id) From 74c1537c7b59bad5f366f06a0801dd88aacff2dd Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 17 Dec 2024 10:05:33 +0000 Subject: [PATCH 07/17] [skip style] [skip vbump] Restyle files --- R/module_teal_data.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/module_teal_data.R b/R/module_teal_data.R index 966504b6d..8575997e2 100644 --- a/R/module_teal_data.R +++ b/R/module_teal_data.R @@ -68,8 +68,8 @@ srv_teal_data_module <- function(id, moduleServer(id, function(input, output, session) { logger::log_debug("srv_teal_data_module initializing.") is_transform_failed[[id]] <- FALSE - module_out <- data_module(id = "data") - try_module_out <- reactive(tryCatch(module_out (), error = function(e) e)) + module_out <- data_module(id = "data") + try_module_out <- reactive(tryCatch(module_out(), error = function(e) e)) observeEvent(try_module_out(), { if (!inherits(try_module_out(), "teal_data")) { is_transform_failed[[id]] <- TRUE From 9338f9bbda6919a422ae25e9baf262d9b93ce916 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Revilla?= Date: Tue, 17 Dec 2024 11:21:30 +0100 Subject: [PATCH 08/17] Fix style --- R/module_teal_data.R | 4 ++-- R/module_transform_data.R | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/R/module_teal_data.R b/R/module_teal_data.R index 966504b6d..8575997e2 100644 --- a/R/module_teal_data.R +++ b/R/module_teal_data.R @@ -68,8 +68,8 @@ srv_teal_data_module <- function(id, moduleServer(id, function(input, output, session) { logger::log_debug("srv_teal_data_module initializing.") is_transform_failed[[id]] <- FALSE - module_out <- data_module(id = "data") - try_module_out <- reactive(tryCatch(module_out (), error = function(e) e)) + module_out <- data_module(id = "data") + try_module_out <- reactive(tryCatch(module_out(), error = function(e) e)) observeEvent(try_module_out(), { if (!inherits(try_module_out(), "teal_data")) { is_transform_failed[[id]] <- TRUE diff --git a/R/module_transform_data.R b/R/module_transform_data.R index fdd80a046..f3f9c7240 100644 --- a/R/module_transform_data.R +++ b/R/module_transform_data.R @@ -74,7 +74,11 @@ ui_transform_teal_data <- function(id, transformators, class = "well") { #' @export #' @rdname module_transform_data -srv_transform_teal_data <- function(id, teal_data_r, transformators, modules = NULL, is_transform_failed = reactiveValues()) { +srv_transform_teal_data <- function(id, + teal_data_r, + transformators, + modules = NULL, + is_transform_failed = reactiveValues()) { checkmate::assert_string(id) assert_reactive(teal_data_r) checkmate::assert_class(modules, "teal_module", null.ok = TRUE) From 7009e896ca2e01fbcfa8c231465b5b78925f1b70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Revilla?= Date: Wed, 18 Dec 2024 09:33:02 +0100 Subject: [PATCH 09/17] Replace teal_data_r, teal_data_rv, and data_rv to data --- R/dummy_functions.R | 2 +- R/module_filter_data.R | 10 ++++---- R/module_init_data.R | 2 +- R/module_nested_tabs.R | 28 ++++++++++----------- R/module_teal.R | 12 ++++----- R/module_teal_data.R | 16 ++++++------ R/module_transform_data.R | 8 +++--- R/teal_data_module-eval_code.R | 10 ++++---- tests/testthat/test-teal_transform_module.R | 6 ++--- 9 files changed, 47 insertions(+), 47 deletions(-) diff --git a/R/dummy_functions.R b/R/dummy_functions.R index 75de38b49..b04c4a488 100644 --- a/R/dummy_functions.R +++ b/R/dummy_functions.R @@ -62,7 +62,7 @@ example_module <- function(label = "example teal module", table_data_decorated_no_print <- srv_transform_teal_data( "decorate", - teal_data_r = table_data, + data = table_data, transformators = decorators ) table_data_decorated <- reactive(within(req(table_data_decorated_no_print()), expr = object)) diff --git a/R/module_filter_data.R b/R/module_filter_data.R index 14dc7b4ec..f5b84e106 100644 --- a/R/module_filter_data.R +++ b/R/module_filter_data.R @@ -24,7 +24,7 @@ ui_filter_data <- function(id) { } #' @rdname module_filter_data -srv_filter_data <- function(id, datasets, active_datanames, data_rv, is_active) { +srv_filter_data <- function(id, datasets, active_datanames, data, is_active) { assert_reactive(datasets) moduleServer(id, function(input, output, session) { active_corrected <- reactive(intersect(active_datanames(), datasets()$datanames())) @@ -42,10 +42,10 @@ srv_filter_data <- function(id, datasets, active_datanames, data_rv, is_active) }) }) - trigger_data <- .observe_active_filter_changed(datasets, is_active, active_corrected, data_rv) + trigger_data <- .observe_active_filter_changed(datasets, is_active, active_corrected, data) eventReactive(trigger_data(), { - .make_filtered_teal_data(modules, data = data_rv(), datasets = datasets(), datanames = active_corrected()) + .make_filtered_teal_data(modules, data = data(), datasets = datasets(), datanames = active_corrected()) }) }) } @@ -69,12 +69,12 @@ srv_filter_data <- function(id, datasets, active_datanames, data_rv, is_active) } #' @rdname module_filter_data -.observe_active_filter_changed <- function(datasets, is_active, active_datanames, data_rv) { +.observe_active_filter_changed <- function(datasets, is_active, active_datanames, data) { previous_signature <- reactiveVal(NULL) filter_changed <- reactive({ req(inherits(datasets(), "FilteredData")) new_signature <- c( - teal.code::get_code(data_rv()), + teal.code::get_code(data()), .get_filter_expr(datasets = datasets(), datanames = active_datanames()) ) if (!identical(previous_signature(), new_signature)) { diff --git a/R/module_init_data.R b/R/module_init_data.R index 3bbe7d8bb..0b3bb1046 100644 --- a/R/module_init_data.R +++ b/R/module_init_data.R @@ -53,7 +53,7 @@ srv_init_data <- function(id, data) { moduleServer(id, function(input, output, session) { logger::log_debug("srv_data initializing.") - # data_rv contains teal_data object + # data contains teal_data object # either passed to teal::init or returned from teal_data_module data_out <- if (inherits(data, "teal_data_module")) { output$data <- renderUI(data$ui(id = session$ns("teal_data_module"))) diff --git a/R/module_nested_tabs.R b/R/module_nested_tabs.R index 1bc6a799b..923294c0b 100644 --- a/R/module_nested_tabs.R +++ b/R/module_nested_tabs.R @@ -8,7 +8,7 @@ #' #' @inheritParams module_teal #' -#' @param data_rv (`reactive` returning `teal_data`) +#' @param data (`reactive` returning `teal_data`) #' #' @param slices_global (`reactiveVal` returning `modules_teal_slices`) #' see [`module_filter_manager`] @@ -138,7 +138,7 @@ ui_teal_module.teal_module <- function(id, modules, depth = 0L) { #' @rdname module_teal_module srv_teal_module <- function(id, - data_rv, + data, modules, datasets = NULL, slices_global, @@ -146,7 +146,7 @@ srv_teal_module <- function(id, data_load_status = reactive("ok"), is_active = reactive(TRUE)) { checkmate::assert_string(id) - assert_reactive(data_rv) + assert_reactive(data) checkmate::assert_multi_class(modules, c("teal_modules", "teal_module")) assert_reactive(datasets, null.ok = TRUE) checkmate::assert_class(slices_global, ".slicesGlobal") @@ -158,7 +158,7 @@ srv_teal_module <- function(id, #' @rdname module_teal_module #' @export srv_teal_module.default <- function(id, - data_rv, + data, modules, datasets = NULL, slices_global, @@ -171,7 +171,7 @@ srv_teal_module.default <- function(id, #' @rdname module_teal_module #' @export srv_teal_module.teal_modules <- function(id, - data_rv, + data, modules, datasets = NULL, slices_global, @@ -201,7 +201,7 @@ srv_teal_module.teal_modules <- function(id, function(module_id) { srv_teal_module( id = module_id, - data_rv = data_rv, + data = data, modules = modules$children[[module_id]], datasets = datasets, slices_global = slices_global, @@ -223,7 +223,7 @@ srv_teal_module.teal_modules <- function(id, #' @rdname module_teal_module #' @export srv_teal_module.teal_module <- function(id, - data_rv, + data, modules, datasets = NULL, slices_global, @@ -235,13 +235,13 @@ srv_teal_module.teal_module <- function(id, module_out <- reactiveVal() active_datanames <- reactive({ - .resolve_module_datanames(data = data_rv(), modules = modules) + .resolve_module_datanames(data = data(), modules = modules) }) if (is.null(datasets)) { - datasets <- eventReactive(data_rv(), { - req(inherits(data_rv(), "teal_data")) + datasets <- eventReactive(data(), { + req(inherits(data(), "teal_data")) logger::log_debug("srv_teal_module@1 initializing module-specific FilteredData") - teal_data_to_filtered_data(data_rv(), datanames = active_datanames()) + teal_data_to_filtered_data(data(), datanames = active_datanames()) }) } @@ -257,13 +257,13 @@ srv_teal_module.teal_module <- function(id, "filter_panel", datasets = datasets, active_datanames = active_datanames, - data_rv = data_rv, + data = data, is_active = is_active ) is_transform_failed <- reactiveValues() transformed_teal_data <- srv_transform_teal_data( "data_transform", - teal_data_r = filtered_teal_data, + data = filtered_teal_data, transformators = modules$transformators, modules = modules, is_transform_failed = is_transform_failed @@ -346,7 +346,7 @@ srv_teal_module.teal_module <- function(id, } .resolve_module_datanames <- function(data, modules) { - stopifnot("data_rv must be teal_data object." = inherits(data, "teal_data")) + stopifnot("data must be teal_data object." = inherits(data, "teal_data")) if (is.null(modules$datanames) || identical(modules$datanames, "all")) { names(data) } else { diff --git a/R/module_teal.R b/R/module_teal.R index 66cddbfce..2f6554f2d 100644 --- a/R/module_teal.R +++ b/R/module_teal.R @@ -201,7 +201,7 @@ srv_teal <- function(id, data, modules, filter = teal_slices()) { data_validated <- .trigger_on_success(data_pulled) - data_rv <- reactive({ + data <- reactive({ req(inherits(data_validated(), "teal_data")) is_filter_ok <- check_filter_datanames(filter, names(data_validated())) if (!isTRUE(is_filter_ok)) { @@ -226,10 +226,10 @@ srv_teal <- function(id, data, modules, filter = teal_slices()) { }) datasets_rv <- if (!isTRUE(attr(filter, "module_specific"))) { - eventReactive(data_rv(), { - req(inherits(data_rv(), "teal_data")) + eventReactive(data(), { + req(inherits(data(), "teal_data")) logger::log_debug("srv_teal@1 initializing FilteredData") - teal_data_to_filtered_data(data_rv()) + teal_data_to_filtered_data(data()) }) } @@ -252,7 +252,7 @@ srv_teal <- function(id, data, modules, filter = teal_slices()) { ) if (attr(data, "once")) { - observeEvent(data_rv(), once = TRUE, { + observeEvent(data(), once = TRUE, { logger::log_debug("srv_teal@2 removing data tab.") # when once = TRUE we pull data once and then remove data tab removeTab("teal_modules-active_tab", target = "teal_data_module") @@ -271,7 +271,7 @@ srv_teal <- function(id, data, modules, filter = teal_slices()) { slices_global <- methods::new(".slicesGlobal", filter, module_labels) modules_output <- srv_teal_module( id = "teal_modules", - data_rv = data_rv, + data = data, datasets = datasets_rv, modules = modules, slices_global = slices_global, diff --git a/R/module_teal_data.R b/R/module_teal_data.R index 8575997e2..8619b7ced 100644 --- a/R/module_teal_data.R +++ b/R/module_teal_data.R @@ -21,7 +21,7 @@ #' (except error 1). #' #' @param id (`character(1)`) Module id -#' @param teal_data_r (`reactive teal_data`) +#' @param data (`reactive teal_data`) #' @param data_module (`teal_data_module`) #' @param modules (`teal_modules` or `teal_module`) For `datanames` validation purpose #' @param validate_shiny_silent_error (`logical`) If `TRUE`, then `shiny.silent.error` is validated and @@ -95,7 +95,7 @@ srv_teal_data_module <- function(id, srv_validate_reactive_teal_data( "validate", - teal_data_r = try_module_out, + data = try_module_out, modules = modules, validate_shiny_silent_error = validate_shiny_silent_error, hide_validation_error = is_previous_failed @@ -123,7 +123,7 @@ ui_validate_reactive_teal_data <- function(id) { #' @rdname module_teal_data srv_validate_reactive_teal_data <- function(id, # nolint: object_length - teal_data_r, + data, modules = NULL, validate_shiny_silent_error = FALSE, hide_validation_error = reactive(FALSE)) { @@ -132,10 +132,10 @@ srv_validate_reactive_teal_data <- function(id, # nolint: object_length checkmate::assert_flag(validate_shiny_silent_error) moduleServer(id, function(input, output, session) { - # there is an empty reactive cycle on `init` and `data_rv` has `shiny.silent.error` class - srv_validate_error("silent_error", teal_data_r, validate_shiny_silent_error) - srv_check_class_teal_data("class_teal_data", teal_data_r) - srv_check_module_datanames("shiny_warnings", teal_data_r, modules) + # there is an empty reactive cycle on `init` and `data` has `shiny.silent.error` class + srv_validate_error("silent_error", data, validate_shiny_silent_error) + srv_check_class_teal_data("class_teal_data", data) + srv_check_module_datanames("shiny_warnings", data, modules) output$previous_failed <- renderUI({ if (hide_validation_error()) { shinyjs::hide("validate_messages") @@ -146,7 +146,7 @@ srv_validate_reactive_teal_data <- function(id, # nolint: object_length } }) - .trigger_on_success(teal_data_r) + .trigger_on_success(data) }) } diff --git a/R/module_transform_data.R b/R/module_transform_data.R index f3f9c7240..b4c28c5ff 100644 --- a/R/module_transform_data.R +++ b/R/module_transform_data.R @@ -75,15 +75,15 @@ ui_transform_teal_data <- function(id, transformators, class = "well") { #' @export #' @rdname module_transform_data srv_transform_teal_data <- function(id, - teal_data_r, + data, transformators, modules = NULL, is_transform_failed = reactiveValues()) { checkmate::assert_string(id) - assert_reactive(teal_data_r) + assert_reactive(data) checkmate::assert_class(modules, "teal_module", null.ok = TRUE) if (length(transformators) == 0L) { - return(teal_data_r) + return(data) } if (inherits(transformators, "teal_transform_module")) { transformators <- list(transformators) @@ -146,7 +146,7 @@ srv_transform_teal_data <- function(id, }) }, x = names(transformators), - init = teal_data_r + init = data ) module_output }) diff --git a/R/teal_data_module-eval_code.R b/R/teal_data_module-eval_code.R index dff1bef14..fa95ec9f4 100644 --- a/R/teal_data_module-eval_code.R +++ b/R/teal_data_module-eval_code.R @@ -33,13 +33,13 @@ setMethod("eval_code", signature = c("teal_data_module", "character"), function( }, server = function(id) { moduleServer(id, function(input, output, session) { - teal_data_rv <- object$server("mutate_inner") - td <- eventReactive(teal_data_rv(), + data <- object$server("mutate_inner") + td <- eventReactive(data(), { - if (inherits(teal_data_rv(), c("teal_data", "qenv.error"))) { - eval_code(teal_data_rv(), code) + if (inherits(data(), c("teal_data", "qenv.error"))) { + eval_code(data(), code) } else { - teal_data_rv() + data() } }, ignoreNULL = FALSE diff --git a/tests/testthat/test-teal_transform_module.R b/tests/testthat/test-teal_transform_module.R index 9246d4ac0..74c8837ac 100644 --- a/tests/testthat/test-teal_transform_module.R +++ b/tests/testthat/test-teal_transform_module.R @@ -12,7 +12,7 @@ testthat::describe("make_teal_transform_server produces a valid teal_transform_m app = srv_transform_teal_data, args = list( id = "test", - teal_data_r = reactive(teal.data::teal_data(data1 = iris, data2 = mtcars)), + data = reactive(teal.data::teal_data(data1 = iris, data2 = mtcars)), transformators = output_decorator ), expr = { @@ -35,7 +35,7 @@ testthat::describe("make_teal_transform_server produces a valid teal_transform_m app = srv_transform_teal_data, args = list( id = "test", - teal_data_r = reactive(teal.data::teal_data(data1 = iris, data2 = mtcars)), + data = reactive(teal.data::teal_data(data1 = iris, data2 = mtcars)), transformators = output_decorator ), expr = { @@ -68,7 +68,7 @@ testthat::test_that( app = srv_transform_teal_data, args = list( id = initial_id, - teal_data_r = reactive(within(teal_data(), iris <- iris)), + data = reactive(within(teal_data(), iris <- iris)), transformators = ttm ), expr = { From 637723cc6cbfa5680b2840a8b17709b40fb92128 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 18 Dec 2024 08:47:58 +0000 Subject: [PATCH 10/17] [skip roxygen] [skip vbump] Roxygen Man Pages Auto Update --- man/TealReportCard.Rd | 1 + man/module_filter_data.Rd | 6 +++--- man/module_teal_data.Rd | 4 ++-- man/module_teal_module.Rd | 10 +++++----- man/module_transform_data.Rd | 4 ++-- 5 files changed, 13 insertions(+), 12 deletions(-) diff --git a/man/TealReportCard.Rd b/man/TealReportCard.Rd index 2503d0035..061dbb73b 100644 --- a/man/TealReportCard.Rd +++ b/man/TealReportCard.Rd @@ -45,6 +45,7 @@ card$get_content()[[1]]$get_content()
Inherited methods
  • teal.reporter::ReportCard$append_content()
  • +
  • teal.reporter::ReportCard$append_html()
  • teal.reporter::ReportCard$append_metadata()
  • teal.reporter::ReportCard$append_plot()
  • teal.reporter::ReportCard$append_rcode()
  • diff --git a/man/module_filter_data.Rd b/man/module_filter_data.Rd index 61d527b9e..a98b9d6b9 100644 --- a/man/module_filter_data.Rd +++ b/man/module_filter_data.Rd @@ -11,11 +11,11 @@ \usage{ ui_filter_data(id) -srv_filter_data(id, datasets, active_datanames, data_rv, is_active) +srv_filter_data(id, datasets, active_datanames, data, is_active) .make_filtered_teal_data(modules, data, datasets = NULL, datanames) -.observe_active_filter_changed(datasets, is_active, active_datanames, data_rv) +.observe_active_filter_changed(datasets, is_active, active_datanames, data) .get_filter_expr(datasets, datanames) } @@ -30,7 +30,7 @@ which implies in filter-panel to be "global". When \code{NULL} then filter-panel \item{active_datanames}{(\code{reactive} returning \code{character}) this module's data names} -\item{data_rv}{(\code{reactive} returning \code{teal_data})} +\item{data}{(\code{reactive} returning \code{teal_data})} \item{modules}{(\code{list} or \code{teal_modules} or \code{teal_module}) Nested list of \code{teal_modules} or \code{teal_module} objects or a single diff --git a/man/module_teal_data.Rd b/man/module_teal_data.Rd index 81424952e..1a8afe9bf 100644 --- a/man/module_teal_data.Rd +++ b/man/module_teal_data.Rd @@ -24,7 +24,7 @@ ui_validate_reactive_teal_data(id) srv_validate_reactive_teal_data( id, - teal_data_r, + data, modules = NULL, validate_shiny_silent_error = FALSE, hide_validation_error = reactive(FALSE) @@ -43,7 +43,7 @@ srv_validate_reactive_teal_data( Help to determine if any previous transformator failed, so that following transformators can be disabled and display a generic failure message.} -\item{teal_data_r}{(\verb{reactive teal_data})} +\item{data}{(\verb{reactive teal_data})} } \value{ \code{reactive} \code{teal_data} diff --git a/man/module_teal_module.Rd b/man/module_teal_module.Rd index bc46f86c6..9c4d80361 100644 --- a/man/module_teal_module.Rd +++ b/man/module_teal_module.Rd @@ -22,7 +22,7 @@ ui_teal_module(id, modules, depth = 0L) srv_teal_module( id, - data_rv, + data, modules, datasets = NULL, slices_global, @@ -33,7 +33,7 @@ srv_teal_module( \method{srv_teal_module}{default}( id, - data_rv, + data, modules, datasets = NULL, slices_global, @@ -44,7 +44,7 @@ srv_teal_module( \method{srv_teal_module}{teal_modules}( id, - data_rv, + data, modules, datasets = NULL, slices_global, @@ -55,7 +55,7 @@ srv_teal_module( \method{srv_teal_module}{teal_module}( id, - data_rv, + data, modules, datasets = NULL, slices_global, @@ -78,7 +78,7 @@ more details.} \item{depth}{(\code{integer(1)}) number which helps to determine depth of the modules nesting.} -\item{data_rv}{(\code{reactive} returning \code{teal_data})} +\item{data}{(\code{reactive} returning \code{teal_data})} \item{datasets}{(\code{reactive} returning \code{FilteredData} or \code{NULL}) When \code{datasets} is passed from the parent module (\code{srv_teal}) then \code{dataset} is a singleton diff --git a/man/module_transform_data.Rd b/man/module_transform_data.Rd index 416535c7b..4dcd515ae 100644 --- a/man/module_transform_data.Rd +++ b/man/module_transform_data.Rd @@ -10,7 +10,7 @@ ui_transform_teal_data(id, transformators, class = "well") srv_transform_teal_data( id, - teal_data_r, + data, transformators, modules = NULL, is_transform_failed = reactiveValues() @@ -23,7 +23,7 @@ srv_transform_teal_data( \item{class}{(character(1)) CSS class to be added in the \code{div} wrapper tag.} -\item{teal_data_r}{(\verb{reactive teal_data})} +\item{data}{(\verb{reactive teal_data})} \item{modules}{(\code{teal_modules} or \code{teal_module}) For \code{datanames} validation purpose} From 14fa40b04ca90927c29a3ac04d508f68de595796 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Revilla?= Date: Wed, 18 Dec 2024 10:20:38 +0100 Subject: [PATCH 11/17] Document parameter changes --- man/module_filter_data.Rd | 6 +++--- man/module_teal_data.Rd | 4 ++-- man/module_teal_module.Rd | 10 +++++----- man/module_transform_data.Rd | 4 ++-- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/man/module_filter_data.Rd b/man/module_filter_data.Rd index 61d527b9e..a98b9d6b9 100644 --- a/man/module_filter_data.Rd +++ b/man/module_filter_data.Rd @@ -11,11 +11,11 @@ \usage{ ui_filter_data(id) -srv_filter_data(id, datasets, active_datanames, data_rv, is_active) +srv_filter_data(id, datasets, active_datanames, data, is_active) .make_filtered_teal_data(modules, data, datasets = NULL, datanames) -.observe_active_filter_changed(datasets, is_active, active_datanames, data_rv) +.observe_active_filter_changed(datasets, is_active, active_datanames, data) .get_filter_expr(datasets, datanames) } @@ -30,7 +30,7 @@ which implies in filter-panel to be "global". When \code{NULL} then filter-panel \item{active_datanames}{(\code{reactive} returning \code{character}) this module's data names} -\item{data_rv}{(\code{reactive} returning \code{teal_data})} +\item{data}{(\code{reactive} returning \code{teal_data})} \item{modules}{(\code{list} or \code{teal_modules} or \code{teal_module}) Nested list of \code{teal_modules} or \code{teal_module} objects or a single diff --git a/man/module_teal_data.Rd b/man/module_teal_data.Rd index 81424952e..1a8afe9bf 100644 --- a/man/module_teal_data.Rd +++ b/man/module_teal_data.Rd @@ -24,7 +24,7 @@ ui_validate_reactive_teal_data(id) srv_validate_reactive_teal_data( id, - teal_data_r, + data, modules = NULL, validate_shiny_silent_error = FALSE, hide_validation_error = reactive(FALSE) @@ -43,7 +43,7 @@ srv_validate_reactive_teal_data( Help to determine if any previous transformator failed, so that following transformators can be disabled and display a generic failure message.} -\item{teal_data_r}{(\verb{reactive teal_data})} +\item{data}{(\verb{reactive teal_data})} } \value{ \code{reactive} \code{teal_data} diff --git a/man/module_teal_module.Rd b/man/module_teal_module.Rd index bc46f86c6..9c4d80361 100644 --- a/man/module_teal_module.Rd +++ b/man/module_teal_module.Rd @@ -22,7 +22,7 @@ ui_teal_module(id, modules, depth = 0L) srv_teal_module( id, - data_rv, + data, modules, datasets = NULL, slices_global, @@ -33,7 +33,7 @@ srv_teal_module( \method{srv_teal_module}{default}( id, - data_rv, + data, modules, datasets = NULL, slices_global, @@ -44,7 +44,7 @@ srv_teal_module( \method{srv_teal_module}{teal_modules}( id, - data_rv, + data, modules, datasets = NULL, slices_global, @@ -55,7 +55,7 @@ srv_teal_module( \method{srv_teal_module}{teal_module}( id, - data_rv, + data, modules, datasets = NULL, slices_global, @@ -78,7 +78,7 @@ more details.} \item{depth}{(\code{integer(1)}) number which helps to determine depth of the modules nesting.} -\item{data_rv}{(\code{reactive} returning \code{teal_data})} +\item{data}{(\code{reactive} returning \code{teal_data})} \item{datasets}{(\code{reactive} returning \code{FilteredData} or \code{NULL}) When \code{datasets} is passed from the parent module (\code{srv_teal}) then \code{dataset} is a singleton diff --git a/man/module_transform_data.Rd b/man/module_transform_data.Rd index 416535c7b..4dcd515ae 100644 --- a/man/module_transform_data.Rd +++ b/man/module_transform_data.Rd @@ -10,7 +10,7 @@ ui_transform_teal_data(id, transformators, class = "well") srv_transform_teal_data( id, - teal_data_r, + data, transformators, modules = NULL, is_transform_failed = reactiveValues() @@ -23,7 +23,7 @@ srv_transform_teal_data( \item{class}{(character(1)) CSS class to be added in the \code{div} wrapper tag.} -\item{teal_data_r}{(\verb{reactive teal_data})} +\item{data}{(\verb{reactive teal_data})} \item{modules}{(\code{teal_modules} or \code{teal_module}) For \code{datanames} validation purpose} From 3e0e4198e805e20c5e4e6411603dd4aa5f1eb3d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Revilla?= Date: Wed, 18 Dec 2024 10:48:15 +0100 Subject: [PATCH 12/17] Replace two more argument --- R/module_data_summary.R | 12 ++++++------ R/module_nested_tabs.R | 6 ++++-- man/module_data_summary.Rd | 2 +- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/R/module_data_summary.R b/R/module_data_summary.R index 0d2bc7b52..e6e26fe73 100644 --- a/R/module_data_summary.R +++ b/R/module_data_summary.R @@ -55,19 +55,19 @@ ui_data_summary <- function(id) { } #' @rdname module_data_summary -srv_data_summary <- function(id, teal_data) { - assert_reactive(teal_data) +srv_data_summary <- function(id, data) { + assert_reactive(data) moduleServer( id = id, function(input, output, session) { logger::log_debug("srv_data_summary initializing") summary_table <- reactive({ - req(inherits(teal_data(), "teal_data")) - if (!length(teal_data())) { + req(inherits(data(), "teal_data")) + if (!length(data())) { return(NULL) } - get_filter_overview_wrapper(teal_data) + get_filter_overview_wrapper(data) }) output$table <- renderUI({ @@ -123,7 +123,7 @@ srv_data_summary <- function(id, teal_data) { " (", vapply( summary_table()[is_unsupported, "dataname"], - function(x) class(teal_data()[[x]])[1], + function(x) class(data()[[x]])[1], character(1L) ), ")" diff --git a/R/module_nested_tabs.R b/R/module_nested_tabs.R index 923294c0b..dcb2d0590 100644 --- a/R/module_nested_tabs.R +++ b/R/module_nested_tabs.R @@ -318,7 +318,9 @@ srv_teal_module.teal_module <- function(id, } # This function calls a module server function. -.call_teal_module <- function(modules, datasets, filtered_teal_data, reporter) { +.call_teal_module <- function(modules, datasets, data, reporter) { + checkmate::assert_class(data, "reactive") + # collect arguments to run teal_module args <- c(list(id = "module"), modules$server_args) if (is_arg_used(modules$server, "reporter")) { @@ -331,7 +333,7 @@ srv_teal_module.teal_module <- function(id, } if (is_arg_used(modules$server, "data")) { - args <- c(args, data = list(filtered_teal_data)) + args <- c(args, data = list(data)) } if (is_arg_used(modules$server, "filter_panel_api")) { diff --git a/man/module_data_summary.Rd b/man/module_data_summary.Rd index 7deaf4d81..72a0db582 100644 --- a/man/module_data_summary.Rd +++ b/man/module_data_summary.Rd @@ -12,7 +12,7 @@ \usage{ ui_data_summary(id) -srv_data_summary(id, teal_data) +srv_data_summary(id, data) get_filter_overview_wrapper(teal_data) From 4d00e74f9c8844a7ca951db1636ec51d8089b400 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Revilla?= Date: Wed, 18 Dec 2024 10:48:31 +0100 Subject: [PATCH 13/17] Remove indentation of parameters --- R/module_transform_data.R | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/R/module_transform_data.R b/R/module_transform_data.R index b4c28c5ff..8acaa9538 100644 --- a/R/module_transform_data.R +++ b/R/module_transform_data.R @@ -74,11 +74,7 @@ ui_transform_teal_data <- function(id, transformators, class = "well") { #' @export #' @rdname module_transform_data -srv_transform_teal_data <- function(id, - data, - transformators, - modules = NULL, - is_transform_failed = reactiveValues()) { +srv_transform_teal_data <- function(id, data, transformators, modules = NULL, is_transform_failed = reactiveValues()) { checkmate::assert_string(id) assert_reactive(data) checkmate::assert_class(modules, "teal_module", null.ok = TRUE) From 646eacad17e06187a01de84114b90d3886c95b6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Revilla?= Date: Wed, 18 Dec 2024 12:26:32 +0100 Subject: [PATCH 14/17] Remove comment --- R/module_init_data.R | 2 -- 1 file changed, 2 deletions(-) diff --git a/R/module_init_data.R b/R/module_init_data.R index 0b3bb1046..c4f588d2d 100644 --- a/R/module_init_data.R +++ b/R/module_init_data.R @@ -53,8 +53,6 @@ srv_init_data <- function(id, data) { moduleServer(id, function(input, output, session) { logger::log_debug("srv_data initializing.") - # data contains teal_data object - # either passed to teal::init or returned from teal_data_module data_out <- if (inherits(data, "teal_data_module")) { output$data <- renderUI(data$ui(id = session$ns("teal_data_module"))) data$server("teal_data_module") From ba31b42e285b8f283776d1d4d0ef1aff99ef086e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Revilla?= Date: Wed, 18 Dec 2024 12:26:51 +0100 Subject: [PATCH 15/17] Replace reactive check for the internal function --- R/module_nested_tabs.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/module_nested_tabs.R b/R/module_nested_tabs.R index dcb2d0590..aedc1349d 100644 --- a/R/module_nested_tabs.R +++ b/R/module_nested_tabs.R @@ -319,7 +319,7 @@ srv_teal_module.teal_module <- function(id, # This function calls a module server function. .call_teal_module <- function(modules, datasets, data, reporter) { - checkmate::assert_class(data, "reactive") + assert_reactive(data) # collect arguments to run teal_module args <- c(list(id = "module"), modules$server_args) From 3e38b1087f5bf43c7ddc40eee5306a5e654f27e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Revilla?= Date: Wed, 18 Dec 2024 12:43:20 +0100 Subject: [PATCH 16/17] Avoid name conflict --- R/module_teal.R | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/R/module_teal.R b/R/module_teal.R index 2f6554f2d..749006fe9 100644 --- a/R/module_teal.R +++ b/R/module_teal.R @@ -201,7 +201,7 @@ srv_teal <- function(id, data, modules, filter = teal_slices()) { data_validated <- .trigger_on_success(data_pulled) - data <- reactive({ + data_validated_r <- reactive({ req(inherits(data_validated(), "teal_data")) is_filter_ok <- check_filter_datanames(filter, names(data_validated())) if (!isTRUE(is_filter_ok)) { @@ -226,10 +226,10 @@ srv_teal <- function(id, data, modules, filter = teal_slices()) { }) datasets_rv <- if (!isTRUE(attr(filter, "module_specific"))) { - eventReactive(data(), { - req(inherits(data(), "teal_data")) + eventReactive(data_validated_r(), { + req(inherits(data_validated_r(), "teal_data")) logger::log_debug("srv_teal@1 initializing FilteredData") - teal_data_to_filtered_data(data()) + teal_data_to_filtered_data(data_validated_r()) }) } @@ -252,7 +252,7 @@ srv_teal <- function(id, data, modules, filter = teal_slices()) { ) if (attr(data, "once")) { - observeEvent(data(), once = TRUE, { + observeEvent(data_validated_r(), once = TRUE, { logger::log_debug("srv_teal@2 removing data tab.") # when once = TRUE we pull data once and then remove data tab removeTab("teal_modules-active_tab", target = "teal_data_module") @@ -271,7 +271,7 @@ srv_teal <- function(id, data, modules, filter = teal_slices()) { slices_global <- methods::new(".slicesGlobal", filter, module_labels) modules_output <- srv_teal_module( id = "teal_modules", - data = data, + data = data_validated_r, datasets = datasets_rv, modules = modules, slices_global = slices_global, From ed9704139124ac97ce36bdb8f86a04be8317640d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Revilla?= Date: Wed, 18 Dec 2024 14:21:47 +0100 Subject: [PATCH 17/17] Adopt latest feedback --- R/module_teal.R | 24 ++++++++++++------------ tests/testthat/test-module_teal.R | 6 +++--- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/R/module_teal.R b/R/module_teal.R index 749006fe9..7834d1d8a 100644 --- a/R/module_teal.R +++ b/R/module_teal.R @@ -186,7 +186,7 @@ srv_teal <- function(id, data, modules, filter = teal_slices()) { } ) - data_pulled <- srv_init_data("data", data = data) + data_handled <- srv_init_data("data", data = data) validate_ui <- tags$div( id = session$ns("validate_messages"), @@ -195,13 +195,13 @@ srv_teal <- function(id, data, modules, filter = teal_slices()) { ui_validate_error(session$ns("silent_error")), ui_check_module_datanames(session$ns("datanames_warning")) ) - srv_check_class_teal_data("class_teal_data", data_pulled) - srv_validate_error("silent_error", data_pulled, validate_shiny_silent_error = FALSE) - srv_check_module_datanames("datanames_warning", data_pulled, modules) + srv_check_class_teal_data("class_teal_data", data_handled) + srv_validate_error("silent_error", data_handled, validate_shiny_silent_error = FALSE) + srv_check_module_datanames("datanames_warning", data_handled, modules) - data_validated <- .trigger_on_success(data_pulled) + data_validated <- .trigger_on_success(data_handled) - data_validated_r <- reactive({ + data_signatured <- reactive({ req(inherits(data_validated(), "teal_data")) is_filter_ok <- check_filter_datanames(filter, names(data_validated())) if (!isTRUE(is_filter_ok)) { @@ -216,7 +216,7 @@ srv_teal <- function(id, data, modules, filter = teal_slices()) { }) data_load_status <- reactive({ - if (inherits(data_pulled(), "teal_data")) { + if (inherits(data_handled(), "teal_data")) { "ok" } else if (inherits(data, "teal_data_module")) { "teal_data_module failed" @@ -226,10 +226,10 @@ srv_teal <- function(id, data, modules, filter = teal_slices()) { }) datasets_rv <- if (!isTRUE(attr(filter, "module_specific"))) { - eventReactive(data_validated_r(), { - req(inherits(data_validated_r(), "teal_data")) + eventReactive(data_signatured(), { + req(inherits(data_signatured(), "teal_data")) logger::log_debug("srv_teal@1 initializing FilteredData") - teal_data_to_filtered_data(data_validated_r()) + teal_data_to_filtered_data(data_signatured()) }) } @@ -252,7 +252,7 @@ srv_teal <- function(id, data, modules, filter = teal_slices()) { ) if (attr(data, "once")) { - observeEvent(data_validated_r(), once = TRUE, { + observeEvent(data_signatured(), once = TRUE, { logger::log_debug("srv_teal@2 removing data tab.") # when once = TRUE we pull data once and then remove data tab removeTab("teal_modules-active_tab", target = "teal_data_module") @@ -271,7 +271,7 @@ srv_teal <- function(id, data, modules, filter = teal_slices()) { slices_global <- methods::new(".slicesGlobal", filter, module_labels) modules_output <- srv_teal_module( id = "teal_modules", - data = data_validated_r, + data = data_signatured, datasets = datasets_rv, modules = modules, slices_global = slices_global, diff --git a/tests/testthat/test-module_teal.R b/tests/testthat/test-module_teal.R index b4eced130..12d0c1c0e 100644 --- a/tests/testthat/test-module_teal.R +++ b/tests/testthat/test-module_teal.R @@ -395,7 +395,7 @@ testthat::describe("srv_teal teal_modules", { ), expr = { testthat::expect_null(modules_output$module_1()) - testthat::expect_s3_class(data_pulled(), "shiny.silent.error") + testthat::expect_s3_class(data_handled(), "shiny.silent.error") session$setInputs(`teal_modules-active_tab` = "module_1") testthat::expect_null(modules_output$module_1()) } @@ -422,7 +422,7 @@ testthat::describe("srv_teal teal_modules", { ), expr = { testthat::expect_null(modules_output$module_1()) - testthat::expect_s3_class(data_pulled(), "simpleError") + testthat::expect_s3_class(data_handled(), "simpleError") session$setInputs(`teal_modules-active_tab` = "module_1") testthat::expect_null(modules_output$module_1()) } @@ -449,7 +449,7 @@ testthat::describe("srv_teal teal_modules", { ), expr = { testthat::expect_null(modules_output$module_1()) - testthat::expect_s3_class(data_pulled(), "qenv.error") + testthat::expect_s3_class(data_handled(), "qenv.error") session$setInputs(`teal_modules-active_tab` = "module_1") testthat::expect_null(modules_output$module_1()) }