Skip to content

Refactor teal.reporter #104

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

Open
1 of 5 tasks
donyunardi opened this issue Feb 14, 2025 · 4 comments
Open
1 of 5 tasks

Refactor teal.reporter #104

donyunardi opened this issue Feb 14, 2025 · 4 comments
Labels

Comments

@donyunardi
Copy link
Collaborator

donyunardi commented Feb 14, 2025

Summary

teal.reporter is a powerful feature that allows users to create reports when they discover interesting analyses during exploration in teal. However, as user requirements continue to evolve, the current design has shown some limitations.

Some key challenges include:

To address these limitations, we aim to refactor teal.reporter with a more flexible and scalable design. This will involve researching potential solutions, conducting proof-of-concept (PoC) evaluations, and implementing a new design that better supports these evolving requirements.

Please see related comment here.

Definition of Done

  • The new design supports bookmarking without excessive disk space usage.
  • Users can customize report cards without modifying teal module programming.
  • Reports generated through teal.reporter are fully reproducible.
  • The refactored system maintains or improves existing functionalities.
  • User can disable reporter in one or multiple teal modules

Tasks

@gogonzo
Copy link

gogonzo commented Apr 1, 2025

Current state of insightsengineering/teal.reporter#307

The new design supports bookmarking without excessive disk space usage.

Reporter has been modified and should not cause disc storage problems - we need an app to test it @m7pr

Users can customize report cards without modifying teal module programming.
User can disable reporter in one or multiple teal modules

