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

feat: format errors #21

Merged
merged 30 commits into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
b2e354f
feat: now print errors if specified by option
timcadman Apr 30, 2024
a7ceaf9
fix: now only return message if error
timcadman Apr 30, 2024
e4f1846
chore: tests for assign expression
timcadman May 8, 2024
6039d56
feat: improved formatting
timcadman May 8, 2024
b4ab7b4
chore: added error handling to assign table and resource
timcadman May 8, 2024
16fb161
chore: updated dependencies
timcadman May 9, 2024
cb6c8fa
chore: updated docs
timcadman May 9, 2024
2493a40
chore: updated docs and added dependencies
timcadman May 9, 2024
3438f95
chore: added missing arguments and updated dependencies
timcadman May 9, 2024
2a963f0
feat: vary formatting depending on whether called within datashield.a…
timcadman Jun 17, 2024
0571651
feat: now return an error rather than warning
timcadman Jun 17, 2024
9e4ab36
feat: format .checkLastErrors in same style as datashield.errors
timcadman Jun 17, 2024
7e14637
return simpler error to avoid duplication
timcadman Jun 17, 2024
5cf8104
test: now test calling external script
timcadman Jun 17, 2024
78b2476
tidied up to pass check
timcadman Jun 17, 2024
c299047
fix: don't return error message if no errors
timcadman Jun 17, 2024
c428576
test: added test for no error scenario
timcadman Jun 17, 2024
790fee3
docs: align error message whether error returned direction or via dat…
timcadman Jul 4, 2024
6235bf3
feat: add cohort names into errors and format with nice colour
timcadman Jul 4, 2024
371a5d0
chore: added .DS_Store to ignores
timcadman Jul 4, 2024
023df34
test: test for more specific message and fixed broken test
timcadman Jul 4, 2024
6462ef9
chore: removed unnecessary dependencies
timcadman Jul 4, 2024
08e9f1c
chore: rm ds_store
timcadman Jul 4, 2024
84f9c62
fix: corrected direction of curly bracket
timcadman Jul 4, 2024
75bdc10
Merge branch 'master' into feat/format-errors
timcadman Jul 4, 2024
2cc2808
feat: added cli messages for aggregate and added tests
timcadman Oct 3, 2024
e314d47
added missing dependency to 'suggests', passed check'
timcadman Oct 3, 2024
23a0761
test: moved tests to DSLite
timcadman Oct 4, 2024
08c9eaf
chore: removed dependencies
timcadman Oct 4, 2024
c66de84
chore: removed dplyr dependency
timcadman Oct 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,5 @@ inst\/doc\/DSI\.b..$
^LICENSE.md
^LICENSE\.md$
^pkgdown$
.DS_Store
^CRAN-SUBMISSION$
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ figure
.RData
inst/doc
vignettes/*.R
.DS_Store
4 changes: 3 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ Depends:
R (>= 4.3),
methods,
progress,
R6
R6,
Imports:
cli
Suggests:
testthat (>= 2.1.0)
License: LGPL (>= 2.1)
Expand Down
3 changes: 3 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ exportClasses(DSObject)
exportClasses(DSResult)
import(R6)
import(progress)
importFrom(cli,cli_abort)
importFrom(cli,cli_alert_warning)
importFrom(cli,cli_bullets)
importFrom(methods,.valueClassTest)
importFrom(methods,getClass)
importFrom(methods,new)
30 changes: 19 additions & 11 deletions R/datashield.aggregate.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#' The expected function signature is the connection/study name and the result value. Default is NULL (no callback).
#' @param error Callback function that will be called each time the aggregation request has failed.
#' The expected function signature is the connection/study name and the error message. Default is NULL (no callback).
#'
#' @param return_errors Boolean, whether to print datashield errors in the console or return a message indicating that they can be retrieved using `datashield.errors`.
#' @return The result of the aggregation
#'
#' @examples
Expand Down Expand Up @@ -39,7 +39,7 @@
#' }
#'
#' @export
datashield.aggregate <- function(conns, expr, async=TRUE, success=NULL, error=NULL) {
datashield.aggregate <- function(conns, expr, async=TRUE, success=NULL, error=NULL, return_errors = getOption("datashield.return_errors", TRUE)) {
.clearLastErrors()
rval <- NULL

Expand All @@ -59,9 +59,9 @@ datashield.aggregate <- function(conns, expr, async=TRUE, success=NULL, error=NU
tryCatch({
results[[n]] <- dsAggregate(fconns[[n]], exprs[[n]], async=TRUE)
}, error = function(e) {
.appendError(n, e$message)
.appendError(n, conditionMessage(e))
if (.is.callback(error)) {
error(n, e$message)
error(n, conditionMessage(e))
}
})
}
Expand All @@ -73,9 +73,9 @@ datashield.aggregate <- function(conns, expr, async=TRUE, success=NULL, error=NU
.tickProgress(pb, tokens = list(what = paste0("Aggregating ", fconns[[n]]@name, " (", .deparse(exprs[[n]]), ")")))
results[[n]] <- dsAggregate(fconns[[n]], exprs[[n]], async=FALSE)
}, error = function(e) {
.appendError(n, e$message)
.appendError(n, conditionMessage(e))
if (.is.callback(error)) {
error(n, e$message)
error(n, conditionMessage(e))
}
})
}
Expand Down Expand Up @@ -115,11 +115,11 @@ datashield.aggregate <- function(conns, expr, async=TRUE, success=NULL, error=NU
rval[[n]] <- NULL
}
}, error = function(e) {
.appendError(n, e$message)
.appendError(n, conditionMessage(e))
completed[[n]] <- TRUE
rval[[n]] <- NULL
if (.is.callback(error)) {
error(n, e$message)
error(n, conditionMessage(e))
}
})
} else {
Expand All @@ -139,16 +139,24 @@ datashield.aggregate <- function(conns, expr, async=TRUE, success=NULL, error=NU
res <- dsAggregate(conns, exprs[[conns@name]])
dsFetch(res)
}, error = function(e) {
.appendError(conns@name, e$message)
.appendError(conns@name, conditionMessage(e))
if (.is.callback(error)) {
error(conns@name, e$message)
error(conns@name, conditionMessage(e))
}
NULL
})
if (.is.callback(success) && !.hasLastErrors(conns@name)) {
success(conns@name, rval)
}
}
.checkLastErrors()
if(return_errors == TRUE){
returned_errors <- datashield.errors(type = "assign")
if(!is.null(returned_errors)) {
cli_abort(c("There are some DataSHIELD errors: ", returned_errors), call = NULL)
}
} else if(return_errors == FALSE){
.checkLastErrors()
}
invisible(NULL)
rval
}
Loading