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

632 teal add reporter vignette@main #642

Merged
merged 27 commits into from
May 24, 2022
Merged

Conversation

kpagacz
Copy link
Contributor

@kpagacz kpagacz commented May 23, 2022

Requires: #635

It's a vignette. Run the code inside it to test.

@github-actions
Copy link
Contributor

github-actions bot commented May 23, 2022

Code Coverage Summary

Filename                         Stmts    Miss  Cover    Missing
-----------------------------  -------  ------  -------  -------------------------------------------
R/default_filter.R                   7       7  0.00%    17-27
R/dummy_functions.R                 89      66  25.84%   12-99, 116
R/example_module.R                  17      17  0.00%    18-34
R/get_rcode_utils.R                 52      11  78.85%   42-51, 94, 99
R/get_rcode.R                      145      99  31.72%   71-74, 85-148, 195, 201-202, 233-284
R/include_css_js.R                  20       0  100.00%
R/init.R                            39      21  46.15%   171, 182-183, 236-257
R/log_app_usage.R                   38      38  0.00%    34-119
R/logging.R                         13      13  0.00%    11-28
R/module_nested_tabs.R              76       4  94.74%   53, 133, 184, 190
R/module_tabs_with_filters.R        52       0  100.00%
R/module_teal_with_splash.R         33       2  93.94%   62, 74
R/module_teal.R                    122      20  83.61%   49, 52, 144-145, 158-164, 170-176, 200, 230
R/modules_debugging.R               19      19  0.00%    41-60
R/modules.R                         80       9  88.75%   208, 372-397
R/reporter_previewer_module.R       12       2  83.33%   17, 21
R/show_rcode_modal.R                20      20  0.00%    17-38
R/utils.R                            6       0  100.00%
R/validations.R                     62      39  37.10%   103-355
R/zzz.R                             11       7  36.36%   3-14
TOTAL                              913     394  56.85%

Results for commit: 8425a6b1a98fd3c44ec1283989935647d4e8fd78

Minimum allowed coverage is 80%

♻️ This comment has been updated with latest results

@nikolas-burkoff nikolas-burkoff self-assigned this May 23, 2022
Copy link
Contributor

@nikolas-burkoff nikolas-burkoff left a comment

Choose a reason for hiding this comment

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

Content's really good - see comments inline and also

  • I would probably refer to the new add reporting vignette from the "creating_custom_modules" vignette

`teal` supports an in-built reporting feature using the `vignette("teal.reporter")` package. Head to its documentation
if you want to know more about the reporting itself.

This article explains how to enhance a custom `teal` module with an automatic reporting feature. The enhancement
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd make even more clear this vignette is for module developers rather than app developers

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What I wished we had in teal is two separate sections of vignettes, one titled: Module development and another Application development and I could put this vignette in the module section.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added

Comment on lines 20 to 22
The responsibilities of a module developer include: adding the support for reporting to their module and specifying
outputs that go into a snapshot of their module. The lifecycle of objects involved in creation of the report and
setting up the module to preview the report is handled by `teal`.
Copy link
Contributor

Choose a reason for hiding this comment

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

(optional)

Suggested change
The responsibilities of a module developer include: adding the support for reporting to their module and specifying
outputs that go into a snapshot of their module. The lifecycle of objects involved in creation of the report and
setting up the module to preview the report is handled by `teal`.
The responsibilities of a module developer include:
- adding the support for reporting to their module
- specifying outputs that go into a snapshot of their module.
The lifecycle of objects involved in creation of the report and setting up the module to preview the report is handled by `teal`.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Chabnged

Comment on lines +64 to +65
The first step is to add another argument to the server function declaration - `reporter`. This needs to be the third
argument to the server function inside the `teal.module` call. See below:
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think it needs to be third - right now it has to go id then datasets but then you could have other stuff before reporter - but maybe better to simpler and say it must be third

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was not aware of this. Considering the complexity of the explanation, it might be better to leave the more straightforward but not entirely true statement here.

Copy link
Contributor

Choose a reason for hiding this comment

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

fair enough

