Closed bschilder closed 3 years ago
Confirmed this; these files are indeed deleted after restarting R session. Really good to know.
In that case, i think we should change the default dir to "./" and automatically create a new folder "formatted" where the results will go. That way, when processing multiple files, even if R crashes for whatever reason (or the user exits without knowing to copy all their formatted files elsewhere first), the time they spent processing won't be wasted.
check_save_path()
always makes sure the directory users specify insave_path
exists, and creates it if not.
Also added some path QC at the beginning of check_save_path()
:
...
#### Do a bit of QC to get the full path ####
## Expand "~" into full path bc it isn't recognized in certain envs (eg Python)
save_path <- path.expand(save_path)
## Expand relative path "./" into absolute path bc it's less ambiguous
save_path <- gsub("^[.]/",paste0(getwd(),"/"),save_path)
...
@bschilder we can't change the default dir to "./", it's a bioconductor requirement that it defaults to a temp directory. As long as you have it as an input, the user can update from the temp to wherever they like
Yikes! that's a weird one. ok, in that case let's provide ample warnings to user in both the README and the functions. I'd hate for anyone to run MungeSumstats for hours only to realise nothing was saved
Now added here:
check_save_path <- function(save_path,
write_vcf=FALSE){
#### Add warning to users tha temp files arent actually saved ####
if(dirname(save_path)==tempdir()){
message("WARNING: Formatted results will be saved to `tempdir()`.",
"This means all results will be deleted upon ending the R session.",
"To keep results, change `save_path` (e.g. `save_path='./formatted/'`)",
" or make sure to copy files elsewhere after processing.")
}
...
...
Not sure what's up here, thought temp files stuck around for a while (at least a couple days). I ran
import_sumstats
, which ran all the way through and supposedly wrote several files (according to the messages), restarted my R session and now they supposedly don't exist.Are
tempdir()
andtempfile()
doing something different what I thought they were doing?