teal icon indicating copy to clipboard operation
teal copied to clipboard

[Bug]: Report export returns an error when using teal as a shiny module

Open AleKoure opened this issue 9 months ago • 6 comments

What happened?

When I embed modules from teal.modules.general in a shiny app using teal framework as shiny module download report throws an error.

Image

Here is a minimal example:

library(shiny)
library(random.cdisc.data)
library(teal.modules.general)

modules <- modules(
  tm_g_bivariate(
    x = data_extract_spec(
      dataname = "ADSL",
      select = select_spec(
        label = "Select variable:",
        choices = variable_choices("ADSL"),
        selected = "AGE",
        fixed = FALSE
      )
    ),
    y = data_extract_spec(
      dataname = "ADSL",
      select = select_spec(
        label = "Select variable:",
        choices = variable_choices("ADSL"),
        selected = "SEX",
        multiple = FALSE,
        fixed = FALSE
      )
    )
  )
)

ui <- fluidPage(
  titlePanel("{teal} as shiny module: teal.modules.general"),
  ui_teal(id = "teal", modules = modules)
)

server <- function(input, output) {
  data <- reactive({
    teal_data(
      ADSL = random.cdisc.data::radsl(seed = 1)
    )
  })

  srv_teal(id = "teal", data = data, modules = modules)
}

shinyApp(ui = ui, server = server)

How to reproduce

  1. Initial app
  2. Add View to report
  3. Navigate to report previewer
  4. Click download report (see screenshot above)

Code of Conduct

  • [x] I agree to follow this project's Code of Conduct.

Contribution Guidelines

  • [x] I agree to follow this project's Contribution Guidelines.

Security Policy

  • [x] I agree to follow this project's Security Policy.

AleKoure avatar Apr 09 '25 07:04 AleKoure

Hi, thanks for the bug report. I can reproduce the warning. But on my machine it doesn't prevent to get the report, as it is not an error. Are you able to download the report or not?

llrs-roche avatar Apr 09 '25 10:04 llrs-roche

@llrs-roche report is not working on my end - it fails to download any file. I work in Posit Workbench. I also checked other formats but they all fail (powerpoint, pdf etc.).

AleKoure avatar Apr 09 '25 10:04 AleKoure

I see it is running on a Red Hat server, I'm not sure we have access to this OS to test and try to reproduce it. If you have any additional information to back trace it might help us to identify the issue: browser developer log, additional Posit Workbench log, any firewall that could block the new window or even if browser pop-ups are blocked for that domain... They might help identify and fix the issue.

llrs-roche avatar Apr 09 '25 12:04 llrs-roche

@llrs-roche I managed to reproduce the error with a rockerverse image.

  1. Pull image and spin a container to localhost:8787
docker run -d \
  -e PASSWORD=123 \
  -p 8787:8787 \
  rocker/verse:4.4.1
  1. Make sure that you point to the latest CRAN snapshot for Package Manager to install the latest version of teal
  2. log in to the container (username: rstudio, password:123)
  3. Repeat steps from https://github.com/insightsengineering/teal/issues/1513#issue-2981908233

Note Also, I managed to reproduce the error in R4.3.1 rockerverse image, but this needs some additional manual setup to resolve dependency issues.

Screenshot from Chrome console

Image

Session Info

R version 4.4.1 (2024-06-14)
Platform: x86_64-pc-linux-gnu
Running under: Ubuntu 22.04.5 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 
LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so;  LAPACK version 3.10.0

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8    LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C             LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

time zone: Etc/UTC
tzcode source: system (glibc)

attached base packages:
[1] stats     graphics  grDevices datasets  utils     methods   base     

other attached packages:
 [1] dplyr_1.1.4                random.cdisc.data_0.3.16   teal.modules.general_0.4.1 teal.transform_0.6.0      
 [5] ggmosaic_0.3.3             ggplot2_3.5.2              teal_0.16.0                teal.slice_0.6.0          
 [9] teal.data_0.7.0            teal.code_0.6.1            shiny_1.10.0              

loaded via a namespace (and not attached):
 [1] shinyvalidate_0.1.3   gtable_0.3.6          xfun_0.52             bslib_0.9.0           shinyjs_2.1.0        
 [6] htmlwidgets_1.6.4     teal.widgets_0.4.3    ggrepel_0.9.6         vctrs_0.6.5           tools_4.4.1          
[11] generics_0.1.3        tibble_3.2.1          pkgconfig_2.0.3       data.table_1.17.0     checkmate_2.3.2      
[16] lifecycle_1.0.4       farver_2.1.2          compiler_4.4.1        stringr_1.5.1         textshaping_1.0.0    
[21] munsell_0.5.1         fontawesome_0.5.3     httpuv_1.6.15         shinyWidgets_0.9.0    htmltools_0.5.8.1    
[26] sass_0.4.9            yaml_2.3.10           lazyeval_0.2.2        plotly_4.10.4         crayon_1.5.3         
[31] later_1.4.2           pillar_1.10.2         jquerylib_0.1.4       tidyr_1.3.1           cachem_1.1.0         
[36] mime_0.13             tidyselect_1.2.1      digest_0.6.37         stringi_1.8.7         purrr_1.0.4          
[41] labeling_0.4.3        fastmap_1.2.0         grid_4.4.1            colorspace_2.1-1      cli_3.6.4            
[46] logger_0.4.0          magrittr_2.0.3        withr_3.0.2           teal.reporter_0.4.0   scales_1.3.0         
[51] promises_1.3.2        backports_1.5.0       timechange_0.3.0      lubridate_1.9.4       rmarkdown_2.29       
[56] httr_1.4.7            ragg_1.3.3            memoise_2.0.1         evaluate_1.0.3        knitr_1.50           
[61] shinycssloaders_1.1.0 viridisLite_0.4.2     rlang_1.1.5           Rcpp_1.0.14           xtable_1.8-4         
[66] glue_1.8.0            renv_1.0.11           jsonlite_2.0.0        teal.logger_0.3.2     R6_2.6.1             
[71] systemfonts_1.2.2    

AleKoure avatar Apr 10 '25 11:04 AleKoure

@AleKoure Wow! Many thanks for the reproducible example and going the extra mile to use docker! I'll try to reproduce that locally and see if we can find the roo cause. Many thanks.

llrs-roche avatar Apr 10 '25 12:04 llrs-roche

Even on the rocker image I only see a warning and the report can be downloaded: Image

Not sure if there is something else going on. However, this warning might be related to not being able to download the report. An approach to identify the source of this warning might involve options(warn = 2, error = browser) or similar approaches. Thanks for the report

llrs-roche avatar Apr 11 '25 11:04 llrs-roche