-
-
Notifications
You must be signed in to change notification settings - Fork 42
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
Introduce the new DDL (module) #955
Conversation
# Calculate app hash to ensure snapshot compatibility. See ?snapshot. Raw data must be extracted from environments. | ||
hashables <- mget(c("data", "modules")) | ||
hashables$data <- if (inherits(hashables$data, "teal_data")) { | ||
as.list(hashables$data@env) | ||
} else if (inherits(hashables$data, "ddl")) { |
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 don't have ddl class anymore but code is still 'teal_module_data' . Could we check the presence of 'teal_module_data' in the 'modules' and retrieve the code from 'server_arg' ?
e.g
module_data <- extract_module(modules, "teal_module_data")
if (length(module_data) > 1L) {
module_data$super_data$server_args$code # seperate logic to extract code
}
before splitting ddl and shiny modules
I've made a push a code where data module is accepted in data . There is still a chance to include this to the |
Out of all the available options we have I like this one the most. I think that the PR #957 (transform module) should be an extension of this (i.e. new constructor of (I do have a few implementation comments but I will hold off for now to first agree on the approach) |
return(data) | ||
} | ||
|
||
if (identical(ls(data@env), character(0))) { |
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.
In case some objects' names starts with .
?
if (identical(ls(data@env), character(0))) { | |
if (identical(ls(data@env, all.names = TRUE), character(0))) { |
#' `ddl` developer must understand that this is a security risk and should be handled with care. | ||
#' To make sure that the code is reproducible, `ddl` object should be used with `input_mask` argument. | ||
#' `teal` provides convenience function [eval_and_mask()] which handles evaluation of the code, masking | ||
#' and creating `teal_data` object. Such `server` function could look like this: |
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.
#' and creating `teal_data` object. Such `server` function could look like this: | |
#' and the creation of `teal_data` object. Such `server` function could look like this: |
#' } | ||
#' ``` | ||
#' | ||
#' If `ddl` developer values more control, then might be interested in using `...` explicitly, |
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 don't see how this can give any more control. I don't see examples a way of using it differently than with input and input_mask. Any chance we can provide advanced examples (maybe in a separate manual page) to reduce the clutter?
#' If `ddl` developer values more control, then might be interested in using `...` explicitly, | |
#' If `ddl` developers values more control, they might be interested in using `...` explicitly, |
Hey, I like the approach as it is easy to follow from the implementation perspective. I think it was originally created for
I do agree with @pawelru as I see we could provide similar comments from other approaches in here (example is the way we use regexes for input substitution).
I would only double check the name: |
|
||
# replace last code entry with masked code | ||
# format_expression needed to convert expression into character(1) | ||
# question: warnings and errors are not masked, is it ok? |
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.
just in case i think those also should be (tried to be) masked
Given that |
@pawelru exactly. But I would add also optional
In above example everything is fine,
I think it's exactly the opposite which I've proved here This is why I think |
Hmmm... I was expecting this idea (i.e. module) to evolve into a simple module rather than the "transform module". We were thinking about the same but different naming :) |
I agree, in
So what I did in my last PR - I've changed assertion to accept |
Closing this PR as this entirely covers this case. Alternative PR uses similar concept like |
Part of #937
Closes #895
I introduce new type of module
tm_teal_data
(classteal_module_data
), which allows to make any modification on existingteal_data
object. Constructor oftm_teal_data
is very similar to ddlI included
tm_teal_data
inteal::init(modules)
for one reason. Users might have some data created in pre-processing (before app starts) and some might be added in the interactive session. This solution prevents to load big objects inddl
which could be loaded before shiny starts - and thus not to influence app loading time.Some key notes:
ui
andserver
and must return modified (or not modified)teal_data
object.datanames
andjoin_keys
(returned reactive containsdatanames
andjoin_keys
) some asserts needed to be moved further.Example app code