Skip to content

Commit

Permalink
fix: use attribute to pass the verification status instead of reverif…
Browse files Browse the repository at this point in the history
…ying everytime
  • Loading branch information
vedhav committed Jan 25, 2024
1 parent 99cbebb commit b3432fa
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 42 deletions.
27 changes: 13 additions & 14 deletions R/module_nested_tabs.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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) {
Expand All @@ -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
Expand All @@ -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) }.")

Expand Down Expand Up @@ -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))
}

Expand Down Expand Up @@ -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")

Expand All @@ -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
Expand Down
8 changes: 2 additions & 6 deletions R/module_tabs_with_filters.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")
Expand All @@ -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) {
Expand Down
3 changes: 1 addition & 2 deletions R/module_teal.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
Expand Down
1 change: 1 addition & 0 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
5 changes: 1 addition & 4 deletions man/dot-datasets_to_data.Rd

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

15 changes: 4 additions & 11 deletions man/module_nested_tabs.Rd

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

6 changes: 1 addition & 5 deletions man/module_tabs_with_filters.Rd

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

0 comments on commit b3432fa

Please sign in to comment.