-
-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
resolve_delayed now accepts a list #74
Conversation
R/resolve_delayed.R
Outdated
@@ -3,7 +3,8 @@ | |||
#' @description `r lifecycle::badge("stable")` | |||
#' | |||
#' @param x Object of class `delayed_data` to resolve. | |||
#' @param datasets Object of class `FilteredData` to use for evaluation. | |||
#' @param datasets A named list of `data.frame` to use for evaluation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will will change the argument name once it has been decided
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mhallal1 has a good point
Code Coverage Summary
Results for commit: 164d2d3 Minimum allowed coverage is ♻️ This comment has been updated with latest results |
resolve_delayed occurs in teal. Please make necessary changes. After it's done please fix data_extract for accept list of data (currently it still depends on a FilteredData) |
The issue asked to create a new module instead of modifying the existing one. Are we settling on modifying now? |
@@ -49,7 +49,7 @@ data_extract_filter_ui <- function(filter, id = "filter") { | |||
#' the `vals` widget based on the input of the `col` widget. | |||
#' | |||
#' @param id (`character`) id string | |||
#' @param datasets (`FilteredData`) the datasets | |||
#' @param datasets (`list` of `reactive`) `data.frame`s | |||
#' @param filter (`filter_spec`) the filter generated by a call to [filter_spec()] | |||
#' @keywords internal | |||
data_extract_filter_srv <- function(id, datasets, filter) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no validation here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added validation checkmate::assert_list(datasets, types = "reactive", names = "named")
@@ -73,7 +73,7 @@ data_extract_filter_srv <- function(id, datasets, filter) { | |||
filter <<- filter | |||
} else if (!rlang::is_empty(input$col)) { | |||
choices <- value_choices( | |||
datasets$get_data(filter$dataname, filtered = TRUE), | |||
datasets[[filter$dataname]](), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without a validation this could fail with an bad error message.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
currently value_choices expects a data.frame not a reactive. We want to support only the reactive now or both of them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what if datasets[[filter$dataname]]
is a data.frame not a reactive
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
data_extract_srv
--> data_extract_single_srv
--> data_extract_filter_srv
is the sequence actually in function. We handle whether the content of datasets
is a reactive or data.frame already in data_extract_srv
so we do not have to worry downstream.
R/data_extract_module.R
Outdated
#' adsl_reactive_input <- data_extract_srv( | ||
#' id = "adsl_var", | ||
#' datasets = datasets, | ||
#' data_extract_spec = adsl_extract | ||
#' ) | ||
#' # using a list of reactive `data.frame` as input to `datasets` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
commented code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, in this example i give both ways to use data_extract_srv
with a FilteredData
object and with a list of data.frame
and a list of join_keys
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove commented code or uncomment it :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added 1. and 2. for both options.
data_extract_srv <- function(id, datasets, data_extract_spec) { | ||
checkmate::assert_class(datasets, "FilteredData") | ||
data_extract_srv <- function(id, datasets, data_extract_spec, ...) { | ||
checkmate::assert_multi_class(datasets, c("FilteredData", "list")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice to have additional validation here, if It is a list then should contains ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you could add it in data_extract_srv.list
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check for reactive
content is added in data_extract_srv.list
:
checkmate::assert_list(datasets, types = "reactive", names = "named")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
data_extract_srv.list <- function(id, datasets, data_extract_spec, keys, ...) {
checkmate::assert_list(datasets, names = "named")
checkmate::assert_list(keys, names = "named")
checkmate::assert_names(names(datasets), permutation.of = names(keys))
...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
input_vals <- as.numeric(input_vals) | ||
} | ||
for (col in input_col) { | ||
# replace NA with NA_character_ for class consistency | ||
if (any(vapply(input_vals, identical, logical(1), "NA")) && | ||
anyNA(datasets$get_data(x$dataname)[col]) && | ||
!any(vapply(unique(datasets$get_data(x$dataname)[col]), identical, logical(1), "NA"))) { | ||
anyNA(datasets[[x$dataname]]()[col]) && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are we sure datasets[[x$dataname]] is a reactive?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added this check in data_extract_read_srv
:
checkmate::assert_list(datasets, types = "reactive", names = "named")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I take only a quick look. I understand you will add some update here, then I will go second round. In this second round I will focus more on tests too.
It will be great to have a list what function expect a list of reactive data.frame or/and a list of data.frame.
Please add |
Co-authored-by: Maciej Nasinski <[email protected]>
Co-authored-by: Maciej Nasinski <[email protected]>
Done. |
replaced by #76 to make the branch name consistent with insightsengineering/teal#674 |
closes #67
resolve_delayed now accepts a list of data.frame or a single data.frame.
EDIT MAHMOUD:
resolve
which is the alternative ofresolve_delayed
that accepts a list of data.frame and a list of join.keys as input. The common functions have been moved intoresolve.R
asresolve_delayed.R
will be removed in the future.resolve_delayed
is updated to useresolve
internally.resolve
function and add a section at the end of every test file for the tests ofresolve_delayed
preceded with the title# with resolve_delayed
. This would not decrease the coverage throughout the coming sprint and would facilitate the removal ofresolve_delayed
and its tests in the future.resolve
tests to not useFilteredData
where not needed.data_extract_srv
forFilteredData
and list of reactive data.frames.STILL TO DO:
check_data_extract_spec_react(datasets, data_extract_spec)
step that was removed.