-
Notifications
You must be signed in to change notification settings - Fork 68
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
Non-interactive (batch) mode #976
Comments
Initializing the embedded R in non-interactive mode is more tedious and less documented than ideal, but you might be able to get away with it by setting R to non-interactive after initialization. Try: import rpy2.rinterface as ri
ri.initr()
ri.openrlib.rlib.R_Interactive = False |
Fix rpy2#976 by configuring interactive mode through environment variable
@lgautier Thanks for the answer! Unfortunately, because it could be more than one entry point in production code (for example in the application and in the tests) this solution leads to a violation of DRY and it's easy to forget to write it in some new entry point. Could you please consider my PR #980 with an environment variable-based setting? It allows setting batch mode in a clean way in one place. |
…able (cherry picked from commit 223e2ae)
The initialization variables are the R interactivity state (issue #976) and the max size of the C stack.
I am not a big fan of having an environment variable here. The interactivity status can be set (changed) at any time in the Python code. The embedded R is initialized only once (the public function import rpy2.rinterface_lib.embedded
rpy2.rinterface_lib.embedded._initr(interactive=False)
# from now R will stay initialized and in non-interactive mode I caught missed in the API though, and wrote an PR to fix them. With PR #986 it can be written import rpy2.rinterface as ri
ri.initr(interactive=False)
# from now R will stay initialized and in non-interactive mode I have also made the default initialization a module-level variable, albeit not a public one to indicate that things are less safe. import rpy2.rinterface.embedded
rpy2.rinterface_embedded._DEFAULT_R_INTERACTIVE = False
# from now on the default interactive-mode for R as initialization is the non-interactive mode...
# ... unless this is reverted before R is initialized, or R is initialized when a different interactive mode. |
* Default for R initialization are now module-level variables. The initialization variables are the R interactivity state (issue #976) and the max size of the C stack.
Fixed with PR #986 , and included in rpy2 release 3.5.8. |
We are currently utilizing rpy2 in our production code and have encountered issues with the interactive mode causing the entire application to become stuck when certain libraries are awaiting input.
A solution would be to implement a way to force rpy2 to operate in non-interactive mode for R.
The text was updated successfully, but these errors were encountered: