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

[Bug]: Error/warning message when data is not sufficient and no teal transform modules #1299

Closed
gogonzo opened this issue Aug 8, 2024 · 3 comments
Assignees
Labels
bug Something isn't working core

Comments

@gogonzo
Copy link
Contributor

gogonzo commented Aug 8, 2024

What happened?

When data provided to the teal::init has insufficient datasets and none of the modules have teal_transform_module specified it clearly means that some modules are missing some datasets.

What we need is to make an assert/warning in teal::init to throw message when:

  • datasets available in data argument don't cover all possible modules$datanames
  • None of the modules have transforms specified (means that list of datasets won't be extended by teal_transform_module)

When we address #1298 it will be possible to determine all possible datanames including those created in teal_transform_module so the message will be thrown when:

  • datasets available in data argument don't cover all possible modules$datanames and teal_transform_module$datanames
@m7pr
Copy link
Contributor

m7pr commented Aug 12, 2024

Proposition for an improvement in here #1309, but blocked by #1298

@m7pr
Copy link
Contributor

m7pr commented Aug 14, 2024

m7pr added a commit that referenced this issue Aug 28, 2024
…modules (#1319)

Fixes the top part of
#1299

The current behavior raised a warning that datanames are not sufficient
based on comparison of `data@datanames` and `modules$datanames`. This
now have a new condition - warning is only displayed when the above is
satisfied & there are no `transformers`.

<img width="697" alt="image"
src="https://github.com/user-attachments/assets/055f4982-07c3-4157-823f-af448443f537">

# Code for testing

<details><summary>Tested with</summary>

```r
pkgload::load_all('teal.data')
pkgload::load_all('teal.slice')
pkgload::load_all('teal')

my_transformers <- list(
  teal_transform_module(
    label = "Custom transform for iris",
    ui = function(id) {
      ns <- NS(id)
      tags$div(
        numericInput(ns("n_rows"), "Subset n rows", value = 6, min = 1, max = 150, step = 1)
      )
    },
    server = function(id, data) {
      moduleServer(id, function(input, output, session) {
        reactive({
          within(data(),
                 {
                   iris <- head(iris, num_rows)
                 },
                 num_rows = input$n_rows
          )
        })
      })
    }
  )
)

app1 <- init(
  data = teal_data(iris = iris),
  modules = example_module(datanames = c("iris", "mtcars"))
)

shinyApp(app1$ui, app1$server)

app2 <- init(
  data = teal_data(iris = iris),
  modules = example_module(datanames = c("iris", "mtcars"), transformers = my_transformers)
)
shinyApp(app2$ui, app2$server)
```

</details>

# No transformers - warning

<img width="658" alt="no_transformers"
src="https://github.com/user-attachments/assets/cc90a3ae-f73c-4f72-ab11-6eb9efd2acf9">

# Transformers exist - no warning

<img width="662" alt="transformers"
src="https://github.com/user-attachments/assets/d560193b-72ff-4b87-9a9e-0d2ccf90a5e9">

# Results of local tests

<details><summary>Results of local tests</summary>

```r
> devtools::test()
ℹ Testing teal
[INFO] 2024-08-14 11:40:00.4037 pid:11652 token:[] teal You are using teal version 0.15.2.9052
✔ | F W  S  OK | Context
✔ |         10 | init [1.1s]                                                           
✔ |      6 129 | module_teal [57.3s]                                                   
✔ |         95 | modules                                                               
✔ |          7 | rcode_utils                                                           
✔ |          8 | report_previewer_module                                               
✔ |      6   0 | shinytest2-data_summary                                               
✔ |      3   0 | shinytest2-filter_panel                                               
✔ |      3   0 | shinytest2-init                                                       
✔ |      5   0 | shinytest2-landing_popup                                              
✔ |      4   0 | shinytest2-module_bookmark_manager                                    
✔ |      4   0 | shinytest2-modules                                                    
✔ |      5   0 | shinytest2-reporter                                                   
✔ |      1   0 | shinytest2-show-rcode                                                 
✔ |      6   0 | shinytest2-teal_data_module                                           
✔ |      2   0 | shinytest2-teal_slices                                                
✔ |      1   0 | shinytest2-utils                                                      
✔ |      2   0 | shinytest2-wunder_bar                                                 
✔ |         16 | teal_data_module-eval_code                                            
✔ |          4 | teal_data_module                                                      
✔ |         25 | teal_reporter                                                         
✔ |         15 | teal_slices-store                                                     
✔ |         18 | teal_slices                                                           
✔ |         36 | utils [9.7s]                                                          
✔ |         17 | validate_has_data                                                     
✔ |         36 | validate_inputs                                                       

══ Results ════════════════════════════════════════════════════════════════════════════
Duration: 74.8 s

── Skipped tests (48) ─────────────────────────────────────────────────────────────────
• need a fix in a .slicesGlobal (1): test-module_teal.R:1177:11
• testing depth 3 is below current testing specification 5 (42):
  test-shinytest2-data_summary.R:2:3, test-shinytest2-data_summary.R:21:3,
  test-shinytest2-data_summary.R:40:3, test-shinytest2-data_summary.R:62:3,
  test-shinytest2-data_summary.R:92:5, test-shinytest2-data_summary.R:139:3,
  test-shinytest2-filter_panel.R:5:3, test-shinytest2-filter_panel.R:32:3,
  test-shinytest2-filter_panel.R:71:3, test-shinytest2-init.R:5:3,
  test-shinytest2-init.R:15:3, test-shinytest2-init.R:70:3,
  test-shinytest2-landing_popup.R:5:3, test-shinytest2-landing_popup.R:25:3,
  test-shinytest2-landing_popup.R:43:3, test-shinytest2-landing_popup.R:67:5,
  test-shinytest2-landing_popup.R:146:3,
  test-shinytest2-module_bookmark_manager.R:5:3,
  test-shinytest2-module_bookmark_manager.R:19:3,
  test-shinytest2-module_bookmark_manager.R:33:3,
  test-shinytest2-module_bookmark_manager.R:44:3, test-shinytest2-modules.R:5:3,
  test-shinytest2-modules.R:44:3, test-shinytest2-modules.R:60:3,
  test-shinytest2-modules.R:77:3, test-shinytest2-reporter.R:5:3,
  test-shinytest2-reporter.R:25:3, test-shinytest2-reporter.R:48:3,
  test-shinytest2-reporter.R:87:3, test-shinytest2-reporter.R:103:3,
  test-shinytest2-show-rcode.R:5:3, test-shinytest2-teal_data_module.R:5:3,
  test-shinytest2-teal_data_module.R:42:3, test-shinytest2-teal_data_module.R:78:3,
  test-shinytest2-teal_data_module.R:130:3, test-shinytest2-teal_data_module.R:175:3,
  test-shinytest2-teal_data_module.R:215:3, test-shinytest2-teal_slices.R:5:3,
  test-shinytest2-teal_slices.R:48:3, test-shinytest2-utils.R:5:3,
  test-shinytest2-wunder_bar.R:5:3, test-shinytest2-wunder_bar.R:24:3
• todo (5): test-module_teal.R:1442:7, test-module_teal.R:1449:5,
  test-module_teal.R:1452:5, test-module_teal.R:1710:5, test-module_teal.R:1768:5

[ FAIL 0 | WARN 0 | SKIP 48 | PASS 416 ]
```

</details>

---------

Signed-off-by: Marcin <[email protected]>
Co-authored-by: 27856297+dependabot-preview[bot]@users.noreply.github.com <27856297+dependabot-preview[bot]@users.noreply.github.com>
Co-authored-by: Dawid Kałędkowski <[email protected]>
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
@m7pr
Copy link
Contributor

m7pr commented Aug 28, 2024

Closed with #1319

@m7pr m7pr closed this as completed Aug 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working core
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants