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

I can not load the saved model, an example from the help #109

Closed
mytarmail opened this issue May 26, 2023 · 9 comments
Closed

I can not load the saved model, an example from the help #109

mytarmail opened this issue May 26, 2023 · 9 comments

Comments

@mytarmail
Copy link

I am getting an error on the last line of code

library(uwot)
iris_train <- iris[c(1:10, 51:60), ]
iris_test <- iris[100:110, ]
model <- umap(iris_train, ret_model = TRUE, n_epochs = 20)
model_file <- tempfile("iris_umap")
model <- save_uwot(model, file = model_file)
test_embedding <- umap_transform(iris_test, model)
unload_uwot(model)
model2 <- load_uwot(file = model_file)

/usr/bin/tar: Cannot connect to C: resolve failed
Error in load_uwot(file = model_file) : 
  Can't find model in C:\Users\tars\AppData\Local\Temp\RtmpaKVSbs\iris_umap12e43e764309
In addition: Warning message:
In utils::untar(abspath(file), exdir = mod_dir, verbose = verbose) :
  ‘tar.exe -xf "C:\Users\tars\AppData\Local\Temp\RtmpaKVSbs/iris_umap12e43e764309" -C "C:/Users/tars/AppData/Local/Temp/RtmpaKVSbs/dir12e44c065145"’ returned error code 128

the model definitely exists.

sessionInfo()
R version 4.3.0 (2023-04-21 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1

Matrix products: default

time zone: Europe/Kiev
tzcode source: internal

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] RcppAnnoy_0.0.20 uwot_0.1.14      Matrix_1.5-4    
@jlmelville
Copy link
Owner

I'm afraid I don't have access to a Windows 7 machine to test this. On Windows 11, I am unable to reproduce the problem.

Does running:

utils::untar(model_file, list = TRUE)

work? You should get out something like:

[1] "uwot/model" "uwot/nn1" 

@mytarmail
Copy link
Author

Hi! I try it

 utils::untar(model_file, list = TRUE)


[1] "/usr/bin/tar: Cannot connect to C: resolve failed"
attr(,"status")
[1] 128
Warning message:
In system(cmd, intern = TRUE) :
  running command 'tar.exe -tf "C:\Users\tars\AppData\Local\Temp\RtmpiG0lBu\iris_umapef02e9815cc"' had status 128

..

file.exists("C:\\Users\\tars\\AppData\\Local\\Temp\\RtmpiG0lBu\\iris_umapef02e9815cc")
[1] TRUE

@jlmelville
Copy link
Owner

It looks like the colon in the drive letter makes tar think it's a file on another machine. This changed on Windows 10 onwards according to ?utils::tar. Does this work:

utils::untar(model_file, list = TRUE, extras = c("--force-local"))

Unfortunately I can't test this because the tar on Windows 10 and above doesn't support --force-local.

But If that does work for you, then maybe setting a TAR_OPTIONS environment variable with the value --force-local will make load_uwot and save_uwot work on Windows 7.

@mytarmail
Copy link
Author

It worked! Thank you very much for your help and great package

@jlmelville
Copy link
Owner

I can attempt to fix the load_uwot and save_uwot functions by detecting if the user is running Windows 7. @mytarmail could you paste the output from Sys.info()?

@mytarmail
Copy link
Author

Yes, sure

Sys.info()
                     sysname                      release                      version 
                   "Windows"                      "7 x64" "build 7601, Service Pack 1" 
                    nodename                      machine                        login 
                   "TARS-ПК"                     "x86-64"                          ....
                        user               effective_user 
                      "tars"                       "tars" 

@jlmelville
Copy link
Owner

Thank you @mytarmail. I have made a change to the save/load model code that attempts to detect Windows 7 and use the --force-local argument, so hopefully Windows 7 users won't need to use the TAR_OPTIONS environment variables with the next version of uwot.

@mytarmail
Copy link
Author

mytarmail commented May 31, 2023

Thank you @mytarmail. I have made a change to the save/load model code that attempts to detect Windows 7 and use the --force-local argument, so hopefully Windows 7 users won't need to use the TAR_OPTIONS environment variables with the next version of uwot.

No, this is a big thank for you.

@jlmelville
Copy link
Owner

Think this is safe to close now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants