rstudio/vetiver-r

`vetiver_sm_endpoint()` error "object b not found"

Closed this issue · 11 comments

Hi everyone,

Thanks a lot for your work on this package!

I try to deploy a vetiver API in SageMaker from my local RStudio (not within SageMaker). Following the procedure discussed in this issue #215, I managed to set up my ARN IAM roles accordingly so that vetiver_sm_build() and vetiver_sm_model() run without any further problems. However, I am somehow failing to set up an API endpoint with vetiver_sm_endpoint().

I am running the following code where I am using an execution role setup according to your explanations above and also my aws_acces_key_id and aws_secret_access_key are provided in .Renviron.

library(vetiver)
library(pins)

name <- "cars-lm"

lm_model <- lm(mpg ~ ., data = mtcars)

v_model <-
  vetiver_model(
    lm_model,
    name
  )

model_board <-
  board_s3(
    bucket = "mlr4all-test-bucket",
    region = "us-east-1"
  )

model_board %>%
  vetiver_pin_write(v_model)

execution_role <- "arn:aws:iam::069650456288:role/vetivertest"

new_image_uri <-
  vetiver_sm_build(
    board = model_board,
    name = name,
    repository = glue::glue("vetiver-sagemaker-{name}:{strftime(Sys.time(), '%Y-%m-%d')}"),
    role = execution_role,
    bucket = model_board$bucket
  )

model_name <-
  vetiver_sm_model(
    image_uri = new_image_uri,
    role = execution_role
  )

new_endpoint <-
  vetiver_sm_endpoint(
    model_name = model_name,
    instance_type = "ml.t2.medium"
  )

Everything works smoothly until vetiver_sm_endpoint(). There I get the following error message:

error_message

When I check CloudWatch for the respective endpoint I find the following:

error_cloud_watch

I don't really understand that error message and I also don't know where this error could come from.

Any help would be really nice!
Thank you guys a lot for your work!

