pins-r
pins-r copied to clipboard
Error: package or namespace load failed for ‘pins’ on huggingface
I have this useless-toy model on HF: https://huggingface.co/spaces/vesorit/InflazioneItalia on posit cloud, it gives a problem in another stage, something that the wonderful @juliasilge already showed here: https://stackoverflow.com/questions/71397075/why-does-deploying-a-tidymodel-with-vetiver-throw-a-error-when-theres-a-variabl
on HF instead, I get:
> pr <- plumber::plumb('/opt/ml/plumber.R'); pr$run(host = '0.0.0.0', port = 8000)
Error in stopOnLine(lineNum, file[lineNum], e) :
Error on line rstudio/vetiver-r#2: '' - Error: package or namespace load failed for ‘pins’:
.onLoad failed in loadNamespace() for 'pins', details:
call: NULL
error: [ENOENT] Failed to make directory '//.cache/pins': no such file or directory
Calls: <Anonymous> ... tryCatchList -> tryCatchOne -> <Anonymous> -> stopOnLine
Execution halted
Following https://github.com/rstudio/pins-r/issues/705 didn't help
Check out this documentation for managing the cache on read-only systems:
https://pins.rstudio.com/reference/board_cache_path.html#details
You'll need to use an env var to make sure the cache path is somewhere writable, like base::tempdir()
.
Let us know if you have further questions! 🙌
sorry, I took some time to go through it but I have no idea how to implement it for example in this chunk
model_board <- board_folder(path = "pins-r", versioned = TRUE)
model_board |> vetiver_pin_write(v)
model_board |>
vetiver::vetiver_write_plumber("uk-edu-rf")
write_board_manifest(model_board)
board_cache_path(model_board)
vetiver_write_docker(v,plumber_file = "plumber.R",lockfile = "vetiver_renv.lock")
You'll want to set an environment variable to control where the board cache goes. From R, you set an env var with Sys.setenv()
:
Sys.setenv(PINS_CACHE_DIR = base::tempdir())
Sys.getenv("PINS_CACHE_DIR")
#> [1] "/var/folders/hv/hzsmmyk9393_m7q3nscx1slc0000gn/T//RtmpwgcRgF"
Created on 2024-05-03 with reprex v2.1.0
You can set the env var like this:
Sys.setenv(PINS_CACHE_DIR = base::tempdir())
library(pins)
board <- board_folder("~/Downloads/")
board_cache_path(board)
#> /var/folders/hv/hzsmmyk9393_m7q3nscx1slc0000gn/T/Rtmpzxh6pl/pins_board_folder
#> /var/folders/hv/hzsmmyk9393_m7q3nscx1slc0000gn/T/Rtmpzxh6pl/1
#> NA
#> /var/folders/hv/hzsmmyk9393_m7q3nscx1slc0000gn/T/Rtmpzxh6pl/FALSE
#> /var/folders/hv/hzsmmyk9393_m7q3nscx1slc0000gn/T/Rtmpzxh6pl/~/Downloads
Created on 2024-05-03 with reprex v2.1.0
Or you can set it generally using a non-R tool.
This issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex: https://reprex.tidyverse.org) and link to this issue.