Auerbach-Lab/Behavior-autoanalysis

Saving Process File manual runs to hard disk

Closed this issue · 0 comments

Issue:
When running process file manually (i.e. not through shiny) saves are only made to the environment, not to disk. This is by design. Saving the run archive isn't hard it should just be saved with save(run_archive, file = paste0(projects_folder, "run_archive.Rdata"), ascii = TRUE, compress = FALSE)
However, the issue arises in saving the trials. They are available in trials_to_write, but don't have the UUID pre-added nor is the necessary file, the appropriate _archive, available. This can theoretically be back-calculated by tailing run_archive as the most recently added row should match the trials, but there is some risk with that.
Current code for saving trials:
fwrite(cbind(trials_to_write, UUID = uuid), file = filename, append = file.exists(filename)) # tack UUID onto trials and add to archive, appending if the file already exists remove(trials_to_write, inherits = TRUE)

Question:
What is the best method for saving runs from manual executions of Process File