-
-
Notifications
You must be signed in to change notification settings - Fork 50
Update report in custom modules vignette for new teal.reporter #1593
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
base: main
Are you sure you want to change the base?
Conversation
Unit Tests Summary 1 files 26 suites 2m 15s ⏱️ Results for commit 71581fc. ♻️ This comment has been updated with latest results. |
Unit Test Performance Difference
Results for commit 559cb36 ♻️ This comment has been updated with latest results. |
Code Coverage Summary
Diff against main
Results for commit: 26f05f1 Minimum allowed coverage is ♻️ This comment has been updated with latest results |
@llrs-roche @averissimo I posted the same question in teal.reporter PR insightsengineering/teal.reporter#407
|
@llrs-roche @averissimo I also think that with this PR we should:
|
@m7pr We can expand the scope of this PR to include the But I see the liberty this function gives to modify what is done with something of a module without adding a decorator. I could simply change the output of the report by just subsetting an object: library("teal.reporter")
app <- init(
data = teal_data(IRIS = iris, MTCARS = mtcars),
modules = example_module() |> after(server = function(input, output, session, data) {
teal_card(data) <- c(teal_card(data), teal.reporter::teal_card("Modification"))
within(data, object[, 1:2])
})
)
if (interactive()) {
shinyApp(app$ui, app$server)
} The web/module looks the same but the report has an extra output with just the first two columns. |
@llrs-roche also an example that covers point 1 and 2 from this example and when it comes to |
I am okay with showing how to use The current version of the vignette focus only on what is needed to add reporter to a custom module not on all the bells and whistles that a reporter has. Features like modifying the reporter template or have an app with a pre-loaded card might be better shown on teal.reporter. |
I think the pre-defining reporter and it's template is a part of teal, since |
Co-authored-by: Marcin <133694481+m7pr@users.noreply.github.com> Signed-off-by: Lluís Revilla <185338939+llrs-roche@users.noreply.github.com>
Co-authored-by: Marcin <133694481+m7pr@users.noreply.github.com> Signed-off-by: Lluís Revilla <185338939+llrs-roche@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the detailed review
) |> | ||
modify_header(tags$h2("Example teal app with reporter")) | ||
reporter = reporter | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Co-authored-by: Marcin <133694481+m7pr@users.noreply.github.com> Signed-off-by: Lluís Revilla <185338939+llrs-roche@users.noreply.github.com>
} | ||
``` | ||
`teal.reporter` supports the addition of tables, charts, and more. | ||
For more information, explore the API of `teal.reporter::ReportCard` to learn about the supported content types. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think teal.reporter::ReportCard
got deprecated. I think we should link to teal.reporter::teal_report
and it's teal_report-class
vignette
``` | ||
|
||
The key step is to return a `teal_report` object containing everything. | ||
This informs `teal` that the module provides a `reporter`, and teal will add a button `+ Add to Report` to add the modules' code to the report. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This informs `teal` that the module provides a `reporter`, and teal will add a button `+ Add to Report` to add the modules' code to the report. | |
This informs `teal` that the module provides a `reporter`, and teal will add a button `+ Add to Report` to add the modules' contents to the report. |
knitr::include_url(url, height = "800px") | ||
``` | ||
|
||
The key step is to return a `teal_report` object containing everything. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The key step is to return a `teal_report` object containing everything. | |
The key step is to return a reactive `teal_report` object containing everything. |
req(rtd <- report(), input$dataname) | ||
within(rtd, table, table = as.name(input$dataname)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we come up with a better variable name than rtd
and dr
(couple lines below)?
Having a descriptive variable may help learning process.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed to teal_data
on both cases to make it easier to remember and still be truthfhul but not sure if I should change also report
to report_r
(for reactive) and use report
instead of teal_data
.
However, there is no visible change in how the module operates and appears and the user cannot add content to the report from this module. | ||
That requires inserting UI and server elements of the `teal.reporter` module into the module body. | ||
The output hasn't changed (yet). | ||
We need one last step so that the module can be reported. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need one last step so that the module can be reported. | |
The final step is to have the server return the reporter object, enabling the module to be reported. |
I thought it would be good to mention what was the last/final step before we got to the next section.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added
`teal` exports the `TealReportCard` class, which extends the `teal.reporter::ReportCard` class and provides several convenient methods to facilitate working with `teal` features like the filter panel or source code. | ||
For more details, refer to the documentation of `TealReportCard`. | ||
If a module has the reporter functionality the teal app developer can disable it with `disable_report()`. | ||
To remove reporting from the whole application, set `reporter = NULL` in ìnit()`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To remove reporting from the whole application, set `reporter = NULL` in ìnit()`. | |
To remove reporting from the whole application, set `reporter = NULL` in init()`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's an example for disable_report(), do we need example for init(reporter=NULL)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure an example is needed as it would be even less interactive than what we have. But maybe we can add a sentence and a screenshot?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that would help
One can set a template of the report. | ||
Then each card added to the report will contain template's content by default. | ||
We can also add cards to the report before the application is started. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One can set a template of the report. | |
Then each card added to the report will contain template's content by default. | |
We can also add cards to the report before the application is started. | |
A template can be set for the report, ensuring that each card added to the report contains the template's default content. Additionally, cards can be added to the report before the application starts. |
Just a suggestion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the working but I slightly modified the sentence. Let me know if it flows well.
) | ||
) | ||
Once the reporter is created we can use in the teal application. | ||
We can also extend a report for a specific module using `after()`: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we explain more on after()
usage? So far, we only have this one liner and then the example code below. Maybe highlight a little bit on when user would want to use this function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll add more explanation about why and how to work with it.
Although it is a bit unclear to me, as the function doesn't have examples
or tests/testthat
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I opened a PR for after
: #1597
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with Marcin that it is better to work on that in a different branch/PR as I think the function needs more work. See this draft and comments: #1597
We need one last step so that the module can be reported. | ||
|
||
### Insert `teal.reporter` module | ||
### Return the reporter object |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should also be described in creating-custom-modules.Rmd
vignette.
Maybe just return the object there and reference here for more information.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch! I'll modify that vignette too
hey, when it comes to extending |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the feedback
req(rtd <- report(), input$dataname) | ||
within(rtd, table, table = as.name(input$dataname)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed to teal_data
on both cases to make it easier to remember and still be truthfhul but not sure if I should change also report
to report_r
(for reactive) and use report
instead of teal_data
.
`teal` exports the `TealReportCard` class, which extends the `teal.reporter::ReportCard` class and provides several convenient methods to facilitate working with `teal` features like the filter panel or source code. | ||
For more details, refer to the documentation of `TealReportCard`. | ||
If a module has the reporter functionality the teal app developer can disable it with `disable_report()`. | ||
To remove reporting from the whole application, set `reporter = NULL` in ìnit()`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure an example is needed as it would be even less interactive than what we have. But maybe we can add a sentence and a screenshot?
One can set a template of the report. | ||
Then each card added to the report will contain template's content by default. | ||
We can also add cards to the report before the application is started. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the working but I slightly modified the sentence. Let me know if it flows well.
We need one last step so that the module can be reported. | ||
|
||
### Insert `teal.reporter` module | ||
### Return the reporter object |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch! I'll modify that vignette too
However, there is no visible change in how the module operates and appears and the user cannot add content to the report from this module. | ||
That requires inserting UI and server elements of the `teal.reporter` module into the module body. | ||
The output hasn't changed (yet). | ||
We need one last step so that the module can be reported. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added
) | ||
) | ||
Once the reporter is created we can use in the teal application. | ||
We can also extend a report for a specific module using `after()`: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll add more explanation about why and how to work with it.
Although it is a bit unclear to me, as the function doesn't have examples
or tests/testthat
.
Pull Request
Fixes #1591
Blocked: Waiting for #1592 to be merged
Update the vignette to explain how teal.reporter can be used to generate the report on modules.
There might be room for improvement on the vignette as this is my first module using this new features.
Specially this section of code doesn't seem self explanatory:
It is an object of class
teal_report
(of a single module!) being modified by the functionteal_card
to addteal_card
s. But I might have got this wrong.Another thing I'm not confident is on having to use
module()[[input$dataname]]
for therenderPrint
. After having to add a line to print the table selected for the report.I removed lot's of apps that showed intermediate work, as I think now it can be done in two steps:
Awesome work that went into this!
In general, it felt very easy to set it up once I got around the
teal_reporter
andteal_card
classes seeing other modules on TMG. But let me know if I missed a clearer description.