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

Error: package or namespace load failed for ‘pins’ on huggingface #822

Closed
F041 opened this issue Mar 5, 2024 · 5 comments
Closed

Error: package or namespace load failed for ‘pins’ on huggingface #822

F041 opened this issue Mar 5, 2024 · 5 comments

Comments

@F041
Copy link

F041 commented Mar 5, 2024

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 #705 didn't help

@juliasilge juliasilge transferred this issue from rstudio/vetiver-r Mar 5, 2024
@juliasilge
Copy link
Member

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().

@juliasilge
Copy link
Member

Let us know if you have further questions! 🙌

@F041
Copy link
Author

F041 commented May 3, 2024

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")

@juliasilge
Copy link
Member

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.

Copy link

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.

@github-actions github-actions bot locked and limited conversation to collaborators May 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants