sol-eng / bike_predict

A demo of an end-to-end machine learning pipeline, using Posit Connect
92 stars 31 forks source link

update to use vetiver_deploy_rsconnect #36

Closed gsingh91 closed 1 year ago

gsingh91 commented 1 year ago

Current version uses rsconnect to deploy the vetiver API. we should update it to use vetiver_deploy_rsconnect function instead.

gsingh91 commented 1 year ago

updated code to use vetiver_deploy_rsconnect @SamEdwardes can you please review?

SamEdwardes commented 1 year ago

Hey at Gagan - the content has been failing since the update. Were you able to re-run the document on Workbench? For your reference, here are the logs from Connect.

Logs ``` 2022/10/05 09:00:28.980867619 [rsc-quarto] Working directory: /opt/rstudio-connect/mnt/app 2022/10/05 09:00:28.980883897 [rsc-quarto] Using R binary: /opt/R/4.1.3/bin/R 2022/10/05 09:00:29.405347169 [rsc-quarto] Configuring PATH='/opt/R/4.1.3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin' 2022/10/05 09:00:29.453067066 [rsc-quarto] Configuring R_HOME=/opt/R/4.1.3/lib/R 2022/10/05 09:00:29.453079785 [rsc-quarto] Running content using its packrat R library 2022/10/05 09:00:30.019677738 [rsc-quarto] Configuring R_LIBS='/opt/rstudio-connect/mnt/app/packrat/lib/x86_64-pc-linux-gnu/4.1.3' 2022/10/05 09:00:31.396840301 [rsc-quarto] Running 'quarto render' 2022/10/05 09:00:33.640345636 2022/10/05 09:00:33.640367875 2022/10/05 09:00:33.640815205 processing file: document.qmd 2022/10/05 09:00:33.855466753 | | | 0% | |... | 4% 2022/10/05 09:00:33.855502655 inline R code fragments 2022/10/05 09:00:33.855754221 2022/10/05 09:00:34.062036537 | |...... | 8% 2022/10/05 09:00:34.065218430 label: setup (with options) 2022/10/05 09:00:34.067616046 List of 3 2022/10/05 09:00:34.070227207 $ include : logi FALSE 2022/10/05 09:00:34.070947294 $ original.params.src: chr "r setup, include=FALSE" 2022/10/05 09:00:34.071328184 $ chunk.echo : logi FALSE 2022/10/05 09:00:34.071517626 2022/10/05 09:00:37.195591905 | |........ | 12% 2022/10/05 09:00:37.195862731 ordinary text without R code 2022/10/05 09:00:37.195867751 2022/10/05 09:00:37.195885831 | |........... | 16% 2022/10/05 09:00:37.196415743 label: connect_to_db (with options) 2022/10/05 09:00:37.196739393 List of 2 2022/10/05 09:00:37.197729122 $ original.params.src: chr "r connect_to_db" 2022/10/05 09:00:37.198494519 $ chunk.echo : logi FALSE 2022/10/05 09:00:37.198512834 2022/10/05 09:00:37.601289820 | |.............. | 20% 2022/10/05 09:00:37.601303112 ordinary text without R code 2022/10/05 09:00:37.601436996 2022/10/05 09:00:37.601438413 | |................. | 24% 2022/10/05 09:00:37.602346827 label: train_test_split_data (with options) 2022/10/05 09:00:37.602996874 List of 2 2022/10/05 09:00:37.603796367 $ original.params.src: chr "r train_test_split_data" 2022/10/05 09:00:37.605085068 $ chunk.echo : logi FALSE 2022/10/05 09:00:37.605093834 2022/10/05 09:01:27.732403687 | |.................... | 28% 2022/10/05 09:01:27.732415244 ordinary text without R code 2022/10/05 09:01:27.732570674 2022/10/05 09:01:27.732585850 | |...................... | 32% 2022/10/05 09:01:27.732636143 label: define_recipe (with options) 2022/10/05 09:01:27.732701570 List of 2 2022/10/05 09:01:27.732724882 $ original.params.src: chr "r define_recipe" 2022/10/05 09:01:27.732726798 $ chunk.echo : logi FALSE 2022/10/05 09:01:27.732749206 2022/10/05 09:01:28.007140965 | |......................... | 36% 2022/10/05 09:01:28.007157125 ordinary text without R code 2022/10/05 09:01:28.007243587 2022/10/05 09:01:28.007245357 | |............................ | 40% 2022/10/05 09:01:28.009127186 label: fit_model (with options) 2022/10/05 09:01:28.009474370 List of 2 2022/10/05 09:01:28.009481400 $ original.params.src: chr "r fit_model" 2022/10/05 09:01:28.009775513 $ chunk.echo : logi FALSE 2022/10/05 09:01:28.009783724 2022/10/05 09:02:29.530664569 | |............................... | 44% 2022/10/05 09:02:29.530682985 ordinary text without R code 2022/10/05 09:02:29.530868827 2022/10/05 09:02:29.530928790 | |.................................. | 48% 2022/10/05 09:02:29.530989129 label: evaluate_model (with options) 2022/10/05 09:02:29.530991723 List of 2 2022/10/05 09:02:29.531073350 $ original.params.src: chr "r evaluate_model" 2022/10/05 09:02:29.531075304 $ chunk.echo : logi FALSE 2022/10/05 09:02:29.531186437 2022/10/05 09:02:30.451015965 | |.................................... | 52% 2022/10/05 09:02:30.451028999 ordinary text without R code 2022/10/05 09:02:30.451056385 2022/10/05 09:02:30.451057513 | |....................................... | 56% 2022/10/05 09:02:30.451510623 label: create_vetiver_model (with options) 2022/10/05 09:02:30.451712615 List of 2 2022/10/05 09:02:30.452517488 $ original.params.src: chr "r create_vetiver_model" 2022/10/05 09:02:30.453177625 $ chunk.echo : logi FALSE 2022/10/05 09:02:30.453278470 2022/10/05 09:02:30.610701229 | |.......................................... | 60% 2022/10/05 09:02:30.610805629 ordinary text without R code 2022/10/05 09:02:30.610852070 2022/10/05 09:02:30.610933448 | |............................................. | 64% 2022/10/05 09:02:30.611716375 label: pin_model (with options) 2022/10/05 09:02:30.611817571 List of 2 2022/10/05 09:02:30.612329784 $ original.params.src: chr "r pin_model" 2022/10/05 09:02:30.613176606 $ chunk.echo : logi FALSE 2022/10/05 09:02:30.613184852 2022/10/05 09:02:30.892267996 Connecting to RSC 2022.09.0 at 2022/10/05 09:02:48.226844171 Writing to pin 'sam.edwardes/bike_predict_model_r' 2022/10/05 09:02:48.239987132 2022/10/05 09:02:48.239998046 Create a Model Card for your published model 2022/10/05 09:02:48.240034074 • Model Cards provide a framework for transparent, responsible reporting 2022/10/05 09:02:48.240035384 • Use the vetiver `.Rmd` template as a place to start 2022/10/05 09:02:48.240041758 This message is displayed once per session. 2022/10/05 09:02:48.242503603 | |................................................ | 68% 2022/10/05 09:02:48.242511684 ordinary text without R code 2022/10/05 09:02:48.242546589 2022/10/05 09:02:48.242547523 | |.................................................. | 72% 2022/10/05 09:02:48.242855500 label: write_model_to_plumber (with options) 2022/10/05 09:02:48.243085204 List of 2 2022/10/05 09:02:48.243807250 $ original.params.src: chr "r write_model_to_plumber" 2022/10/05 09:02:48.244475583 $ chunk.echo : logi FALSE 2022/10/05 09:02:48.244480624 2022/10/05 09:02:55.485143209 | |..................................................... | 76% 2022/10/05 09:02:55.485265924 ordinary text without R code 2022/10/05 09:02:55.485287033 2022/10/05 09:02:55.485313594 | |........................................................ | 80% 2022/10/05 09:02:55.485893402 label: preview_plumber_file (with options) 2022/10/05 09:02:55.486303836 List of 5 2022/10/05 09:02:55.486900589 $ results : chr "asis" 2022/10/05 09:02:55.487616839 $ collapse : logi FALSE 2022/10/05 09:02:55.488236365 $ echo : logi FALSE 2022/10/05 09:02:55.488927748 $ original.params.src: chr "r preview_plumber_file, results='asis', collapse=FALSE, echo=FALSE" 2022/10/05 09:02:55.489666214 $ chunk.echo : logi FALSE 2022/10/05 09:02:55.489672027 2022/10/05 09:02:55.503257992 | |........................................................... | 84% 2022/10/05 09:02:55.503265872 ordinary text without R code 2022/10/05 09:02:55.503296943 2022/10/05 09:02:55.503467983 | |.............................................................. | 88% 2022/10/05 09:02:55.504309483 label: deploy_model_api_to_connect (with options) 2022/10/05 09:02:55.504315820 List of 2 2022/10/05 09:02:55.505384656 $ original.params.src: chr "r deploy_model_api_to_connect" 2022/10/05 09:02:55.505610743 $ chunk.echo : logi FALSE 2022/10/05 09:02:55.505616565 2022/10/05 09:02:55.532837734 Registered S3 methods overwritten by 'connectapi': 2022/10/05 09:02:55.532848916 method from 2022/10/05 09:02:55.532887307 dim.tbl_lazy dbplyr 2022/10/05 09:02:55.532888297 dimnames.tbl_lazy dbplyr 2022/10/05 09:02:55.539396418 Defining Connect with server: https://colorado.rstudio.com/rsc/ 2022/10/05 09:02:58.439196510 Loading required namespace: plumber 2022/10/05 09:02:58.533912986 Quitting from lines 234-250 (document.qmd) 2022/10/05 09:02:58.533923769 Error: You must register an account using setAccountInfo prior to proceeding. 2022/10/05 09:02:58.534099590 In addition: Warning messages: 2022/10/05 09:02:58.534417522 1: In dir.create("api") : 2022/10/05 09:02:58.534587375 'api' already exists 2022/10/05 09:02:58.535307613 2: You are using a newer version of RStudio Connect(2022.09.0) than was tested (2021.12.1).Most APIs should function as expected. 2022/10/05 09:02:58.535320946 This warning is displayed once per session. 2022/10/05 09:02:58.536789611 Execution halted ```

Also, not that we are using vetiver_deploy_rsconnect do we need to create the client object?

app_name <- "bike-predict-r-api"
app_title <- "Bike Predict - Model - API"

# Establish a connection to RStudio connect.
client <- connectapi::connect(
  server = Sys.getenv("CONNECT_SERVER"),
  api_key = Sys.getenv("CONNECT_API_KEY")
)

# Deploy the content.
vetiver_deploy_rsconnect(
  board = board,
  name = pin_name,
  version = NULL,
  appTitle = app_title,
)
gsingh91 commented 1 year ago

@SamEdwardes I am able to reproduce locally. I was able to test it before as I was using my Connect credentials and my own pin. Have reverted my changes to continue the previous deployments. working on making this change locally for now.

gsingh91 commented 1 year ago

raised an issue on vetiver for Connect deployment: https://github.com/rstudio/vetiver-r/issues/151

SamEdwardes commented 1 year ago

Thanks Gagan!

gsingh91 commented 1 year ago

The issue seems to be with my Colorado env, so I tested the changes locally. Created PR #37 , @SamEdwardes can you please do a quick test and merge? Thanks