silence warning/errors from infering reticulate python #13541
Merged
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.
Intent
On startup, the IDE will attempt to infer what what Python installation reticulate would select to load.
Part of this inference routine may involve launching a subprocess that calls
reticulate::py_discover_config()
.reticulate::py_discover_config()
may raise warnings or errors if it encounters a python installation that would be preferred, but is broken for some reason (e.g., a virtual environment where the python installation it is derived from has been removed).The intent of this PR is to not present those warnings or errors to the user as part of the IDE session startup routine. In that context they are not actionable, and the text of the warning can be occasionally cryptic.
The user will may still encounter the same error message if/when they attempt to use Python via reticulate.
Closes rstudio/reticulate#1449
Approach
Wrap the
reticulate::py_discover_config()
call withsuppressWarnings(tryCatch())
Automated Tests
QA Notes
To test, create a broken python installation in a reticulate prefered location, and confirm that no warnings/errors are shown until the user explicitly causes reticulate to initialize python.
library(reticulate)
confirm no warnings/errors.py_eval('1')