Not started yet. It needs extra teal function to modify returned ReportDocument object returned from the module (as reactive) and pass (or don't to disable) further.
At this point example app with an explicit <module>$server wrapper is enough to demonstrate the possibility.

Reports generated through teal.reporter are fully reproducible.

@m7pr has made a step forward and split the code so that it is possible to generate an executable document.

@m7pr
Copy link

m7pr commented Apr 2, 2025

The new design supports bookmarking without excessive disk space usage.
Reporter has been modified and should not cause disc storage problems - we need an app to test it @m7pr

You can use the app from the opening comment of the PR in teal.reporter

Code
devtools::load_all('../teal.reporter')
devtools::load_all('../teal.widgets')
devtools::load_all('../teal.code')
devtools::load_all('../teal')
devtools::load_all('.')

# general data example
data <- teal_data()
data <- within(data, {
  require(nestcolor)
  CO2 <- CO2
  USArrests <- USArrests
})

app <- init(
  data = data,
  modules = modules(
    tm_a_regression(
      label = "Regression",
      response = data_extract_spec(
        dataname = "CO2",
        select = select_spec(
          label = "Select variable:",
          choices = "uptake",
          selected = "uptake",
          multiple = FALSE,
          fixed = TRUE
        )
      ),
      regressor = data_extract_spec(
        dataname = "CO2",
        select = select_spec(
          label = "Select variables:",
          choices = variable_choices(data[["CO2"]], c("conc", "Treatment")),
          selected = "conc",
          multiple = TRUE,
          fixed = FALSE
        )
      )
    ),
    tm_a_pca(
      "PCA",
      dat = data_extract_spec(
        dataname = "USArrests",
        select = select_spec(
          choices = variable_choices(
            data = data[["USArrests"]], c("Murder", "Assault", "UrbanPop", "Rape")
          ),
          selected = c("Murder", "Assault"),
          multiple = TRUE
        ),
        filter = NULL
      )
    ),
    tm_g_scatterplot(
      label = "Scatterplot Choices",
      x = data_extract_spec(
        dataname = "CO2",
        select = select_spec(
          label = "Select variable:",
          choices = variable_choices(data[["CO2"]], c("conc", "uptake")),
          selected = "conc",
          multiple = FALSE,
          fixed = FALSE
        )
      ),
      y = data_extract_spec(
        dataname = "CO2",
        select = select_spec(
          label = "Select variable:",
          choices = variable_choices(data[["CO2"]], c("conc", "uptake")),
          selected = "uptake",
          multiple = FALSE,
          fixed = FALSE
        )
      ),
      color_by = data_extract_spec(
        dataname = "CO2",
        select = select_spec(
          label = "Select variable:",
          choices = variable_choices(
            data[["CO2"]],
            c("Plant", "Type", "Treatment", "conc", "uptake")
          ),
          selected = NULL,
          multiple = FALSE,
          fixed = FALSE
        )
      ),
      size_by = data_extract_spec(
        dataname = "CO2",
        select = select_spec(
          label = "Select variable:",
          choices = variable_choices(data[["CO2"]], c("conc", "uptake")),
          selected = "uptake",
          multiple = FALSE,
          fixed = FALSE
        )
      ),
      row_facet = data_extract_spec(
        dataname = "CO2",
        select = select_spec(
          label = "Select variable:",
          choices = variable_choices(data[["CO2"]], c("Plant", "Type", "Treatment")),
          selected = NULL,
          multiple = FALSE,
          fixed = FALSE
        )
      ),
      col_facet = data_extract_spec(
        dataname = "CO2",
        select = select_spec(
          label = "Select variable:",
          choices = variable_choices(data[["CO2"]], c("Plant", "Type", "Treatment")),
          selected = NULL,
          multiple = FALSE,
          fixed = FALSE
        )
      )
    ),
    tm_g_bivariate(
      x = data_extract_spec(
        dataname = "CO2",
        select = select_spec(
          label = "Select variable:",
          choices = variable_choices(data[["CO2"]]),
          selected = "conc",
          fixed = FALSE
        )
      ),
      y = data_extract_spec(
        dataname = "CO2",
        select = select_spec(
          label = "Select variable:",
          choices = variable_choices(data[["CO2"]]),
          selected = "uptake",
          multiple = FALSE,
          fixed = FALSE
        )
      ),
      row_facet = data_extract_spec(
        dataname = "CO2",
        select = select_spec(
          label = "Select variable:",
          choices = variable_choices(data[["CO2"]]),
          selected = "Type",
          fixed = FALSE
        )
      ),
      col_facet = data_extract_spec(
        dataname = "CO2",
        select = select_spec(
          label = "Select variable:",
          choices = variable_choices(data[["CO2"]]),
          selected = "Treatment",
          fixed = FALSE
        )
      )
    )
  )
)
if (interactive()) {
  shinyApp(app$ui, app$server, enableBookmarking = "server")
}

However I do not see a lot of disk space being saved. Rather the opposite.

shiny bookmark for tm_g_bivariate that is still kept in the old fashion for old teal.reporter classes

Image

shiny bookmark for module that is written using new teal.reporter class that needs to be stored as .rds file

Image

@m7pr
Copy link

m7pr commented Apr 2, 2025

Users can customize report cards without modifying teal module programming.

I was trying to create a prototype of a function that would edit the module's report_card insightsengineering/teal@c0b9836
but for now ended up with some namespace collision as inputs are not visible in the server function

Image

@m7pr
Copy link

m7pr commented Apr 25, 2025

Hey! Here's a quick update and a TODO list of future tasks we can tackle after finishing the current research.


Done

teal.modules.general

teal

teal.reporter

  • Added report_document() and edit_report_document() for the new ReportDocument S3 class
  • Extended Previewer and Reporter to support ReportDocument
  • Deleted private Rendered class
  • Refactored:
    • report_render_and_compress
    • report_render
    • Added load report button to previewer buttons

In Progress

teal

teal.reporter


🔜 TODOs

Module Packages

  • Rewrite report cards based on the new design in:
    • teal.modules.general - 15 modules (23 hours)
    • teal.modules.clinical - 36 modules (54 hours)
    • teal.osprey - 10 modules (15 hours)
    • teal.goshawk - 6 modules (9 hours)
    • teal.hermes - 8 modules (12 hours)

teal

teal.reporter


Future Plans

  • Expose Show R Code as a button next to Add to Report button
    • This will require the module to return teal_data/qenv
    • This will require srv_teal_module to depend on whether module returned teal_data/qenv to show the button
    • This will allow to modify the teal_data/qenv returned by the module, so that Show R Code can be also customized or nullified

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants