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

make via set_progress fails on Windows with long filename #628

Closed
kendonB opened this issue Dec 19, 2018 · 3 comments
Closed

make via set_progress fails on Windows with long filename #628

kendonB opened this issue Dec 19, 2018 · 3 comments

Comments

@kendonB
Copy link
Contributor

kendonB commented Dec 19, 2018

ref: richfitz/storr#94

I'm finding that drake throws an error from within set_progress when making. Reprex on Windows:

library(drake)
fn <- paste0(paste0(rep("a", 150), collapse = ""), ".rds")
saveRDS(iris, fn)
on.exit(file.remove(fn))
plan <- drake_plan(my_iris = readRDS(file_in("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.rds")),
                   strings_in_dots = "literals")
make(plan)
#> Error in file.rename(tmp, filename): expanded 'to' name too long
@kendonB
Copy link
Contributor Author

kendonB commented Dec 19, 2018

A workaround:

library(drake)
fn <- paste0(paste0(rep("a", 150), collapse = ""), ".rds")
saveRDS(iris, fn)
plan <- drake_plan(my_fn = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.rds",
                   my_iris = readRDS(file_in(my_fn)),
                   strings_in_dots = "literals")
make(plan)
#> target my_fn
#> target my_iris
file.remove(fn)

Created on 2018-12-19 by the reprex package (v0.2.1.9000)

@wlandau
Copy link
Member

wlandau commented Dec 19, 2018

You can also turn off key mangling in storr, which will also make drake run faster. The only caveat is that you can no longer use file paths with slashes for file_in(), etc.

library(drake)
fn <- paste0(paste0(rep("a", 150), collapse = ""), ".rds")
saveRDS(iris, fn)
on.exit(file.remove(fn))
plan <- drake_plan(my_iris = readRDS(file_in("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.rds")),
                   strings_in_dots = "literals")

cache <- storr::storr_rds(".drake", mangle_key = FALSE)

make(plan, cache = cache)

Related: #572, richfitz/storr#88, and richfitz/storr#90.

It would be nice to avoid key mangling altogether, but files are tricky. Without encoding, a plan with file_in("not/a/valid/key.txt") would error out. We really do need a reliable bijective transformation for the file names.

@wlandau
Copy link
Member

wlandau commented Dec 19, 2018

As a default option, I believe we will continue to need a bijective function to encode file names, and the solution needs to be general. Otherwise, we will either have bad keys or name collisions. Please chime in if you find an alternative to base 64 encoding that produces shorter file names.

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