if (interactive()) shinyApp(app$ui, app$server)
```

`teal` added another tab to the application titled `Report previer` but besides that there appears to be no change in
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
`teal` added another tab to the application titled `Report previer` but besides that there appears to be no change in
`teal` added another tab to the application titled `Report previewer` but besides that there appears to be no change in

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed


`teal` added another tab to the application titled `Report previer` but besides that there appears to be no change in
how the module works and what it looks like. User cannot interact with it to add to the report from this module yet.
Thankfully, `teal.report` provides `ui` and `server` objects that support that.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Thankfully, `teal.report` provides `ui` and `server` objects that support that.
Thankfully, `teal.reporter` provides `ui` and `server` objects that support that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changed

### Add content to the card
We will use the public API exposed by the `teal.reporter::ReportCard` and `teal.reporter::TealReportCard` classes
to add content to a card. The `teal.reporter::simple_reporter_srv` module accepts the `card_fun` argument that
dictates the way the output from our custom module will look like. `ReportCard` and its derivatives adds
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
dictates the way the output from our custom module will look like. `ReportCard` and its derivatives adds
dictates the way the output from our custom module will look like. `ReportCard` and its derivatives add

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

label,
server = function(id, datasets, reporter) {
moduleServer(id, function(input, output, session) {
custom_function <- function(card = teal.reporter::ReportCard$new()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

could we have the custom function above the module so it's clear what we are adding and then either have a new block with "putting it all together we have:" or just have card_fun = custom_fun

Copy link
Contributor Author

Choose a reason for hiding this comment

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

moved

```

### Add non-text content to the card
Explore the API of `teal.reporter::ReportCard` to learn what types of content are supported.
Copy link
Contributor

Choose a reason for hiding this comment

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

I would at least give a taster - "it is possible to add tables and charts etc. to the ReportCard see the docs..." or something like that

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added

Otherwise, the API of `TealReportCard` will not be available inside the function.

### Use a child class of `ReportCard` inside the module
`teal.reporter` allows using a child of `ReportCard` inside the function passed to
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if this section belongs in roxygen rather than here as it's quite specific and unlikely to be used by most module developers?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

moved to the docs of teal.reporter::add_card_button_srv

### Add non-text content to the card
Explore the API of `teal.reporter::ReportCard` to learn what types of content are supported.

### `TealReportCard`
Copy link
Contributor

Choose a reason for hiding this comment

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

So I'm torn between using this as the default - as we are in teal of course! - or not

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My view is that TealReportCard is only helpful if the module uses all the things teal offers - the source code thing and filter states. And all those things do not need to be used by the module, so in my mind, it should not be the default.

Copy link
Contributor

Choose a reason for hiding this comment

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

fair enough

NEWS.md Outdated Show resolved Hide resolved
@github-actions
Copy link
Contributor

github-actions bot commented May 23, 2022

Unit Tests Summary

    1 files    10 suites   13s ⏱️
  91 tests   91 ✔️ 0 💤 0
196 runs  196 ✔️ 0 💤 0

Results for commit f2c85be.

♻️ This comment has been updated with latest results.

@nikolas-burkoff
Copy link
Contributor

nikolas-burkoff commented May 23, 2022

Example looks interesting when using the new flex formatting in teal.reporter

image

Should we move the report buttons to the encoding - though I guess they are fine there

Copy link
Contributor

@nikolas-burkoff nikolas-burkoff left a comment

Choose a reason for hiding this comment

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

Looks good, a few minor comments but this can then go in

vignettes/adding_support_for_reporting.Rmd Show resolved Hide resolved
Comment on lines +64 to +65
The first step is to add another argument to the server function declaration - `reporter`. This needs to be the third
argument to the server function inside the `teal.module` call. See below:
Copy link
Contributor

Choose a reason for hiding this comment

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

fair enough

label,
server = function(id, datasets, reporter) {
moduleServer(id, function(input, output, session) {
output$text <- renderPrint(datasets$get_data(input$dataname, filtered = TRUE))
Copy link
Contributor

Choose a reason for hiding this comment

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

interesting that if I run this inside the vignette (i.e. select the code the print unhelpfully puts it here:
image

but running it form a file is fine, so no need to change anything

vignettes/adding_support_for_reporting.Rmd Outdated Show resolved Hide resolved
vignettes/adding_support_for_reporting.Rmd Outdated Show resolved Hide resolved
### Add non-text content to the card
Explore the API of `teal.reporter::ReportCard` to learn what types of content are supported.

### `TealReportCard`
Copy link
Contributor

Choose a reason for hiding this comment

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

fair enough

Co-authored-by: Nikolas Burkoff <[email protected]>
@kpagacz kpagacz enabled auto-merge (squash) May 24, 2022 16:19
@kpagacz kpagacz merged commit 8b278e0 into main May 24, 2022
@kpagacz kpagacz deleted the 632_teal_add_reporter_vignette@main branch May 24, 2022 16:26
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.

2 participants