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

Modify the print for modules to contain more information #1401

Merged
merged 20 commits into from
Nov 7, 2024

Conversation

vedhav
Copy link
Contributor

@vedhav vedhav commented Nov 4, 2024

Closes #1378

Example code to test the format:

devtools::load_all("teal")

custom_module <- function(label = "label", ui_args = NULL, server_args = NULL, datanames = "all", transformers = list(), bk = FALSE) {
  ans <- module(
    label,
    server = function(id, data, ...) {
      moduleServer(id, function(input, output, session) {
        
      })
    },
    ui = function(id, ...) {
    },
    datanames = datanames,
    transformers = transformers,
    ui_args = ui_args,
    server_args = server_args
  )
  attr(ans, "teal_bookmarkable") <- bk
  ans
}

dummy_transformer <- teal_transform_module(
  label = "Dummy Transform",
  ui = function(id) div("(does nothing)"),
  server = function(id, data) {
    moduleServer(id, function(input, output, session) data)
  }
)

plot_transformer <- teal_transform_module(
  label = "Plot Settings",
  ui = function(id) div("(does nothing)"),
  server = function(id, data) {
    moduleServer(id, function(input, output, session) data)
  }
)

complete_modules <- modules(
  custom_module(
    label = "Data Overview",
    datanames = c("ADSL", "ADAE", "ADVS"),
    ui_args = list(
      view_type = "table",
      page_size = 10,
      filters = c("ARM", "SEX", "RACE")
    ),
    server_args = list(
      cache = TRUE,
      debounce = 1000
    ),
    transformers = list(dummy_transformer),
    bk = TRUE
  ),
  modules(
    label = "Nested 1",
    custom_module(
      label = "Interactive Plots",
      datanames = c("ADSL", "ADVS"),
      ui_args = list(
        plot_type = c("scatter", "box", "line"),
        height = 600,
        width = 800,
        color_scheme = "viridis"
      ),
      server_args = list(
        render_type = "svg",
        cache_plots = TRUE
      ),
      transformers = list(dummy_transformer, plot_transformer),
      bk = TRUE
    ),
    modules(
      label = "Nested 2",
      custom_module(
        label = "Summary Statistics",
        datanames = "ADSL",
        ui_args = list(
          stats = c("mean", "median", "sd", "range"),
          grouping = c("ARM", "SEX")
        )
      ),
      modules(
        label = "Labeled nested modules",
        custom_module(
          label = "Subgroup Analysis",
          datanames = c("ADSL", "ADAE"),
          ui_args = list(
            subgroups = c("AGE", "SEX", "RACE"),
            analysis_type = "stratified"
          ),
          bk = TRUE
        )
      ),
      modules(custom_module(label = "Subgroup Analysis in non-labled modules"))
    )
  ),
  custom_module("Non-nested module")
)

complete_modules
> complete_modules
TEAL ROOT
  ├─ Data Overview
  │  ├─ Data Sources: ADSL, ADAE, ADVS
  │  ├─ Properties:
  │  │  ├─ Bookmarkable: Yes
  │  │  └─ Reportable: No
  │  ├─ UI Arguments: view_type, page_size, filters
  │  ├─ Server Arguments: cache, debounce
  │  └─ Transformers: Dummy Transform
  ├─ Nested 1
  │  ├─ Interactive Plots
  │  │  ├─ Data Sources: ADSL, ADVS
  │  │  ├─ Properties:
  │  │  │  ├─ Bookmarkable: Yes
  │  │  │  └─ Reportable: No
  │  │  ├─ UI Arguments: plot_type, height, width, color_scheme
  │  │  ├─ Server Arguments: render_type, cache_plots
  │  │  └─ Transformers: Dummy Transform, Plot Settings
  │  └─ Nested 2
  │     ├─ Summary Statistics
  │     │  ├─ Data Sources: ADSL
  │     │  ├─ Properties:
  │     │  │  ├─ Bookmarkable: No
  │     │  │  └─ Reportable: No
  │     │  ├─ UI Arguments: stats, grouping
  │     │  ├─ Server Arguments:none
  │     │  └─ Transformers:none
  │     ├─ Labeled nested modules
  │     │  └─ Subgroup Analysis
  │     │     ├─ Data Sources: ADSL, ADAE
  │     │     ├─ Properties:
  │     │     │  ├─ Bookmarkable: Yes
  │     │     │  └─ Reportable: No
  │     │     ├─ UI Arguments: subgroups, analysis_type
  │     │     ├─ Server Arguments:none
  │     │     └─ Transformers:none
  │     └─ root
  │        └─ Subgroup Analysis in non-labled modules
  │           ├─ Data Sources: all
  │           ├─ Properties:
  │           │  ├─ Bookmarkable: No
  │           │  └─ Reportable: No
  │           ├─ UI Arguments:none
  │           ├─ Server Arguments:none
  │           └─ Transformers:none
  └─ Non-nested module
     ├─ Data Sources: all
     ├─ Properties:
     │  ├─ Bookmarkable: No
     │  └─ Reportable: No
     ├─ UI Arguments:none
     ├─ Server Arguments:none
     └─ Transformers:none

@vedhav vedhav added enhancement New feature or request core labels Nov 4, 2024
@vedhav vedhav force-pushed the 1378-format-module-print@main branch from 59432d8 to 1dce0d7 Compare November 5, 2024 07:20
@vedhav vedhav marked this pull request as ready for review November 5, 2024 08:05
R/modules.R Outdated Show resolved Hide resolved
DESCRIPTION Show resolved Hide resolved
R/modules.R Outdated Show resolved Hide resolved
R/modules.R Outdated Show resolved Hide resolved
R/modules.R Show resolved Hide resolved
Signed-off-by: Vedha Viyash <[email protected]>
R/modules.R Outdated Show resolved Hide resolved
R/modules.R Outdated Show resolved Hide resolved
R/modules.R Show resolved Hide resolved
R/modules.R Outdated Show resolved Hide resolved
R/modules.R Outdated Show resolved Hide resolved
R/modules.R Outdated Show resolved Hide resolved
Co-authored-by: Marcin <[email protected]>
Signed-off-by: Vedha Viyash <[email protected]>
R/modules.R Show resolved Hide resolved
R/modules.R Outdated Show resolved Hide resolved
R/modules.R Outdated Show resolved Hide resolved
R/modules.R Show resolved Hide resolved
@m7pr m7pr self-assigned this Nov 5, 2024
Copy link
Contributor

github-actions bot commented Nov 6, 2024

Unit Tests Summary

  1 files   25 suites   8m 54s ⏱️
265 tests 261 ✅ 4 💤 0 ❌
519 runs  515 ✅ 4 💤 0 ❌

Results for commit 9296afb.

♻️ This comment has been updated with latest results.

Copy link
Contributor

github-actions bot commented Nov 6, 2024

Unit Test Performance Difference

Test Suite $Status$ Time on main $±Time$ $±Tests$ $±Skipped$ $±Failures$ $±Errors$
module_teal 💚 $69.43$ $-2.26$ $0$ $0$ $0$ $0$

Results for commit 5626267

♻️ This comment has been updated with latest results.

@vedhav vedhav force-pushed the 1378-format-module-print@main branch from 374ddac to 4df2d15 Compare November 6, 2024 14:55
Copy link
Contributor

github-actions bot commented Nov 6, 2024

badge

Code Coverage Summary

Filename                          Stmts    Miss  Cover    Missing
------------------------------  -------  ------  -------  ----------------------------------------------------------------------------------------------------------------------------------------
R/checkmate.R                        24       0  100.00%
R/dummy_functions.R                  47      11  76.60%   27, 29, 41, 52-59
R/get_rcode_utils.R                  12       0  100.00%
R/include_css_js.R                   22      17  22.73%   12-38, 76-82
R/init.R                            108      50  53.70%   107-114, 160-169, 171, 183-204, 229-232, 239-245, 248-249, 251
R/landing_popup_module.R             25      25  0.00%    61-87
R/module_bookmark_manager.R         158     127  19.62%   47-68, 88-138, 143-144, 156, 203, 238-315
R/module_data_summary.R             203      38  81.28%   26-54, 78, 218, 223, 237, 268-272
R/module_filter_data.R               64       2  96.88%   22-23
R/module_filter_manager.R           230      57  75.22%   56-62, 73-82, 90-95, 108-112, 117-118, 291-314, 340, 367, 379, 386-387
R/module_init_data.R                 74       0  100.00%
R/module_nested_tabs.R              236      91  61.44%   40-142, 174, 199-201, 320, 360
R/module_snapshot_manager.R         216     146  32.41%   89-95, 104-113, 121-133, 152-153, 170-180, 184-199, 201-208, 215-230, 234-238, 240-246, 249-262, 265-273, 304-318, 321-332, 335-341, 355
R/module_teal_data.R                149      10  93.29%   41-48, 84, 135-136
R/module_teal_lockfile.R            131      44  66.41%   32-36, 44-56, 59-61, 75, 85-87, 99-101, 109-118, 121, 123, 125-126, 160-161
R/module_teal_with_splash.R          12      12  0.00%    22-38
R/module_teal.R                     190      87  54.21%   48-143, 158, 184-185, 217
R/module_transform_data.R            54      32  40.74%   17-52
R/modules.R                         280      72  74.29%   173-177, 232-235, 356-376, 384, 534-540, 553-562, 578-626, 659, 671-679
R/reporter_previewer_module.R        19       2  89.47%   30, 34
R/show_rcode_modal.R                 24      24  0.00%    17-42
R/tdata.R                            14      14  0.00%    19-61
R/teal_data_module-eval_code.R       24       0  100.00%
R/teal_data_module-within.R           7       0  100.00%
R/teal_data_module.R                 58       0  100.00%
R/teal_data_utils.R                  32       0  100.00%
R/teal_reporter.R                    68       6  91.18%   69, 77, 125-126, 129, 146
R/teal_slices-store.R                29       0  100.00%
R/teal_slices.R                      63       0  100.00%
R/TealAppDriver.R                   353     353  0.00%    52-735
R/utils.R                           231      37  83.98%   389-437
R/validate_inputs.R                  32       0  100.00%
R/validations.R                      58      37  36.21%   110-377
R/zzz.R                              15      11  26.67%   4-18
TOTAL                              3262    1305  59.99%

Diff against main

Filename       Stmts    Miss  Cover
-----------  -------  ------  -------
R/modules.R      +99     +40  -8.03%
R/utils.R         +1       0  +0.07%
TOTAL           +100     +40  +0.00%

Results for commit: 9296afb

Minimum allowed coverage is 80%

♻️ This comment has been updated with latest results

@m7pr
Copy link
Contributor

m7pr commented Nov 7, 2024

@vedhav I think this looks really great

DESCRIPTION Show resolved Hide resolved
R/modules.R Outdated Show resolved Hide resolved
@vedhav vedhav force-pushed the 1378-format-module-print@main branch from 014ef33 to 4badf06 Compare November 7, 2024 09:21
Copy link
Contributor

@m7pr m7pr left a comment

Choose a reason for hiding this comment

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

Left one last commit, but this is already in a good shape. Really nice job!

@vedhav vedhav enabled auto-merge (squash) November 7, 2024 09:37
@vedhav
Copy link
Contributor Author

vedhav commented Nov 7, 2024

The new print method for the teal modules look like this in black console and RStudio's white console.

Screenshot 2024-11-07 150908
Screenshot 2024-11-07 150848

@vedhav vedhav merged commit 0562ff1 into main Nov 7, 2024
29 checks passed
@vedhav vedhav deleted the 1378-format-module-print@main branch November 7, 2024 09:52
@github-actions github-actions bot locked and limited conversation to collaborators Nov 7, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
core enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Modify print of modules/module to contain more information
2 participants