Skip to content
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

Teal refactor #598

Merged
merged 22 commits into from
Nov 4, 2022
Merged

Teal refactor #598

merged 22 commits into from
Nov 4, 2022

Conversation

pawelru
Copy link
Contributor

@pawelru pawelru commented Sep 15, 2022

Part of insightsengineering/teal#731

FYI @shajoezhu once this goes in SME will be able to test the refactor hasn't broken anything

gogonzo and others added 2 commits September 7, 2022 10:35
* Implement quosure and data to the module

Co-authored-by: Mahmoud Hallal <mahmoud.hallal@roche.com>
Co-authored-by: Maciej Nasinski <nasinski.maciej@gmail.com>
Co-authored-by: Nikolas Burkoff <nikolas.burkoff@roche.com>
mapply(expression = res, id = paste(names(res), "call", sep = "_"), plot_stack_push)
teal.code::chunks_push_chunks(plot_stack)
teal.code::chunks_safe_eval()
all_code <- shiny::reactive({
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rename to all_q for consistency

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will rename all reactives returning qenv to have _q suffix.

table_stack_push <- function(...) {
teal.code::chunks_push(..., chunks = table_stack)
}
q1 <- mmrm_fit()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why "1"? do we have q2 there?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is repeated multiple times for other modules as well.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will fix all the qenv objects to qenv, qenv1, ... etc.

R/tm_g_barchart_simple.R Outdated Show resolved Hide resolved
Comment on lines -387 to +368
chunk$push(
bquote({
attr(counts[[.(get_n_name(groupby_vars))]], "label") <- "Count" # for plot
counts <- counts %>%
dplyr::group_by_at(.(as.vector(groupby_vars))) %>%
dplyr::slice(1) %>%
dplyr::ungroup() %>%
dplyr::select(.(as.vector(groupby_vars)), dplyr::starts_with("n_"))
}),
id = "add_label_n_group_by_call"
quo3 <- teal.code::eval_code(
quo2,
as.expression(
c(
bquote(attr(counts[[.(get_n_name(groupby_vars))]], "label") <- "Count"),
bquote(
counts <- counts %>%
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

previously it was bquote({... <\n> ...}) and you converted this into as.expression(c(buote(...), bquote(...))) and yours is more complex. May I ask what was the motivation?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm trying to avoid the { in the code. I'll change it to the

qenv1 <- eval_code()
qenv2 <- eval_code(qenv1)

R/tm_g_barchart_simple.R Outdated Show resolved Hide resolved
@@ -583,7 +594,7 @@ srv_g_forest_rsp <- function(id,

do.call(what = "validate_standard_inputs", validate_args)

teal::validate_one_row_per_id(anl_m$data(), key = c("USUBJID", "STUDYID", input_paramcd))
teal::validate_one_row_per_id(q1[["ANL"]], key = c("USUBJID", "STUDYID", input_paramcd))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

few lines above you did: anl <- q1[["ANL"]] so feel free to use it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WDYT? would it be more convenient to do anl_merged_df <- reactive(anl_merged_q()[["ANL"]]) and then use that reactive clause throughout the server?

list(arm_var, paramcd, subgroup_var, strata_var)
),
modal_title = label
verbatim_content = reactive(teal.code::get_code(output_q())),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WDYT? would it be more convenient to do q_code <- reactive(teal.code::get_code(output_q())) and use it throughout the server?
I am looking for creating some kind of template for module that is easy to follow by module developers

Comment on lines +445 to +449
merged <- list(
anl_input_r = anl_merged_input,
adsl_input_r = adsl_merged_input,
anl_q_r = anl_merged_q
)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so this is yet another way of managing objects
please make it more consistent across modules

Comment on lines -742 to +749
adsl_filtered <- datasets$get_data(parentname, filtered = TRUE)
anl_filtered <- datasets$get_data(dataname, filtered = TRUE)
adsl_filtered <- data[[parentname]]()
anl_filtered <- data[[dataname]]()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it correct to use data variable here? In other modules you get filtered datasets from merged_q variable

@nikolas-burkoff nikolas-burkoff changed the title Teal refactor@main Teal refactor Oct 27, 2022
@nikolas-burkoff nikolas-burkoff marked this pull request as ready for review October 27, 2022 12:47
@github-actions
Copy link
Contributor

github-actions bot commented Oct 27, 2022

Unit Tests Summary

    1 files    32 suites   4s ⏱️
140 tests 140 ✔️ 0 💤 0
155 runs  155 ✔️ 0 💤 0

Results for commit 4c9531f.

♻️ This comment has been updated with latest results.

@gogonzo
Copy link
Contributor

gogonzo commented Nov 4, 2022

I'm taking over the issue to address all the comments - please contact me before if you are planning to commit.

BLAZEWIM and others added 6 commits November 4, 2022 14:01
# Pull Request

This one line 
```
name = "add_label_n_group_by_call"
``` 
cause the module to crash:
```
example(tm_g_barchart_simple, package = 'teal.modules.clinical')
shinyApp(app$ui, app$server)
Error in teal.code::eval_code: unused argument (name = "add_label_n_group_by_call")
```

Removing it helps, but have a look to be sure.

P.S. it is PR number 666 \m/

Signed-off-by: Marek Blazewicz <110387997+BLAZEWIM@users.noreply.github.com>
…eal.modules.clinical into teal_refactor@main
@gogonzo
Copy link
Contributor

gogonzo commented Nov 4, 2022

@pawelru your comments will be addressed here after we merge to main early next week

Copy link
Contributor

@gogonzo gogonzo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UAT passed - we addressed all functional issues.
@ruckip comments to be addressed here #667

@gogonzo gogonzo self-assigned this Nov 4, 2022
@gogonzo gogonzo merged commit f79d2c4 into main Nov 4, 2022
@gogonzo gogonzo deleted the teal_refactor@main branch November 4, 2022 16:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants