-
Notifications
You must be signed in to change notification settings - Fork 6
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
base: master
Are you sure you want to change the base?
Conversation
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.
R/datashield.assign.R
Outdated
.checkLastErrors() | ||
if(return_errors == TRUE){ | ||
cli_text() | ||
cli_alert_warning("Error: There are some DataSHIELD errors ") |
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.
What happens when the execution is not in a CLI context, like a batch script execution?
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.
Do you mean eg calling datashield.assign.expr in a loop? Or you had something else in mind?
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.
No, I mean when there is no command line, like when executing code with Rscript.
Sorry Yannick, not sure what happened yesterday ... trying to do 17 things at once! |
…ssign, remove { } brackets as cause issues with cli
Hi Yannick, following your comments:
|
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.
Please rebase to master, there are conflicts in the NAMESPACE.
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.
Please add .DS_Store
to .gitignore
and .Rbuildignore
(thank you Apple for the noise).
#' @importFrom purrr map | ||
#' @importFrom stringr str_replace_all | ||
.remove_curly_brackets <- function(errors) { | ||
errors <- errors %>% map(~str_replace_all(.x, "\\{", "(")) |
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.
Try to minimize the package dependencies. I don't think you need all the fancy packages dplyr, purr and stringr for that function, just go the plain old R way:
# Replace all curly brackets with parentheses
output_string <- gsub("\\{", "(", input_string)
output_string <- gsub("\\}", ")", output_string)
Implement two main changes:
return_error
todatashield.assign
functions, giving the option either to immediately return errors or to store them to be accessible with a call todatashield.errors
Note: tests written for
datashield.assign.expr
; however I was unable to create errors with eitherdatashield.assign.table
ordatashield.assign.resource
. If you have code which will do this tell me and I'll add tests.