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

Duplicated decorators during an edge case of named and unnamed decorators #1325

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

m7pr
Copy link
Contributor

@m7pr m7pr commented Jan 28, 2025

Fixes #1316

Companion in tmg insightsengineering/teal.modules.general#835

There was an issue where decorators got duplicated when you passed a combination of named an unnamed decorators into the module. This module has 2 objects, so if you pass 1 unnamed decorators and one named, there should be only 3 decorators visible (1 unnamed passed to all 2, and one named pass to one named).

On feature branch

image

On main

image
Code
pkgload::load_all(".", export_all = FALSE)

library(nestcolor)
library(dplyr)

data <- teal_data()
data <- within(data, {
  ADAE <- tmc_ex_adae
  ADSL <- tmc_ex_adsl %>%
    filter(USUBJID %in% ADAE$USUBJID)
  
  ADAE$ASTDY <- structure(
    as.double(ADAE$ASTDY, unit = attr(ADAE$ASTDY, "units", exact = TRUE)),
    label = attr(ADAE$ASTDY, "label", exact = TRUE)
  )
})
join_keys(data) <- default_cdisc_join_keys[names(data)]

ADSL <- data[["ADSL"]]
ADAE <- data[["ADAE"]]

caption_decorator <- function(default_caption = "I am a good decorator", .var_to_replace = "plot") {
  teal_transform_module(
    label = "Caption",
    ui = function(id) shiny::textInput(shiny::NS(id, "footnote"), "Footnote", value = default_caption),
    server = make_teal_transform_server(
      substitute({
        
      }, env = list(.var_to_replace = as.name(.var_to_replace)))
    )
  )
}

head_decorator <- function(default_value = 6, .var_to_replace = "object") {
  teal_transform_module(
    label = "Head",
    ui = function(id) shiny::numericInput(shiny::NS(id, "n"), "N rows", value = default_value),
    server = make_teal_transform_server(
      substitute({
        
      }, env = list(.var_to_replace = as.name(.var_to_replace)))
    )
  )
}

app <- init(
  data = data,
  modules = modules(
    tm_g_pp_adverse_events(
      label = "Adverse Events",
      dataname = "ADAE",
      parentname = "ADSL",
      patient_col = "USUBJID",
      plot_height = c(600L, 200L, 2000L),
      aeterm = choices_selected(
        choices = variable_choices(ADAE, "AETERM"),
        selected = "AETERM"
      ),
      tox_grade = choices_selected(
        choices = variable_choices(ADAE, "AETOXGR"),
        selected = "AETOXGR"
      ),
      causality = choices_selected(
        choices = variable_choices(ADAE, "AEREL"),
        selected = "AEREL"
      ),
      outcome = choices_selected(
        choices = variable_choices(ADAE, "AEOUT"),
        selected = "AEOUT"
      ),
      action = choices_selected(
        choices = variable_choices(ADAE, "AEACN"),
        selected = "AEACN"
      ),
      time = choices_selected(
        choices = variable_choices(ADAE, "ASTDY"),
        selected = "ASTDY"
      ),
      decod = NULL,
      decorators = list(plot = caption_decorator('Marcin', 'plot'), 
                        caption_decorator('Marcin', 'plot')
                        )
    )
  )
) |> shiny::runApp()

@llrs-roche llrs-roche self-assigned this Jan 29, 2025
Copy link
Contributor

@llrs-roche llrs-roche left a comment

Choose a reason for hiding this comment

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

Note that the CI is failing. See the linter and the comment of Dawid on tmg.

@m7pr
Copy link
Contributor Author

m7pr commented Jan 31, 2025

In the end allowed either all named or all unnamed decorators

Copy link
Contributor

github-actions bot commented Jan 31, 2025

Unit Tests Summary

    1 files     70 suites   1h 12m 49s ⏱️
  727 tests   614 ✅ 113 💤 0 ❌
1 987 runs  1 759 ✅ 228 💤 0 ❌

Results for commit 9caafdf.