Session info
sessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value
#>  version  R version 4.2.3 (2023-03-15 ucrt)
#>  os       Windows 10 x64 (build 22621)
#>  system   x86_64, mingw32
#>  ui       RTerm
#>  language (EN)
#>  collate  German_Germany.utf8
#>  ctype    German_Germany.utf8
#>  tz       Europe/Berlin
#>  date     2023-10-30
#>  pandoc   3.1.1 @ C:/Program Files/RStudio/resources/app/bin/quarto/bin/tools/ (via rmarkdown)
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  ! package                * version date (UTC) lib source
#>  P base64enc                0.1-3   2015-07-28 [?] CRAN (R 4.2.0)
#>  P bit                      4.0.5   2022-11-15 [?] CRAN (R 4.2.3)
#>  P bit64                    4.0.5   2020-08-30 [?] CRAN (R 4.2.3)
#>  P bundle                   0.1.1   2023-09-09 [?] CRAN (R 4.2.3)
#>  P butcher                  0.3.3   2023-08-23 [?] CRAN (R 4.2.3)
#>  P cli                      3.6.0   2023-01-09 [?] CRAN (R 4.2.3)
#>  P crayon                   1.5.2   2022-09-29 [?] CRAN (R 4.2.3)
#>  P curl                     5.0.0   2023-01-12 [?] CRAN (R 4.2.3)
#>  P digest                   0.6.31  2022-12-11 [?] CRAN (R 4.2.3)
#>  P ellipsis                 0.3.2   2021-04-29 [?] CRAN (R 4.2.3)
#>  P evaluate                 0.20    2023-01-17 [?] CRAN (R 4.2.3)
#>  P fansi                    1.0.4   2023-01-22 [?] CRAN (R 4.2.3)
#>  P fastmap                  1.1.1   2023-02-24 [?] CRAN (R 4.2.3)
#>  P fs                       1.6.1   2023-02-06 [?] CRAN (R 4.2.3)
#>  P generics                 0.1.3   2022-07-05 [?] CRAN (R 4.2.3)
#>  P glue                     1.6.2   2022-02-24 [?] CRAN (R 4.2.3)
#>  P hms                      1.1.3   2023-03-21 [?] CRAN (R 4.2.3)
#>  P htmltools                0.5.4   2022-12-07 [?] CRAN (R 4.2.3)
#>  P httr                     1.4.5   2023-02-24 [?] CRAN (R 4.2.3)
#>  P jsonlite                 1.8.4   2022-12-06 [?] CRAN (R 4.2.3)
#>  P knitr                    1.42    2023-01-25 [?] CRAN (R 4.2.3)
#>  P later                    1.3.0   2021-08-18 [?] CRAN (R 4.2.3)
#>  P lifecycle                1.0.3   2022-10-07 [?] CRAN (R 4.2.3)
#>  P magrittr                 2.0.3   2022-03-30 [?] CRAN (R 4.2.3)
#>  P mime                     0.12    2021-09-28 [?] CRAN (R 4.2.0)
#>    paws.common              0.6.2   2023-10-13 [1] CRAN (R 4.2.3)
#>    paws.compute             0.4.0   2023-09-11 [1] CRAN (R 4.2.3)
#>    paws.developer.tools     0.4.0   2023-09-11 [1] CRAN (R 4.2.3)
#>    paws.machine.learning    0.4.0   2023-09-11 [1] CRAN (R 4.2.3)
#>    paws.management          0.4.0   2023-09-11 [1] CRAN (R 4.2.3)
#>    paws.security.identity   0.4.0   2023-09-11 [1] CRAN (R 4.2.3)
#>    paws.storage             0.4.0   2023-09-11 [1] CRAN (R 4.2.3)
#>  P pillar                   1.9.0   2023-03-22 [?] CRAN (R 4.2.3)
#>  P pins                   * 1.2.2   2023-09-09 [?] CRAN (R 4.2.3)
#>  P pkgconfig                2.0.3   2019-09-22 [?] CRAN (R 4.2.3)
#>    plumber                  1.2.1   2022-09-06 [1] CRAN (R 4.2.3)
#>  P promises                 1.2.0.1 2021-02-11 [?] CRAN (R 4.2.3)
#>  P purrr                    1.0.1   2023-01-10 [?] CRAN (R 4.2.3)
#>  P R6                       2.5.1   2021-08-19 [?] CRAN (R 4.2.3)
#>  P rappdirs                 0.3.3   2021-01-31 [?] CRAN (R 4.2.3)
#>  P Rcpp                     1.0.10  2023-01-22 [?] CRAN (R 4.2.3)
#>  P readr                    2.1.4   2023-02-10 [?] CRAN (R 4.2.3)
#>  P reprex                   2.0.2   2022-08-17 [?] CRAN (R 4.2.3)
#>  P rlang                    1.1.0   2023-03-14 [?] CRAN (R 4.2.3)
#>  P rmarkdown                2.20    2023-01-19 [?] CRAN (R 4.2.3)
#>  P rstudioapi               0.14    2022-08-22 [?] CRAN (R 4.2.3)
#>  P sessioninfo              1.2.2   2021-12-06 [?] CRAN (R 4.2.3)
#>    smdocker                 0.1.4   2023-06-07 [1] CRAN (R 4.2.3)
#>  P stringi                  1.7.12  2023-01-11 [?] CRAN (R 4.2.2)
#>    swagger                  3.33.1  2020-10-02 [1] CRAN (R 4.2.3)
#>  P tibble                   3.2.1   2023-03-20 [?] CRAN (R 4.2.3)
#>  P tidyselect               1.2.0   2022-10-10 [?] CRAN (R 4.2.3)
#>  P tzdb                     0.4.0   2023-05-12 [?] CRAN (R 4.2.3)
#>  P utf8                     1.2.3   2023-01-31 [?] CRAN (R 4.2.3)
#>  P uuid                     1.1-0   2022-04-19 [?] CRAN (R 4.2.3)
#>  P vctrs                    0.6.1   2023-03-22 [?] CRAN (R 4.2.3)
#>  P vetiver                * 0.2.4   2023-09-12 [?] CRAN (R 4.2.3)
#>  P vroom                    1.6.4   2023-10-02 [?] CRAN (R 4.2.3)
#>    webutils                 1.1     2020-04-28 [1] CRAN (R 4.2.3)
#>  P withr                    2.5.0   2022-03-03 [?] CRAN (R 4.2.3)
#>  P xfun                     0.39    2023-04-20 [?] CRAN (R 4.2.3)
#>  P xml2                     1.3.4   2023-04-27 [?] CRAN (R 4.2.3)
#>  P yaml                     2.3.7   2023-01-23 [?] CRAN (R 4.2.3)
#>  P zip                      2.3.0   2023-04-17 [?] CRAN (R 4.2.3)
#> 
#>  [1] C:/Users/stefa/Documents/local gitclones/mlr4all/renv/library/R-4.2/x86_64-w64-mingw32
#>  [2] C:/Users/stefa/AppData/Local/R/cache/R/renv/sandbox/R-4.2/x86_64-w64-mingw32/19d6eec0
#> 
#>  P ── Loaded and on-disk path mismatch.
#> 
#> ──────────────────────────────────────────────────────────────────────────────

Hi @stefanlinner my gut feeling is that your execution role doesn't have access to your AWS S3 bucket: mlr4all-test-bucket. That is why b is failing to be assigned. A quick and easy fix (I think) would be to give your execution role AWS S3 full access.

When I have a little more time I will list an general "over kill" approach in setup up the execution role. I am a little snowed under as I am planning for my wedding.

Hi @DyfanJones, thanks for your quick response! Congratulations! All the best for your wedding!

Unfortunately, granting full S3 access doesn't fix the problem. I am still getting the same error messages.

My trust policy looks like this

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Principal": {
                "Service": "codebuild.amazonaws.com"
            },
            "Action": "sts:AssumeRole"
        },
        {
            "Effect": "Allow",
            "Principal": {
                "Service": "sagemaker.amazonaws.com"
            },
            "Action": "sts:AssumeRole"
        }
    ]
}

and for permissions I use AmazonS3FullAccess & AmazonSageMakerFullAccess.

I somehow assumed that my execution role was fine, since the two functions that use it as input run without problems (but maybe I was wrong to assume that).

Before I created this problem I was thinking about the repository argument in vetiver_sm_build(). Because I just copy pasted this and when looking in CloudWatch my built image is in /aws/codebuild/sagemaker-studio-image-build-* while the endpoint is in /aws/sagemaker/Endpoints/vetiver-sagemaker-cars-lm-2023-10-30-15-17-20-700. I don't know if those repositories need to align somehow or if it's just a name and it doesn't matter.

I also looked at the kms_key argument of vetiver_sm_endpoint() as it seems to be related to authentication and is an input of my failing function, but I don't really know if that could be related to my problem.

FWIW when I have seen that kind of error ("object 'b' not found") it is because the container doesn't have access to the S3 bucket. The function vetiver_sm_build() does run just fine, like you mentioned, because you have the right permissions to build that container but then the container doesn't have permissions to get to the S3 bucket where the model artifact is stored. When the container is then run, it errors because it can't get the pin.

Hello again,

with the comment in #256, I managed to find the problem. I recognized this part from my error message above:

c("b <- board_s3(bucket = \"taller-barna-ireland\", region = structure(\"eu-west-1\", tags = list(", "b <-     type = \"scalar\")))")

Thus I tried it myself and prepared the dockerfile with vetiver version 0.2.4 (!)

vetiver_prepare_docker(model_board, name)

and indeed the created plumber.R file looks like this:

# Generated by the vetiver package; edit with care

library(pins)
library(plumber)
library(rapidoc)
library(vetiver)
c("b <- board_s3(bucket = \"mlr4all-test-bucket\", region = structure(\"us-east-1\", tags = list(", "b <-     type = \"scalar\")))")
v <- vetiver_pin_read(b, "cars-lm", version = "20231106T074421Z-a4c1c")

#* @plumber
function(pr) {
    pr %>% vetiver_api(v)
}

Then I downgraded the vetiver package to version 0.2.3 and run again vetiver_prepare_docker() as above and got the following plumber.R file:

# Generated by the vetiver package; edit with care

library(pins)
library(plumber)
library(rapidoc)
library(vetiver)
b <- board_s3(bucket = "mlr4all-test-bucket", region = structure("us-east-1", tags = list(type = "scalar")))
v <- vetiver_pin_read(b, "cars-lm", version = "20231106T075123Z-a4c1c")

#* @plumber
function(pr) {
    pr %>% vetiver_api(v)
}

So in version 0.2.3 the expression c("b <- board_s3(bucket = \"mlr4all-test-bucket\", region = structure(\"us-east-1\", tags = list(", "b <- type = \"scalar\")))") is replaced and that solves the problem.

Oh gosh, that would be the problem! I currently can't reproduce that but let me dig a bit deeper:

library(vetiver)
library(pins)
tmp_plumber <- tempfile()
b <- board_temp(versioned = TRUE)
cars_lm <- lm(mpg ~ ., data = mtcars)
v <- vetiver_model(cars_lm, "cars_linear")
vetiver_pin_write(b, v)
#> Creating new version '20231106T165756Z-a34d4'
#> Writing to pin 'cars_linear'
#> 
#> Create a Model Card for your published model
#> • Model Cards provide a framework for transparent, responsible reporting
#> • Use the vetiver `.Rmd` template as a place to start
vetiver_write_plumber(b, "cars_linear", file = tmp_plumber)

cat(readr::read_lines(tmp_plumber), sep = "\n")
#> # Generated by the vetiver package; edit with care
#> 
#> library(pins)
#> library(plumber)
#> library(rapidoc)
#> library(vetiver)
#> b <- board_folder(path = "/var/folders/hv/hzsmmyk9393_m7q3nscx1slc0000gn/T/RtmpyNxmsM/pins-554576dd0706")
#> v <- vetiver_pin_read(b, "cars_linear", version = "20231106T165756Z-a34d4")
#> 
#> #* @plumber
#> function(pr) {
#>     pr %>% vetiver_api(v)
#> }

