Auerbach-Lab/Behavior-autoanalysis

Backup should be a try_catch

Closed this issue · 0 comments

Issue

Even if the data backup throws an error, the script proceeds to delete the entry.

Expected Behavior

If an error is thrown during the backup step, the scripts should stop immediately with a warning. Ideally, prior to exiting the script prints out the key_data allowing for manual recording of the entry.

Locations of code that need fixing

check and backup.R - should probably just source remove entry with the options set so the code isn't duplicated
remove entry.R

Suggested Fix

On line 53 of check and backup.R should be a tryCatch()

Reproduce

Run check and backup.R on the saved files. It should cause the error on the TTS.

Example Log

 Checking TTS... Issue with archive: off by 561

A tibble: 0 x 8

i 8 variables: UUID , rows , trials , Issue , date , rat_name , rat_ID , file_name

      No extra data for TTS
      Missing trials for runs in TTS

Proceed with cleaning bad runs from run_archive?

                             Note: Data WILL be saved and attempted to reload 

1: Yes
2: No

Selection: 1
Cleaning Green21's entry on 20231011 ...
Data backed up
Trials removed from TTS_archive
Run archive cleaned
Done.
Warning in fread(paste0(projects_folder, "deleted_entries.csv")) :
Stopped early on line 2. Expected 18 fields but found 15. Consider fill=TRUE and comment.char=. First discarded non-empty line: <<20230817,195,LP3,466,,32kHz_70dB_BBN_60dB_8s_4-6,Oddball,Tone-BBN,Reset,4-6,"2x reset: 4, 16, 32, 16, 8>>
All deleted entries have already been re-loaded into the system

Backing up runs...