♻️ This comment has been updated with latest results.

Copy link
Contributor

Unit Test Performance Difference

Test suite performance difference
Test Suite $Status$ Time on main $±Time$ $±Tests$ $±Skipped$ $±Failures$ $±Errors$
shinytest2-tm_a_gee 💚 $136.01$ $-3.14$ $0$ $0$ $0$ $0$
shinytest2-tm_a_mmrm 💚 $766.07$ $-8.62$ $0$ $0$ $0$ $0$
shinytest2-tm_g_barchart_simple 💚 $239.12$ $-3.95$ $0$ $0$ $0$ $0$
shinytest2-tm_g_forest_rsp 💚 $186.12$ $-2.40$ $0$ $0$ $0$ $0$
shinytest2-tm_g_km 💔 $278.99$ $+5.04$ $0$ $0$ $0$ $0$
shinytest2-tm_g_lineplot 💔 $91.34$ $+2.98$ $0$ $0$ $0$ $0$
shinytest2-tm_g_pp_adverse_events 💔 $130.33$ $+6.06$ $0$ $0$ $0$ $0$
shinytest2-tm_g_pp_patient_timeline 💔 $251.48$ $+9.32$ $0$ $0$ $0$ $0$
shinytest2-tm_g_pp_therapy 💔 $199.36$ $+11.69$ $0$ $0$ $0$ $0$
shinytest2-tm_g_pp_vitals 💔 $89.75$ $+1.90$ $0$ $0$ $0$ $0$
shinytest2-tm_t_abnormality_by_worst_grade 💔 $69.89$ $+1.78$ $0$ $0$ $0$ $0$
shinytest2-tm_t_binary_outcome 💚 $83.23$ $-3.69$ $0$ $0$ $0$ $0$
shinytest2-tm_t_coxreg 💚 $80.31$ $-3.87$ $0$ $0$ $0$ $0$
shinytest2-tm_t_events 💚 $66.22$ $-3.63$ $0$ $0$ $0$ $0$
shinytest2-tm_t_events_by_grade 💚 $97.79$ $-5.37$ $0$ $0$ $0$ $0$
shinytest2-tm_t_events_patyear 💚 $55.38$ $-2.13$ $0$ $0$ $0$ $0$
shinytest2-tm_t_events_summary 💚 $72.95$ $-3.77$ $0$ $0$ $0$ $0$
shinytest2-tm_t_exposure 💚 $85.97$ $-4.20$ $0$ $0$ $0$ $0$
shinytest2-tm_t_logistic 💚 $65.82$ $-3.74$ $0$ $0$ $0$ $0$
shinytest2-tm_t_mult_events 💚 $61.92$ $-2.14$ $0$ $0$ $0$ $0$
shinytest2-tm_t_pp_basic_info 💚 $44.05$ $-1.07$ $0$ $0$ $0$ $0$
shinytest2-tm_t_pp_laboratory 💚 $133.94$ $-3.04$ $0$ $0$ $0$ $0$
shinytest2-tm_t_pp_medical_history 💚 $71.74$ $-3.29$ $0$ $0$ $0$ $0$
shinytest2-tm_t_pp_prior_medication 💚 $85.05$ $-5.54$ $0$ $0$ $0$ $0$
shinytest2-tm_t_shift_by_arm 💚 $63.59$ $-2.81$ $0$ $0$ $0$ $0$
shinytest2-tm_t_shift_by_arm_by_worst 💚 $94.92$ $-1.34$ $0$ $0$ $0$ $0$
shinytest2-tm_t_shift_by_grade 💚 $84.91$ $-2.64$ $0$ $0$ $0$ $0$
shinytest2-tm_t_smq 💚 $64.30$ $-3.28$ $0$ $0$ $0$ $0$
shinytest2-tm_t_tte 💚 $72.46$ $-3.55$ $0$ $0$ $0$ $0$

Results for commit fe34508

♻️ This comment has been updated with latest results.

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.

[Bug]: multiplied decorators
2 participants