Created on 2023-11-06 with reprex v2.0.2

@stefanlinner Can you run this code with reprex(session_info = TRUE)?

library(vetiver)
library(pins)
tmp_plumber <- tempfile()
b <- board_temp(versioned = TRUE)
cars_lm <- lm(mpg ~ ., data = mtcars)
v <- vetiver_model(cars_lm, "cars_linear")
vetiver_pin_write(b, v)
#> Creating new version '20231106T171138Z-a34d4'
#> Writing to pin 'cars_linear'
#> 
#> Create a Model Card for your published model
#> • Model Cards provide a framework for transparent, responsible reporting
#> • Use the vetiver `.Rmd` template as a place to start
vetiver_write_plumber(b, "cars_linear", file = tmp_plumber)

cat(readr::read_lines(tmp_plumber), sep = "\n")
#> # Generated by the vetiver package; edit with care
#> 
#> library(pins)
#> library(plumber)
#> library(rapidoc)
#> library(vetiver)
#> b <- board_folder(path = "/var/folders/hv/hzsmmyk9393_m7q3nscx1slc0000gn/T/RtmprtXpz4/pins-59ba732f7ef5")
#> v <- vetiver_pin_read(b, "cars_linear", version = "20231106T171138Z-a34d4")
#> 
#> #* @plumber
#> function(pr) {
#>     pr %>% vetiver_api(v)
#> }

Created on 2023-11-06 with reprex v2.0.2

Session info
sessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value
#>  version  R version 4.3.1 (2023-06-16)
#>  os       macOS Ventura 13.5.2
#>  system   aarch64, darwin20
#>  ui       X11
#>  language (EN)
#>  collate  en_US.UTF-8
#>  ctype    en_US.UTF-8
#>  tz       America/Denver
#>  date     2023-11-06
#>  pandoc   2.17.1.1 @ /usr/local/bin/ (via rmarkdown)
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  package     * version    date (UTC) lib source
#>  archive       1.1.5      2022-05-06 [1] CRAN (R 4.3.0)
#>  bit           4.0.5      2022-11-15 [1] CRAN (R 4.3.0)
#>  bit64         4.0.5      2020-08-30 [1] CRAN (R 4.3.0)
#>  bundle        0.1.1.9000 2023-11-02 [1] local
#>  butcher       0.3.3      2023-08-23 [1] CRAN (R 4.3.0)
#>  cli           3.6.1      2023-03-23 [1] CRAN (R 4.3.0)
#>  crayon        1.5.2      2022-09-29 [1] CRAN (R 4.3.0)
#>  digest        0.6.33     2023-07-07 [1] CRAN (R 4.3.0)
#>  ellipsis      0.3.2      2021-04-29 [1] CRAN (R 4.3.0)
#>  evaluate      0.23       2023-11-01 [1] CRAN (R 4.3.1)
#>  fansi         1.0.5      2023-10-08 [1] CRAN (R 4.3.1)
#>  fastmap       1.1.1      2023-02-24 [1] CRAN (R 4.3.0)
#>  fs            1.6.3      2023-07-20 [1] CRAN (R 4.3.0)
#>  generics      0.1.3      2022-07-05 [1] CRAN (R 4.3.0)
#>  glue          1.6.2      2022-02-24 [1] CRAN (R 4.3.0)
#>  hms           1.1.3      2023-03-21 [1] CRAN (R 4.3.0)
#>  htmltools     0.5.7      2023-11-03 [1] CRAN (R 4.3.1)
#>  jsonlite      1.8.7      2023-06-29 [1] CRAN (R 4.3.0)
#>  knitr         1.45       2023-10-30 [1] CRAN (R 4.3.1)
#>  later         1.3.1      2023-05-02 [1] CRAN (R 4.3.0)
#>  lifecycle     1.0.3      2022-10-07 [1] CRAN (R 4.3.0)
#>  magrittr      2.0.3      2022-03-30 [1] CRAN (R 4.3.0)
#>  pillar        1.9.0      2023-03-22 [1] CRAN (R 4.3.0)
#>  pins        * 1.2.2.9000 2023-10-31 [1] Github (rstudio/pins-r@f6c6f50)
#>  pkgconfig     2.0.3      2019-09-22 [1] CRAN (R 4.3.0)
#>  plumber       1.2.1      2022-09-06 [1] CRAN (R 4.3.0)
#>  promises      1.2.1      2023-08-10 [1] CRAN (R 4.3.0)
#>  purrr         1.0.2      2023-08-10 [1] CRAN (R 4.3.0)
#>  R.cache       0.16.0     2022-07-21 [1] CRAN (R 4.3.0)
#>  R.methodsS3   1.8.2      2022-06-13 [1] CRAN (R 4.3.0)
#>  R.oo          1.25.0     2022-06-12 [1] CRAN (R 4.3.0)
#>  R.utils       2.12.2     2022-11-11 [1] CRAN (R 4.3.0)
#>  R6            2.5.1      2021-08-19 [1] CRAN (R 4.3.0)
#>  rappdirs      0.3.3      2021-01-31 [1] CRAN (R 4.3.0)
#>  Rcpp          1.0.11     2023-07-06 [1] CRAN (R 4.3.0)
#>  readr         2.1.4      2023-02-10 [1] CRAN (R 4.3.0)
#>  reprex        2.0.2      2022-08-17 [1] CRAN (R 4.3.0)
#>  rlang         1.1.1      2023-04-28 [1] CRAN (R 4.3.0)
#>  rmarkdown     2.25       2023-09-18 [1] CRAN (R 4.3.1)
#>  sessioninfo   1.2.2      2021-12-06 [1] CRAN (R 4.3.0)
#>  stringi       1.7.12     2023-01-11 [1] CRAN (R 4.3.0)
#>  styler        1.10.2     2023-08-29 [1] CRAN (R 4.3.0)
#>  swagger       3.33.1     2020-10-02 [1] CRAN (R 4.3.0)
#>  tibble        3.2.1      2023-03-20 [1] CRAN (R 4.3.0)
#>  tidyselect    1.2.0      2022-10-10 [1] CRAN (R 4.3.0)
#>  tzdb          0.4.0      2023-05-12 [1] CRAN (R 4.3.0)
#>  utf8          1.2.4      2023-10-22 [1] CRAN (R 4.3.1)
#>  vctrs         0.6.4      2023-10-12 [1] CRAN (R 4.3.1)
#>  vetiver     * 0.2.4      2023-09-12 [1] CRAN (R 4.3.0)
#>  vroom         1.6.4      2023-10-02 [1] CRAN (R 4.3.1)
#>  webutils      1.1        2020-04-28 [1] CRAN (R 4.3.0)
#>  withr         2.5.2      2023-10-30 [1] CRAN (R 4.3.1)
#>  xfun          0.41       2023-11-01 [1] CRAN (R 4.3.1)
#>  yaml          2.3.7      2023-01-23 [1] CRAN (R 4.3.0)
#> 
#>  [1] /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/library
#> 
#> ──────────────────────────────────────────────────────────────────────────────

