Closed
Description
We need to find an optimal way to allow app developer to "decorate" output of the module (including interactivity). In tmc modules are developed as follows.
- there is a template_xy function which generates a list of calls needed to produce an output
- template_xy is evaluated in qenv and plots use to be assigned to
p
binding (it is defined in the template) - then
p
variable is extracted from qenv and passed toplot_with_settings
template_xy <- function(... <many arguments like dataname xvar yvar>) {
}
srv_xy <- function(...) {
...
all_q <- reactive({
my_calls <- template_xy(...)
teal.code::eval_code(anl_q(), as.expression(my_calls))
})
plot_r <- reactive(all_q()[["p"]])
plot_with_settings(plot_r)
}
We need to find a nice way to include any arbitrary code to change the p
. No holds barred!
Issue should be addressed by POC
Definition of Done
- Research on how to decorate module output
- Followed by PoC(s) for coreDev and SME review -> [Discussion]: Discuss with SME team the concept of module decoration #1385
- Once decided, refine and create actionable issue for implementation
Metadata
Metadata
Assignees
Type
Projects
Status
Done
Relationships
Development
No branches or pull requests
Activity
[-]Decorate module output[/-][+][research] Decorate module output[/+]gogonzo commentedon Aug 22, 2024
Discussion 1 summary
@kpagacz and I discussed the issue and decided to first focus on allowing app developers to provide arbitrary code to modify the module’s output. Interactivity is not yet included. We agreed almost immediately that decorators need to be provided through the
tm_xyz
argument and passed down byserver_args
to thesrv_xyz
. Discussion about the other ways seems irrelevant, but we will come back to this later. We considered three scenarios, though the list is not exhaustive.1. Decorator passed as expression list
Above call could be passed to the server and in the reactive which produces the plot call it would look something like this:
ggplot_args
p
object created inside of the module.p
doesn't have to be used as it will be automatically added to the final callggplot
elements.2. Decorator as a function
Inside of the module above would be consumed in the following way. Because function is passed as expression it will be added to SRC for reproducibility.
data
object name norp
3. teal_transform_module
If we consider that some decorations will depend on the app user input (limiting axes range, changing title etc.) then
teal_transform_module
could be a solution.teal
qenv
likeplot
orADSL
gogonzo commentedon Aug 23, 2024
Discussion 2 summary
After short meeting, we agreed that in order to execute any custom call inside of the teal_module one of the following is needed:
function(plot)
without knowing howplot
is named inside thesrv_xy
. Inside of thesrv_xy
body, module-developer would calldecorator(plot = p)
. Function can have more arguments, for examplefunction(plot, data)
for example to addggplot
elements dependent on somedata
.plot
anddata
doesn't have to be the exact names inside of the teal_module. Then the module documentation should explicitly say that plot object is namedp
and data object is namedADSL
. In most of the cases dataname is not fixed, so app-developer would have to know that if module receivesiris
theniris
needs to be included in a decorate.gogonzo commentedon Sep 16, 2024
Conclusions from the last (general) meeting
ui
andserver
is needed for decoration in some casesInitial apps showing apps the problem
Initial app for plot decoration (simple case, one output)
shajoezhu commentedon Sep 23, 2024
16 remaining items