-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Enable override the is_interactive function. #634
Conversation
I suspect a better eventual solution is for httr to use https://rlang.r-lib.org/reference/is_interactive.html That affords various options for temporarily overriding the inferred interactive state. It would be odd for httr itself to export such a function. As maintainer of the packages you are probably using for "R and Google Drive / Sheets in Google Colaboratory", I'd be curious to hear more. Now that I think about it, I suspect this is related to tidyverse/googledrive#284, which I think is a more profound problem than just overriding |
@jennybc using this workaround I could successfully use googledrive and googlesheets4 to access files and sheets. But its really heavy. I restart my httr fork and make your suggestion. Yes, changing to: is_interactive <- function() rlang::is_interactive() also solve with use of: options(rlang_interactive=TRUE) another hack that I test was to verify if is running under colab. which have the advantage that workbooks could works seamlessly without changes. but its a terrible hack at now. is_interactive <- function() {
if (file.exists("/usr/local/lib/python3.6/dist-packages/google/colab/_ipython.py")) {
return(TRUE)
} else {
return(interactive())
}
} |
@jobdiogenes Do you have an example colab notebook where you can connect to Google Drive? I have tried here using your fork, but it still fails. devtools::install_github("jobdiogenes/httr")
devtools::install_github("tidyverse/googledrive")
library(googledrive)
options(rlang_interactive = TRUE)
drive_auth(use_oob = TRUE)
|
@nacnudus Yes, I did some more tests. demo-of-use-google-drive-sheets-in-r-with-google-colaboratory.ipynb |
Thank you @jobdiogenes, that works! |
The Notebook no longer works for me. |
The notebook works if you do the same for rlang as for httr. Both of them have to be overridden. I'll comment on the gist too. |
The notebook are working again. Although reassign is_interactive in rlang solves. |
This conversation should be informed by r-lib/rlang#1033. It doesn't get at or solve the heart of the issue, but it's related. |
In some cases checking if is interactive mode are not as we need.
Since is_interactive parameter are deprecated and the is_interactive function enable to mocked the native interactive function.
This pull request add just two lines to export is_interactive function that is in
oauth-init.R, enabling developers to override is_interactive.
I use this to help me use R and Google Drive / Sheets in Google Colaboratory, which are also useful to many users.
But its also useful to others cases and tests.