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

silence warning/errors from infering reticulate python #13541

Conversation

t-kalinowski
Copy link
Member

@t-kalinowski t-kalinowski commented Aug 23, 2023

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.

Describe briefly what problem this pull request resolves, or what new feature it introduces. Include screenshots of any new or altered UI. Link to any Github issues that are related.

Closes rstudio/reticulate#1449

Approach

Wrap the reticulate::py_discover_config() call with suppressWarnings(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.

  1. Create the broken state
reticulate:::rm_all_reticulate_state()
install_python()
virtualenv_create(force=TRUE) # r-reticulate
unlink("~/.pyenv", recursive = TRUE)
  1. restart R session in the IDE (cmd+shift+0). Confirm no warnings/errors are shown
  2. Load reticulate namespace, library(reticulate) confirm no warnings/errors.
  3. Cause reticulate to initialize python, confirm warning or error is shown: py_eval('1')

@t-kalinowski t-kalinowski marked this pull request as draft August 23, 2023 14:09
@t-kalinowski t-kalinowski marked this pull request as ready for review August 23, 2023 14:23
@kevinushey kevinushey merged commit 8a219ca into rstudio:main Aug 23, 2023
@kevinushey
Copy link
Contributor

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

IDE shows error when a venv starter is removed
2 participants