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

Support board_deparse for Google Drive #820

Open
aephidayatuloh opened this issue Jan 4, 2024 · 3 comments
Open

Support board_deparse for Google Drive #820

aephidayatuloh opened this issue Jan 4, 2024 · 3 comments
Labels
feature a feature request or enhancement

Comments

@aephidayatuloh
Copy link

aephidayatuloh commented Jan 4, 2024

Hi,

I use google drive as a board and get error when write plumber.

library(pins)
library(vetiver)
library(plumber)

mc <- lm(mpg ~., data = mtcars)
v <- vetiver_model(model = mc, "mtcars")

model_board <- board_gdrive("https://drive.google.com/drive/folders/1NjzouASz0omeWbejGj0r2p3TzsVhAeTN")

model_board |> 
  vetiver_pin_write(v)

pr() |> 
  vetiver_api(v, debug = TRUE) 
vetiver_write_plumber(model_board, "mtcars", rsconnect = FALSE)
Error in `pins::board_deparse()`:
! This board doesn't support deparsing
Run `rlang::last_trace()` to see where the error occurred.

> rlang::last_trace()
<error/rlang_error>
Error in `pins::board_deparse()`:
! This board doesn't support deparsing
---
Backtrace:
    ▆
 1. └─vetiver::vetiver_write_plumber(model_board, "mtcars", rsconnect = FALSE)
 2.   ├─rlang::expr_deparse(pins::board_deparse(board))
 3.   │ └─rlang:::quo_deparse(x, deparser)
 4.   │   └─rlang::is_quosure(x)
 5.   ├─pins::board_deparse(board)
 6.   └─pins:::board_deparse.pins_board(board)
Run rlang::last_trace(drop = FALSE) to see 1 hidden frame.
> packageVersion("pins")
[1] ‘1.3.0’
> packageVersion("vetiver")
[1] ‘0.2.5’
> packageVersion("plumber")
[1] ‘1.2.1’

Anyone can help me to understand and solve this problem?
Thank you.

@juliasilge
Copy link
Member

Ah, what is happening here is that vetiver_write_plumber() is trying to automatically generate a plumber file for you, but the Google Drive pins board doesn't support that kind of automated code generation because we don't have a method for it in pins.

The main reason we haven't added that is that Google Drive is S L O W for reading big objects like models (even for small files, too, in my experience) and I don't expect it to be useful for realistic use cases. If you use Google Drive to store your model, it will take a really long time for your vetiver API to be up and ready to go. In the framing of my recent MLOps talk, it will have really terrible performance in the software sense (not statistical sense).

Is it possible for you to use another pins backend to store your model? One more suited to serving predictions via an API? Or can you share a little more about why you are wanting to use Google Drive?

@aephidayatuloh
Copy link
Author

Thank you @juliasilge for your explanation.

First, I'm new to vetiver but I found it is very useful. I'm just trying to use Google Drive as my board because my company uses Google Drive as cloud storage services. So Ithink "why not I use it to store my model?". FYI, I've successfully deploy vetiver model using pins board_folder().

If I still want to use Google Drive as my board, can I just use board_folder() to generate model file, plumber.R, dockerfile and vetiver_renv.lock and then upload all the files to my gdrive manually So I still can use gdrive as my board? And how about the computational performance after my API ready?

@juliasilge
Copy link
Member

I am afraid that Google Drive will be just super duper slow no matter how you use it, but certainly your constraints might be different than what I am picturing.

Would you be willing to try this out:

  • Generate a vetiver plumber file using board_folder()
  • Edit the generated file so it goes to board_gdrive() instead of board_folder(), i.e. replace the pins code with board <- board_gdrive("folder-for-your-model")
  • Try deploying your model to see if the API starts up fast enough

If this works OK for your constraints, then certainly I could add the board_deparse method to pins so this will work more as you expected it to.

@juliasilge juliasilge transferred this issue from rstudio/vetiver-r Jan 19, 2024
@juliasilge juliasilge changed the title This board doesn't support deparsing Support board_deparse for Google Drive Jan 19, 2024
@juliasilge juliasilge added the feature a feature request or enhancement label Jan 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature a feature request or enhancement
Projects
None yet
Development

No branches or pull requests

2 participants