This code example also seems to work for me

library(vetiver)
library(pins)

tmp_plumber <- tempfile()

b <- board_temp(versioned = TRUE)

cars_lm <- lm(mpg ~ ., data = mtcars)

v <- vetiver_model(cars_lm, "cars_linear")

vetiver_pin_write(b, v)
#> Creating new version '20231106T190456Z-a4c1c'
#> Writing to pin 'cars_linear'
#> 
#> Create a Model Card for your published model
#> • Model Cards provide a framework for transparent, responsible reporting
#> • Use the vetiver `.Rmd` template as a place to start

vetiver_write_plumber(b, "cars_linear", file = tmp_plumber)

cat(readr::read_lines(tmp_plumber), sep = "\n")
#> # Generated by the vetiver package; edit with care
#> 
#> library(pins)
#> library(plumber)
#> library(rapidoc)
#> library(vetiver)
#> b <- board_folder(path = "C:/Users/stefa/AppData/Local/Temp/RtmpKQhhoy/pins-3f542a586f1f")
#> v <- vetiver_pin_read(b, "cars_linear", version = "20231106T190456Z-a4c1c")
#> 
#> #* @plumber
#> function(pr) {
#>     pr %>% vetiver_api(v)
#> }

Created on 2023-11-06 with reprex v2.0.2

Session info
sessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value
#>  version  R version 4.2.3 (2023-03-15 ucrt)
#>  os       Windows 10 x64 (build 22621)
#>  system   x86_64, mingw32
#>  ui       RTerm
#>  language (EN)
#>  collate  German_Germany.utf8
#>  ctype    German_Germany.utf8
#>  tz       Europe/Berlin
#>  date     2023-11-06
#>  pandoc   3.1.1 @ C:/Program Files/RStudio/resources/app/bin/quarto/bin/tools/ (via rmarkdown)
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  ! package     * version date (UTC) lib source
#>  P bit           4.0.5   2022-11-15 [?] CRAN (R 4.2.3)
#>  P bit64         4.0.5   2020-08-30 [?] CRAN (R 4.2.3)
#>  P bundle        0.1.1   2023-09-09 [?] CRAN (R 4.2.3)
#>  P butcher       0.3.3   2023-08-23 [?] CRAN (R 4.2.3)
#>  P cli           3.6.0   2023-01-09 [?] CRAN (R 4.2.3)
#>  P crayon        1.5.2   2022-09-29 [?] CRAN (R 4.2.3)
#>  P digest        0.6.31  2022-12-11 [?] CRAN (R 4.2.3)
#>  P ellipsis      0.3.2   2021-04-29 [?] CRAN (R 4.2.3)
#>  P evaluate      0.20    2023-01-17 [?] CRAN (R 4.2.3)
#>  P fansi         1.0.4   2023-01-22 [?] CRAN (R 4.2.3)
#>  P fastmap       1.1.1   2023-02-24 [?] CRAN (R 4.2.3)
#>  P fs            1.6.1   2023-02-06 [?] CRAN (R 4.2.3)
#>  P generics      0.1.3   2022-07-05 [?] CRAN (R 4.2.3)
#>  P glue          1.6.2   2022-02-24 [?] CRAN (R 4.2.3)
#>  P hms           1.1.3   2023-03-21 [?] CRAN (R 4.2.3)
#>  P htmltools     0.5.4   2022-12-07 [?] CRAN (R 4.2.3)
#>  P jsonlite      1.8.4   2022-12-06 [?] CRAN (R 4.2.3)
#>  P knitr         1.42    2023-01-25 [?] CRAN (R 4.2.3)
#>  P later         1.3.0   2021-08-18 [?] CRAN (R 4.2.3)
#>  P lifecycle     1.0.3   2022-10-07 [?] CRAN (R 4.2.3)
#>  P magrittr      2.0.3   2022-03-30 [?] CRAN (R 4.2.3)
#>  P pillar        1.9.0   2023-03-22 [?] CRAN (R 4.2.3)
#>  P pins        * 1.2.2   2023-09-09 [?] CRAN (R 4.2.3)
#>  P pkgconfig     2.0.3   2019-09-22 [?] CRAN (R 4.2.3)
#>    plumber       1.2.1   2022-09-06 [1] CRAN (R 4.2.3)
#>  P promises      1.2.0.1 2021-02-11 [?] CRAN (R 4.2.3)
#>  P purrr         1.0.1   2023-01-10 [?] CRAN (R 4.2.3)
#>  P R6            2.5.1   2021-08-19 [?] CRAN (R 4.2.3)
#>  P rappdirs      0.3.3   2021-01-31 [?] CRAN (R 4.2.3)
#>  P Rcpp          1.0.10  2023-01-22 [?] CRAN (R 4.2.3)
#>  P readr         2.1.4   2023-02-10 [?] CRAN (R 4.2.3)
#>  P reprex        2.0.2   2022-08-17 [?] CRAN (R 4.2.3)
#>  P rlang         1.1.0   2023-03-14 [?] CRAN (R 4.2.3)
#>  P rmarkdown     2.20    2023-01-19 [?] CRAN (R 4.2.3)
#>  P rstudioapi    0.14    2022-08-22 [?] CRAN (R 4.2.3)
#>  P sessioninfo   1.2.2   2021-12-06 [?] CRAN (R 4.2.3)
#>  P stringi       1.7.12  2023-01-11 [?] CRAN (R 4.2.2)
#>    swagger       3.33.1  2020-10-02 [1] CRAN (R 4.2.3)
#>  P tibble        3.2.1   2023-03-20 [?] CRAN (R 4.2.3)
#>  P tidyselect    1.2.0   2022-10-10 [?] CRAN (R 4.2.3)
#>  P tzdb          0.4.0   2023-05-12 [?] CRAN (R 4.2.3)
#>  P utf8          1.2.3   2023-01-31 [?] CRAN (R 4.2.3)
#>  P vctrs         0.6.1   2023-03-22 [?] CRAN (R 4.2.3)
#>  P vetiver     * 0.2.4   2023-09-12 [?] CRAN (R 4.2.3)
#>  P vroom         1.6.4   2023-10-02 [?] CRAN (R 4.2.3)
#>    webutils      1.1     2020-04-28 [1] CRAN (R 4.2.3)
#>  P withr         2.5.0   2022-03-03 [?] CRAN (R 4.2.3)
#>  P xfun          0.39    2023-04-20 [?] CRAN (R 4.2.3)
#>  P yaml          2.3.7   2023-01-23 [?] CRAN (R 4.2.3)
#> 
#>  [1] C:/Users/stefa/Documents/local gitclones/mlr4all/renv/library/R-4.2/x86_64-w64-mingw32
#>  [2] C:/Users/stefa/AppData/Local/R/cache/R/renv/sandbox/R-4.2/x86_64-w64-mingw32/09ddda53
#>  [3] C:/Program Files/R/R-4.2.3/library
#> 
#>  P ── Loaded and on-disk path mismatch.
#> 
#> ──────────────────────────────────────────────────────────────────────────────

So there seems to be a difference in parsing, whether you use board_temp() or board_s3():

library(vetiver)
library(pins)

tmp_plumber <- tempfile()

b <- board_s3(
  bucket = "mlr4all-test-bucket",
  region = "us-east-1"
)

cars_lm <- lm(mpg ~ ., data = mtcars)

v <- vetiver_model(cars_lm, "cars_linear")

vetiver_pin_write(b, v)
#> Creating new version '20231106T190836Z-a4c1c'
#> Writing to pin 'cars_linear'
#> 
#> Create a Model Card for your published model
#> • Model Cards provide a framework for transparent, responsible reporting
#> • Use the vetiver `.Rmd` template as a place to start

vetiver_write_plumber(b, "cars_linear", file = tmp_plumber)

cat(readr::read_lines(tmp_plumber), sep = "\n")
#> # Generated by the vetiver package; edit with care
#> 
#> library(pins)
#> library(plumber)
#> library(rapidoc)
#> library(vetiver)
#> c("b <- board_s3(bucket = \"mlr4all-test-bucket\", region = structure(\"us-east-1\", tags = list(", "b <-     type = \"scalar\")))")
#> v <- vetiver_pin_read(b, "cars_linear", version = "20231106T190836Z-a4c1c")
#> 
#> #* @plumber
#> function(pr) {
#>     pr %>% vetiver_api(v)
#> }

Created on 2023-11-06 with reprex v2.0.2

Session info
sessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value
#>  version  R version 4.2.3 (2023-03-15 ucrt)
#>  os       Windows 10 x64 (build 22621)
#>  system   x86_64, mingw32
#>  ui       RTerm
#>  language (EN)
#>  collate  German_Germany.utf8
#>  ctype    German_Germany.utf8
#>  tz       Europe/Berlin
#>  date     2023-11-06
#>  pandoc   3.1.1 @ C:/Program Files/RStudio/resources/app/bin/quarto/bin/tools/ (via rmarkdown)
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  ! package      * version date (UTC) lib source
#>  P base64enc      0.1-3   2015-07-28 [?] CRAN (R 4.2.0)
#>  P bit            4.0.5   2022-11-15 [?] CRAN (R 4.2.3)
#>  P bit64          4.0.5   2020-08-30 [?] CRAN (R 4.2.3)
#>  P bundle         0.1.1   2023-09-09 [?] CRAN (R 4.2.3)
#>  P butcher        0.3.3   2023-08-23 [?] CRAN (R 4.2.3)
#>  P cli            3.6.0   2023-01-09 [?] CRAN (R 4.2.3)
#>  P crayon         1.5.2   2022-09-29 [?] CRAN (R 4.2.3)
#>  P curl           5.0.0   2023-01-12 [?] CRAN (R 4.2.3)
#>  P digest         0.6.31  2022-12-11 [?] CRAN (R 4.2.3)
#>  P ellipsis       0.3.2   2021-04-29 [?] CRAN (R 4.2.3)
#>  P evaluate       0.20    2023-01-17 [?] CRAN (R 4.2.3)
#>  P fansi          1.0.4   2023-01-22 [?] CRAN (R 4.2.3)
#>  P fastmap        1.1.1   2023-02-24 [?] CRAN (R 4.2.3)
#>  P fs             1.6.1   2023-02-06 [?] CRAN (R 4.2.3)
#>  P generics       0.1.3   2022-07-05 [?] CRAN (R 4.2.3)
#>  P glue           1.6.2   2022-02-24 [?] CRAN (R 4.2.3)
#>  P hms            1.1.3   2023-03-21 [?] CRAN (R 4.2.3)
#>  P htmltools      0.5.4   2022-12-07 [?] CRAN (R 4.2.3)
#>  P httr           1.4.5   2023-02-24 [?] CRAN (R 4.2.3)
#>  P jsonlite       1.8.4   2022-12-06 [?] CRAN (R 4.2.3)
#>  P knitr          1.42    2023-01-25 [?] CRAN (R 4.2.3)
#>  P later          1.3.0   2021-08-18 [?] CRAN (R 4.2.3)
#>  P lifecycle      1.0.3   2022-10-07 [?] CRAN (R 4.2.3)
#>  P magrittr       2.0.3   2022-03-30 [?] CRAN (R 4.2.3)
#>  P mime           0.12    2021-09-28 [?] CRAN (R 4.2.0)
#>    paws.common    0.6.2   2023-10-13 [1] CRAN (R 4.2.3)
#>    paws.storage   0.4.0   2023-09-11 [1] CRAN (R 4.2.3)
#>  P pillar         1.9.0   2023-03-22 [?] CRAN (R 4.2.3)
#>  P pins         * 1.2.2   2023-09-09 [?] CRAN (R 4.2.3)
#>  P pkgconfig      2.0.3   2019-09-22 [?] CRAN (R 4.2.3)
#>    plumber        1.2.1   2022-09-06 [1] CRAN (R 4.2.3)
#>  P promises       1.2.0.1 2021-02-11 [?] CRAN (R 4.2.3)
#>  P purrr          1.0.1   2023-01-10 [?] CRAN (R 4.2.3)
#>  P R6             2.5.1   2021-08-19 [?] CRAN (R 4.2.3)
#>  P rappdirs       0.3.3   2021-01-31 [?] CRAN (R 4.2.3)
#>  P Rcpp           1.0.10  2023-01-22 [?] CRAN (R 4.2.3)
#>  P readr          2.1.4   2023-02-10 [?] CRAN (R 4.2.3)
#>  P reprex         2.0.2   2022-08-17 [?] CRAN (R 4.2.3)
#>  P rlang          1.1.0   2023-03-14 [?] CRAN (R 4.2.3)
#>  P rmarkdown      2.20    2023-01-19 [?] CRAN (R 4.2.3)
#>  P rstudioapi     0.14    2022-08-22 [?] CRAN (R 4.2.3)
#>  P sessioninfo    1.2.2   2021-12-06 [?] CRAN (R 4.2.3)
#>  P stringi        1.7.12  2023-01-11 [?] CRAN (R 4.2.2)
#>    swagger        3.33.1  2020-10-02 [1] CRAN (R 4.2.3)
#>  P tibble         3.2.1   2023-03-20 [?] CRAN (R 4.2.3)
#>  P tidyselect     1.2.0   2022-10-10 [?] CRAN (R 4.2.3)
#>  P tzdb           0.4.0   2023-05-12 [?] CRAN (R 4.2.3)
#>  P utf8           1.2.3   2023-01-31 [?] CRAN (R 4.2.3)
#>  P vctrs          0.6.1   2023-03-22 [?] CRAN (R 4.2.3)
#>  P vetiver      * 0.2.4   2023-09-12 [?] CRAN (R 4.2.3)
#>  P vroom          1.6.4   2023-10-02 [?] CRAN (R 4.2.3)
#>    webutils       1.1     2020-04-28 [1] CRAN (R 4.2.3)
#>  P withr          2.5.0   2022-03-03 [?] CRAN (R 4.2.3)
#>  P xfun           0.39    2023-04-20 [?] CRAN (R 4.2.3)
#>  P xml2           1.3.4   2023-04-27 [?] CRAN (R 4.2.3)
#>  P yaml           2.3.7   2023-01-23 [?] CRAN (R 4.2.3)
#> 
#>  [1] C:/Users/stefa/Documents/local gitclones/mlr4all/renv/library/R-4.2/x86_64-w64-mingw32
#>  [2] C:/Users/stefa/AppData/Local/R/cache/R/renv/sandbox/R-4.2/x86_64-w64-mingw32/09ddda53
#>  [3] C:/Program Files/R/R-4.2.3/library
#> 
#>  P ── Loaded and on-disk path mismatch.
#> 
#> ──────────────────────────────────────────────────────────────────────────────

Ah OK, this is because the length of the string specifying the board is so long, longer than the default of width.cutoff = 60L:

library(pins)
board <- pins:::board_s3_test()
board <- deparse(board_deparse(board))
glue::glue('b <- {board}')
#> b <- board_s3(bucket = "pins-test-hadley", region = structure("us-east-2", tags = list(
#> b <-     type = "scalar")))

Created on 2023-11-06 with reprex v2.0.2

I changed to use base deparse() from rlang::expr_deparse() here because of the board_url() problems but clearly the rlang function is better for more use cases.

I believe I have a fix set up in #257 but if you are needing to deploy to SageMaker very immediately, I recommend installing back to vetiver 0.2.3 which is from before this bug was introduced:

pak::pak("vetiver@0.2.3")

Thank you for the quick fix! I'll do that :) Really appreciate your work and the package!

You can now also install the development version of vetiver via pak::pak("rstudio/vetiver-r") to get this fix. Let me know if this does not fix the problem or you run into any further troubles!