From 904f80b7f6362689c9e09cb56f26f610479ef788 Mon Sep 17 00:00:00 2001 From: vedhav Date: Thu, 25 Jan 2024 11:39:33 +0530 Subject: [PATCH 1/4] fix: pass the check status to the main teal_data function call --- R/module_nested_tabs.R | 18 ++++++++++-------- R/module_tabs_with_filters.R | 6 ++++-- R/module_teal.R | 3 ++- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/R/module_nested_tabs.R b/R/module_nested_tabs.R index 73afb01be8..4a979164f5 100644 --- a/R/module_nested_tabs.R +++ b/R/module_nested_tabs.R @@ -140,7 +140,7 @@ ui_nested_tabs.teal_module <- function(id, modules, datasets, depth = 0L, is_mod #' @rdname module_nested_tabs srv_nested_tabs <- function(id, datasets, modules, is_module_specific = FALSE, - reporter = teal.reporter::Reporter$new()) { + reporter = teal.reporter::Reporter$new(), check = FALSE) { checkmate::assert_multi_class(modules, c("teal_modules", "teal_module")) checkmate::assert_class(reporter, "Reporter") UseMethod("srv_nested_tabs", modules) @@ -149,14 +149,14 @@ srv_nested_tabs <- function(id, datasets, modules, is_module_specific = FALSE, #' @rdname module_nested_tabs #' @export srv_nested_tabs.default <- function(id, datasets, modules, is_module_specific = FALSE, - reporter = teal.reporter::Reporter$new()) { + reporter = teal.reporter::Reporter$new(), check = FALSE) { stop("Modules class not supported: ", paste(class(modules), collapse = " ")) } #' @rdname module_nested_tabs #' @export srv_nested_tabs.teal_modules <- function(id, datasets, modules, is_module_specific = FALSE, - reporter = teal.reporter::Reporter$new()) { + reporter = teal.reporter::Reporter$new(), check = FALSE) { checkmate::assert_list(datasets, types = c("list", "FilteredData")) moduleServer(id = id, module = function(input, output, session) { @@ -171,7 +171,8 @@ srv_nested_tabs.teal_modules <- function(id, datasets, modules, is_module_specif datasets = datasets[[labels[module_id]]], modules = modules$children[[module_id]], is_module_specific = is_module_specific, - reporter = reporter + reporter = reporter, + check = check ) }, simplify = FALSE @@ -196,7 +197,7 @@ srv_nested_tabs.teal_modules <- function(id, datasets, modules, is_module_specif #' @rdname module_nested_tabs #' @export srv_nested_tabs.teal_module <- function(id, datasets, modules, is_module_specific = TRUE, - reporter = teal.reporter::Reporter$new()) { + reporter = teal.reporter::Reporter$new(), check = FALSE) { checkmate::assert_class(datasets, "FilteredData") logger::log_trace("srv_nested_tabs.teal_module initializing the module: { deparse1(modules$label) }.") @@ -232,7 +233,7 @@ srv_nested_tabs.teal_module <- function(id, datasets, modules, is_module_specifi } if (is_arg_used(modules$server, "data")) { - data <- eventReactive(trigger_data(), .datasets_to_data(modules, datasets)) + data <- eventReactive(trigger_data(), .datasets_to_data(modules, datasets, check)) args <- c(args, data = list(data)) } @@ -270,7 +271,7 @@ srv_nested_tabs.teal_module <- function(id, datasets, modules, is_module_specifi #' @return A `teal_data` object. #' #' @keywords internal -.datasets_to_data <- function(module, datasets) { +.datasets_to_data <- function(module, datasets, check) { checkmate::assert_class(module, "teal_module") checkmate::assert_class(datasets, "FilteredData") @@ -291,9 +292,10 @@ srv_nested_tabs.teal_module <- function(id, datasets, modules, is_module_specifi get_datasets_code(datanames, datasets, hashes) ) + do.call( teal.data::teal_data, - args = c(data, code = list(code), join_keys = list(datasets$get_join_keys()[datanames])) + args = c(data, code = list(code), join_keys = list(datasets$get_join_keys()[datanames]), check = check) ) } diff --git a/R/module_tabs_with_filters.R b/R/module_tabs_with_filters.R index 7c42fc2ea0..0608584d17 100644 --- a/R/module_tabs_with_filters.R +++ b/R/module_tabs_with_filters.R @@ -101,7 +101,8 @@ srv_tabs_with_filters <- function(id, datasets, modules, reporter = teal.reporter::Reporter$new(), - filter = teal_slices()) { + filter = teal_slices(), + check = FALSE) { checkmate::assert_class(modules, "teal_modules") checkmate::assert_list(datasets, types = c("list", "FilteredData")) checkmate::assert_class(reporter, "Reporter") @@ -118,7 +119,8 @@ srv_tabs_with_filters <- function(id, datasets = datasets, modules = modules, reporter = reporter, - is_module_specific = is_module_specific + is_module_specific = is_module_specific, + check = check ) if (!is_module_specific) { diff --git a/R/module_teal.R b/R/module_teal.R index cdecfaf639..e138c5e3e3 100644 --- a/R/module_teal.R +++ b/R/module_teal.R @@ -262,7 +262,8 @@ srv_teal <- function(id, modules, teal_data_rv, filter = teal_slices()) { datasets = datasets, modules = modules, reporter = reporter, - filter = filter + filter = filter, + check = teal_data_rv()@verified ) return(active_module) }) From 0533f31277ae99013cf4c83570745781a2b2ed82 Mon Sep 17 00:00:00 2001 From: "27856297+dependabot-preview[bot]@users.noreply.github.com" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Thu, 25 Jan 2024 06:17:24 +0000 Subject: [PATCH 2/4] [skip actions] Roxygen Man Pages Auto Update --- DESCRIPTION | 2 +- man/dot-datasets_to_data.Rd | 2 +- man/module_nested_tabs.Rd | 12 ++++++++---- man/module_tabs_with_filters.Rd | 3 ++- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 70b576b913..ce3ba6295a 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -76,7 +76,7 @@ Encoding: UTF-8 Language: en-US LazyData: true Roxygen: list(markdown = TRUE) -RoxygenNote: 7.3.0 +RoxygenNote: 7.3.1 Collate: 'dummy_functions.R' 'get_rcode_utils.R' diff --git a/man/dot-datasets_to_data.Rd b/man/dot-datasets_to_data.Rd index 1789e9bd71..b6ad7ffc37 100644 --- a/man/dot-datasets_to_data.Rd +++ b/man/dot-datasets_to_data.Rd @@ -4,7 +4,7 @@ \alias{.datasets_to_data} \title{Convert \code{FilteredData} to reactive list of datasets of the \code{teal_data} type.} \usage{ -.datasets_to_data(module, datasets) +.datasets_to_data(module, datasets, check) } \arguments{ \item{module}{(\code{teal_module}) module where needed filters are taken from} diff --git a/man/module_nested_tabs.Rd b/man/module_nested_tabs.Rd index e4d2620e15..202593e29a 100644 --- a/man/module_nested_tabs.Rd +++ b/man/module_nested_tabs.Rd @@ -25,7 +25,8 @@ srv_nested_tabs( datasets, modules, is_module_specific = FALSE, - reporter = teal.reporter::Reporter$new() + reporter = teal.reporter::Reporter$new(), + check = FALSE ) \method{srv_nested_tabs}{default}( @@ -33,7 +34,8 @@ srv_nested_tabs( datasets, modules, is_module_specific = FALSE, - reporter = teal.reporter::Reporter$new() + reporter = teal.reporter::Reporter$new(), + check = FALSE ) \method{srv_nested_tabs}{teal_modules}( @@ -41,7 +43,8 @@ srv_nested_tabs( datasets, modules, is_module_specific = FALSE, - reporter = teal.reporter::Reporter$new() + reporter = teal.reporter::Reporter$new(), + check = FALSE ) \method{srv_nested_tabs}{teal_module}( @@ -49,7 +52,8 @@ srv_nested_tabs( datasets, modules, is_module_specific = TRUE, - reporter = teal.reporter::Reporter$new() + reporter = teal.reporter::Reporter$new(), + check = FALSE ) } \arguments{ diff --git a/man/module_tabs_with_filters.Rd b/man/module_tabs_with_filters.Rd index 03163535dc..c5ec08822d 100644 --- a/man/module_tabs_with_filters.Rd +++ b/man/module_tabs_with_filters.Rd @@ -13,7 +13,8 @@ srv_tabs_with_filters( datasets, modules, reporter = teal.reporter::Reporter$new(), - filter = teal_slices() + filter = teal_slices(), + check = FALSE ) } \arguments{ From 99cbebb8ff5616973bfb10849f783ae029ce4488 Mon Sep 17 00:00:00 2001 From: vedhav Date: Thu, 25 Jan 2024 12:03:40 +0530 Subject: [PATCH 3/4] docs: update docs with arg definition of `check` --- R/module_nested_tabs.R | 7 ++++++- R/module_tabs_with_filters.R | 2 ++ man/dot-datasets_to_data.Rd | 5 ++++- man/module_nested_tabs.Rd | 3 +++ man/module_tabs_with_filters.Rd | 3 +++ 5 files changed, 18 insertions(+), 2 deletions(-) diff --git a/R/module_nested_tabs.R b/R/module_nested_tabs.R index 4a979164f5..06a0573c0e 100644 --- a/R/module_nested_tabs.R +++ b/R/module_nested_tabs.R @@ -23,6 +23,9 @@ #' @param is_module_specific (`logical(1)`)\cr #' flag determining if the filter panel is global or module-specific. #' When set to `TRUE`, a filter panel is called inside of each module tab. +#' @param check (`logical`) reproducibility check - whether to perform a check that the data creation +#' code included in the object definitions actually produces those objects. +#' #' @return depending on class of `modules`, `ui_nested_tabs` returns: #' - `teal_module`: instantiated UI of the module #' - `teal_modules`: `tabsetPanel` with each tab corresponding to recursively @@ -268,10 +271,12 @@ srv_nested_tabs.teal_module <- function(id, datasets, modules, is_module_specifi #' #' @param module (`teal_module`) module where needed filters are taken from #' @param datasets (`FilteredData`) object where needed data are taken from +#' @param check (`logical`) reproducibility check - whether to perform a check that the data creation +#' code included in the object definitions actually produces those objects. #' @return A `teal_data` object. #' #' @keywords internal -.datasets_to_data <- function(module, datasets, check) { +.datasets_to_data <- function(module, datasets, check = FALSE) { checkmate::assert_class(module, "teal_module") checkmate::assert_class(datasets, "FilteredData") diff --git a/R/module_tabs_with_filters.R b/R/module_tabs_with_filters.R index 0608584d17..cbeb3e204d 100644 --- a/R/module_tabs_with_filters.R +++ b/R/module_tabs_with_filters.R @@ -20,6 +20,8 @@ #' of the `modules` argument and list names must correspond to the labels in `modules`. #' When filter is not module-specific then list contains the same object in all elements. #' @param reporter (`Reporter`) object from `teal.reporter` +#' @param check (`logical`) reproducibility check - whether to perform a check that the data creation +#' code included in the object definitions actually produces those objects. #' #' @return A `tagList` of The main menu, place holders for filters and #' place holders for the teal modules diff --git a/man/dot-datasets_to_data.Rd b/man/dot-datasets_to_data.Rd index b6ad7ffc37..a1338b4fdb 100644 --- a/man/dot-datasets_to_data.Rd +++ b/man/dot-datasets_to_data.Rd @@ -4,12 +4,15 @@ \alias{.datasets_to_data} \title{Convert \code{FilteredData} to reactive list of datasets of the \code{teal_data} type.} \usage{ -.datasets_to_data(module, datasets, check) +.datasets_to_data(module, datasets, check = FALSE) } \arguments{ \item{module}{(\code{teal_module}) module where needed filters are taken from} \item{datasets}{(\code{FilteredData}) object where needed data are taken from} + +\item{check}{(\code{logical}) reproducibility check - whether to perform a check that the data creation +code included in the object definitions actually produces those objects.} } \value{ A \code{teal_data} object. diff --git a/man/module_nested_tabs.Rd b/man/module_nested_tabs.Rd index 202593e29a..d03bd866ea 100644 --- a/man/module_nested_tabs.Rd +++ b/man/module_nested_tabs.Rd @@ -74,6 +74,9 @@ flag determining if the filter panel is global or module-specific. When set to \code{TRUE}, a filter panel is called inside of each module tab.} \item{reporter}{(\code{Reporter}) object from \code{teal.reporter}} + +\item{check}{(\code{logical}) reproducibility check - whether to perform a check that the data creation +code included in the object definitions actually produces those objects.} } \value{ depending on class of \code{modules}, \code{ui_nested_tabs} returns: diff --git a/man/module_tabs_with_filters.Rd b/man/module_tabs_with_filters.Rd index c5ec08822d..2f55abb0a5 100644 --- a/man/module_tabs_with_filters.Rd +++ b/man/module_tabs_with_filters.Rd @@ -28,6 +28,9 @@ of the \code{modules} argument and list names must correspond to the labels in \ When filter is not module-specific then list contains the same object in all elements.} \item{reporter}{(\code{Reporter}) object from \code{teal.reporter}} + +\item{check}{(\code{logical}) reproducibility check - whether to perform a check that the data creation +code included in the object definitions actually produces those objects.} } \value{ A \code{tagList} of The main menu, place holders for filters and From b3432fa6255eca123e67399acf08152311bca21d Mon Sep 17 00:00:00 2001 From: vedhav Date: Thu, 25 Jan 2024 13:00:06 +0530 Subject: [PATCH 4/4] fix: use attribute to pass the verification status instead of reverifying everytime --- R/module_nested_tabs.R | 27 +++++++++++++-------------- R/module_tabs_with_filters.R | 8 ++------ R/module_teal.R | 3 +-- R/utils.R | 1 + man/dot-datasets_to_data.Rd | 5 +---- man/module_nested_tabs.Rd | 15 ++++----------- man/module_tabs_with_filters.Rd | 6 +----- 7 files changed, 23 insertions(+), 42 deletions(-) diff --git a/R/module_nested_tabs.R b/R/module_nested_tabs.R index 06a0573c0e..dc84f86c75 100644 --- a/R/module_nested_tabs.R +++ b/R/module_nested_tabs.R @@ -23,8 +23,6 @@ #' @param is_module_specific (`logical(1)`)\cr #' flag determining if the filter panel is global or module-specific. #' When set to `TRUE`, a filter panel is called inside of each module tab. -#' @param check (`logical`) reproducibility check - whether to perform a check that the data creation -#' code included in the object definitions actually produces those objects. #' #' @return depending on class of `modules`, `ui_nested_tabs` returns: #' - `teal_module`: instantiated UI of the module @@ -143,7 +141,7 @@ ui_nested_tabs.teal_module <- function(id, modules, datasets, depth = 0L, is_mod #' @rdname module_nested_tabs srv_nested_tabs <- function(id, datasets, modules, is_module_specific = FALSE, - reporter = teal.reporter::Reporter$new(), check = FALSE) { + reporter = teal.reporter::Reporter$new()) { checkmate::assert_multi_class(modules, c("teal_modules", "teal_module")) checkmate::assert_class(reporter, "Reporter") UseMethod("srv_nested_tabs", modules) @@ -152,14 +150,14 @@ srv_nested_tabs <- function(id, datasets, modules, is_module_specific = FALSE, #' @rdname module_nested_tabs #' @export srv_nested_tabs.default <- function(id, datasets, modules, is_module_specific = FALSE, - reporter = teal.reporter::Reporter$new(), check = FALSE) { + reporter = teal.reporter::Reporter$new()) { stop("Modules class not supported: ", paste(class(modules), collapse = " ")) } #' @rdname module_nested_tabs #' @export srv_nested_tabs.teal_modules <- function(id, datasets, modules, is_module_specific = FALSE, - reporter = teal.reporter::Reporter$new(), check = FALSE) { + reporter = teal.reporter::Reporter$new()) { checkmate::assert_list(datasets, types = c("list", "FilteredData")) moduleServer(id = id, module = function(input, output, session) { @@ -174,8 +172,7 @@ srv_nested_tabs.teal_modules <- function(id, datasets, modules, is_module_specif datasets = datasets[[labels[module_id]]], modules = modules$children[[module_id]], is_module_specific = is_module_specific, - reporter = reporter, - check = check + reporter = reporter ) }, simplify = FALSE @@ -200,7 +197,7 @@ srv_nested_tabs.teal_modules <- function(id, datasets, modules, is_module_specif #' @rdname module_nested_tabs #' @export srv_nested_tabs.teal_module <- function(id, datasets, modules, is_module_specific = TRUE, - reporter = teal.reporter::Reporter$new(), check = FALSE) { + reporter = teal.reporter::Reporter$new()) { checkmate::assert_class(datasets, "FilteredData") logger::log_trace("srv_nested_tabs.teal_module initializing the module: { deparse1(modules$label) }.") @@ -236,7 +233,7 @@ srv_nested_tabs.teal_module <- function(id, datasets, modules, is_module_specifi } if (is_arg_used(modules$server, "data")) { - data <- eventReactive(trigger_data(), .datasets_to_data(modules, datasets, check)) + data <- eventReactive(trigger_data(), .datasets_to_data(modules, datasets)) args <- c(args, data = list(data)) } @@ -271,12 +268,11 @@ srv_nested_tabs.teal_module <- function(id, datasets, modules, is_module_specifi #' #' @param module (`teal_module`) module where needed filters are taken from #' @param datasets (`FilteredData`) object where needed data are taken from -#' @param check (`logical`) reproducibility check - whether to perform a check that the data creation -#' code included in the object definitions actually produces those objects. +#' #' @return A `teal_data` object. #' #' @keywords internal -.datasets_to_data <- function(module, datasets, check = FALSE) { +.datasets_to_data <- function(module, datasets) { checkmate::assert_class(module, "teal_module") checkmate::assert_class(datasets, "FilteredData") @@ -298,10 +294,13 @@ srv_nested_tabs.teal_module <- function(id, datasets, modules, is_module_specifi ) - do.call( + data <- do.call( teal.data::teal_data, - args = c(data, code = list(code), join_keys = list(datasets$get_join_keys()[datanames]), check = check) + args = c(data, code = list(code), join_keys = list(datasets$get_join_keys()[datanames])) ) + + data@verified <- attr(datasets, "verification_status") + return(data) } #' Get the hash of a dataset diff --git a/R/module_tabs_with_filters.R b/R/module_tabs_with_filters.R index cbeb3e204d..7c42fc2ea0 100644 --- a/R/module_tabs_with_filters.R +++ b/R/module_tabs_with_filters.R @@ -20,8 +20,6 @@ #' of the `modules` argument and list names must correspond to the labels in `modules`. #' When filter is not module-specific then list contains the same object in all elements. #' @param reporter (`Reporter`) object from `teal.reporter` -#' @param check (`logical`) reproducibility check - whether to perform a check that the data creation -#' code included in the object definitions actually produces those objects. #' #' @return A `tagList` of The main menu, place holders for filters and #' place holders for the teal modules @@ -103,8 +101,7 @@ srv_tabs_with_filters <- function(id, datasets, modules, reporter = teal.reporter::Reporter$new(), - filter = teal_slices(), - check = FALSE) { + filter = teal_slices()) { checkmate::assert_class(modules, "teal_modules") checkmate::assert_list(datasets, types = c("list", "FilteredData")) checkmate::assert_class(reporter, "Reporter") @@ -121,8 +118,7 @@ srv_tabs_with_filters <- function(id, datasets = datasets, modules = modules, reporter = reporter, - is_module_specific = is_module_specific, - check = check + is_module_specific = is_module_specific ) if (!is_module_specific) { diff --git a/R/module_teal.R b/R/module_teal.R index e138c5e3e3..cdecfaf639 100644 --- a/R/module_teal.R +++ b/R/module_teal.R @@ -262,8 +262,7 @@ srv_teal <- function(id, modules, teal_data_rv, filter = teal_slices()) { datasets = datasets, modules = modules, reporter = reporter, - filter = filter, - check = teal_data_rv()@verified + filter = filter ) return(active_module) }) diff --git a/R/utils.R b/R/utils.R index 99ba006535..63434747c7 100644 --- a/R/utils.R +++ b/R/utils.R @@ -66,6 +66,7 @@ teal_data_to_filtered_data <- function(x, datanames = teal_data_datanames(x)) { ) # Piggy-back entire pre-processing code so that filtering code can be appended later. attr(ans, "preprocessing_code") <- teal.code::get_code(x) + attr(ans, "verification_status") <- x@verified ans } diff --git a/man/dot-datasets_to_data.Rd b/man/dot-datasets_to_data.Rd index a1338b4fdb..1789e9bd71 100644 --- a/man/dot-datasets_to_data.Rd +++ b/man/dot-datasets_to_data.Rd @@ -4,15 +4,12 @@ \alias{.datasets_to_data} \title{Convert \code{FilteredData} to reactive list of datasets of the \code{teal_data} type.} \usage{ -.datasets_to_data(module, datasets, check = FALSE) +.datasets_to_data(module, datasets) } \arguments{ \item{module}{(\code{teal_module}) module where needed filters are taken from} \item{datasets}{(\code{FilteredData}) object where needed data are taken from} - -\item{check}{(\code{logical}) reproducibility check - whether to perform a check that the data creation -code included in the object definitions actually produces those objects.} } \value{ A \code{teal_data} object. diff --git a/man/module_nested_tabs.Rd b/man/module_nested_tabs.Rd index d03bd866ea..e4d2620e15 100644 --- a/man/module_nested_tabs.Rd +++ b/man/module_nested_tabs.Rd @@ -25,8 +25,7 @@ srv_nested_tabs( datasets, modules, is_module_specific = FALSE, - reporter = teal.reporter::Reporter$new(), - check = FALSE + reporter = teal.reporter::Reporter$new() ) \method{srv_nested_tabs}{default}( @@ -34,8 +33,7 @@ srv_nested_tabs( datasets, modules, is_module_specific = FALSE, - reporter = teal.reporter::Reporter$new(), - check = FALSE + reporter = teal.reporter::Reporter$new() ) \method{srv_nested_tabs}{teal_modules}( @@ -43,8 +41,7 @@ srv_nested_tabs( datasets, modules, is_module_specific = FALSE, - reporter = teal.reporter::Reporter$new(), - check = FALSE + reporter = teal.reporter::Reporter$new() ) \method{srv_nested_tabs}{teal_module}( @@ -52,8 +49,7 @@ srv_nested_tabs( datasets, modules, is_module_specific = TRUE, - reporter = teal.reporter::Reporter$new(), - check = FALSE + reporter = teal.reporter::Reporter$new() ) } \arguments{ @@ -74,9 +70,6 @@ flag determining if the filter panel is global or module-specific. When set to \code{TRUE}, a filter panel is called inside of each module tab.} \item{reporter}{(\code{Reporter}) object from \code{teal.reporter}} - -\item{check}{(\code{logical}) reproducibility check - whether to perform a check that the data creation -code included in the object definitions actually produces those objects.} } \value{ depending on class of \code{modules}, \code{ui_nested_tabs} returns: diff --git a/man/module_tabs_with_filters.Rd b/man/module_tabs_with_filters.Rd index 2f55abb0a5..03163535dc 100644 --- a/man/module_tabs_with_filters.Rd +++ b/man/module_tabs_with_filters.Rd @@ -13,8 +13,7 @@ srv_tabs_with_filters( datasets, modules, reporter = teal.reporter::Reporter$new(), - filter = teal_slices(), - check = FALSE + filter = teal_slices() ) } \arguments{ @@ -28,9 +27,6 @@ of the \code{modules} argument and list names must correspond to the labels in \ When filter is not module-specific then list contains the same object in all elements.} \item{reporter}{(\code{Reporter}) object from \code{teal.reporter}} - -\item{check}{(\code{logical}) reproducibility check - whether to perform a check that the data creation -code included in the object definitions actually produces those objects.} } \value{ A \code{tagList} of The main menu, place holders for filters and