-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Fix verbose for R bindings
#3691
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
Conversation
| #include <Rcpp.h> | ||
|
|
||
| // To suppress Found '__assert_fail', possibly from 'assert' (C). | ||
| #define BOOST_DISABLE_ASSERTS |
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.
@coatless @eddelbuettel @Yashwants19 if you don't mind sanity checking me on this one since I am not an R expert... I think it's no longer needed since we aren't using Boost.
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.
Agreed, just remove.
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.
Yup, no longer needed with the shift away from boost!
|
That's a fine catch of the singleton issue. I guess we could add a testthat predicate or two for silent vs verbose expectations? (Not a big user of testthat myself but these test runners are all roughly equivalent.) |
|
Thanks @rcurtin ! I just noticed that I forgot to mention a small suggestion in relation to verbose argument. It might be worth adding the ability to set the verbose state at the package level using Practically, if a user wants to use verbose in all invocations then using |
|
Good point. And by using global state from R (as offered by R) you can also flip it on/off programmatically in subroutines. |
|
Yeap! |
eddelbuettel
left a comment
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.
Approving now with most but not all CI runs green. The Azure stuff I will ignore 😎
coatless
left a comment
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.
LGTM.
On the note of global options raised earlier, I would suggest adding that as a separate issue as it would involve modifications to how the function parameters are populated to get getOption() component, c.f.
mlpack/src/mlpack/bindings/R/print_R.cpp
Line 158 in 3e2a677
| for (size_t i = 0; i < inputOptions.size(); ++i) |
| #include <Rcpp.h> | ||
|
|
||
| // To suppress Found '__assert_fail', possibly from 'assert' (C). | ||
| #define BOOST_DISABLE_ASSERTS |
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.
Yup, no longer needed with the shift away from boost!
This fixes #3675.
I reproduced the issue and found that the
verboseargument to mlpack's R bindings had no effect, even though theEnableVerbose()function was successfully being called.This is because
Log::Info(which is what theEnableVerbose()function modified) is a singleton object, and exists once in each translation unit. SinceEnableVerbose()is compiled into the translation unit for the filer_util.cpp, theLog::Infomodified byEnableVerbose()ends up being different than theLog::Infothat is being used by each individual binding---so, in essence, we are enabling verbose mode... with the wrongLog::Infoobject.I fixed this by removing the standalone
EnableVerbose()andDisableVerbose()functions, and instead modifying theLog::Infoobject's verbose state directly inside each printed binding. So, e.g., this block is now gone from the R code:and the actual binding code, which before looked like this:
now looks like this:
and so when I run the example code provided by @cgiachalis:
I get this output instead of nothing:
Hooray!