-
-
Notifications
You must be signed in to change notification settings - Fork 8
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
Refactor #161
Closed
Refactor #161
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
e622149
any data possible
gogonzo 9827de3
Merge remote-tracking branch 'origin/main' into refactor
gogonzo 2daf83a
Merge remote-tracking branch 'origin/main' into refactor
gogonzo bef092f
ddl
gogonzo 3f723f3
Merge bef092fd1955e566716e9d182b647657d1eac1ca into ba573f2544bf8591e…
gogonzo 5e3c0cb
[skip actions] Restyle files
github-actions[bot] 7429b55
adjust to teal
gogonzo e964b95
fix
gogonzo 1b1ebc6
Merge e964b95be5111216e924621b7793ff046249de99 into ba573f2544bf8591e…
gogonzo 3f37efe
[skip actions] Restyle files
github-actions[bot] 212806c
change arg names
gogonzo 7d9e2b0
Merge branch 'main' into refactor
gogonzo 7edaf2a
cleanup builds
m7pr b30029b
@anverissimo review
gogonzo 2248740
Merge remote-tracking branch 'origin/main' into refactor
gogonzo 1ca4cb1
ddl alternative (#167)
chlebowa 6504197
ddl WIP
gogonzo d067b93
POC
gogonzo 56a7b2d
tdata -> teal_data
gogonzo f3876df
mask_args -> input_mask
gogonzo c407adf
online_args -> input
gogonzo 5443613
ddl_run - input can be of class "reactivevalues"
gogonzo 48e0f3b
handling datanames information
gogonzo 6b46e4c
ddl from teal.data to teal
gogonzo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,6 +33,7 @@ Imports: | |
shinyjs, | ||
stats, | ||
teal.logger (>= 0.1.1), | ||
teal.code, | ||
utils, | ||
yaml (>= 1.1.0) | ||
Suggests: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#' Function to get join keys from a `` object | ||
#' @param data `` - object to extract the join keys | ||
#' @return Either `JoinKeys` object or `NULL` if no join keys | ||
#' @export | ||
get_join_keys <- function(data) { | ||
UseMethod("get_join_keys", data) | ||
} | ||
|
||
|
||
#' @rdname get_join_keys | ||
#' @export | ||
get_join_keys.teal_data <- function(data) { | ||
data@join_keys | ||
} | ||
|
||
#' @rdname get_join_keys | ||
#' @export | ||
get_join_keys.TealData <- function(data) { | ||
data$get_join_keys() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
setOldClass("JoinKeys") | ||
|
||
#' @import teal.code | ||
#' @export | ||
setClass( | ||
Class = "teal_data", | ||
contains = "qenv", | ||
slots = c(join_keys = "JoinKeys", datanames = "character"), | ||
prototype = list( | ||
join_keys = join_keys(), | ||
datanames = character(0) | ||
) | ||
) | ||
|
||
#' Initialize `teal_data` object | ||
#' | ||
#' Initialize `teal_data` object. | ||
#' @name new_teal_data | ||
#' | ||
#' @param code (`character(1)` or `language`) code to evaluate. Accepts and stores comments also. | ||
#' @param env (`list`) List of data. | ||
#' @param keys (`JoinKeys`) object | ||
#' @param datanames (`character`) names of datasets in `env`. Needed when non-dataset | ||
#' objects are needed in the `env` slot. | ||
#' | ||
#' @examples | ||
#' new_teal_data(env = list(a = 1), code = quote(a <- 1)) | ||
#' new_teal_data(env = list(a = 1), code = parse(text = "a <- 1")) | ||
#' new_teal_data(env = list(a = 1), code = "a <- 1") | ||
#' | ||
#' @export | ||
setGeneric("new_teal_data", function(env = new.env(), code = expression(), keys = join_keys(), datanames = character()) { | ||
standardGeneric("new_teal_data") | ||
}) | ||
|
||
#' @rdname new_teal_data | ||
#' @export | ||
setMethod( | ||
"new_teal_data", | ||
signature = c(env = "list", code = "expression", keys = "ANY"), | ||
function(env, code, keys = join_keys(), datanames = names(env)) { | ||
new_env <- rlang::env_clone(list2env(env), parent = parent.env(.GlobalEnv)) | ||
lockEnvironment(new_env, bindings = TRUE) | ||
id <- sample.int(.Machine$integer.max, size = length(code)) | ||
methods::new( | ||
"teal_data", | ||
env = new_env, | ||
code = code, | ||
warnings = rep("", length(code)), | ||
messages = rep("", length(code)), | ||
id = id, | ||
join_keys = keys, | ||
datanames = as.character(union(names(env), names(keys$get()))) | ||
) | ||
} | ||
) | ||
|
||
#' @rdname new_teal_data | ||
#' @export | ||
setMethod( | ||
"new_teal_data", | ||
signature = c(env = "list", code = "language", keys = "ANY"), | ||
function(env, code, keys = join_keys(), datanames = names(env)) { | ||
code_expr <- as.expression(code) | ||
new_teal_data(env = env, code = code_expr, keys = keys, datanames = datanames) | ||
} | ||
) | ||
|
||
#' @rdname new_teal_data | ||
#' @export | ||
setMethod( | ||
"new_teal_data", | ||
signature = c(env = "list", code = "character", keys = "ANY"), | ||
function(env, code, keys = join_keys(), datanames = names(env)) { | ||
code_expr <- parse(text = code) | ||
new_teal_data(env = env, code = code_expr, keys = keys, datanames = datanames) | ||
} | ||
) |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 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.
Ah great!
The function I used before is the soon-to-be-deprecated
assert_named()
which had a non-descriptive error message (failed: Must have Object.
), but this is much cleaner :-)