Auerbach-Lab/Behavior-autoanalysis

File analyze sometimes doesn't work in shiny

Closed this issue · 3 comments

To produce issue:
From either 1) a fresh start of R studio or 2) forced restart of the current R session the second file uploaded will only advance to the blue 'uploaded' bar and will allow you to press 'Analysis' triggering the DNA spin animation but will hang (i.e. never finish the analysis). It is possible that the back-end actually failed on the upload and that allowing the pressing of analysis is a bug or that the hang occurs during the analysis.

Note on method 2
2 is odd because I have not tried it from the menu in Rstudio. Most of the time, if you close the browser window, the stop icon is in console indicating the process is still running. A short wait will cause an error box to come up indicating that you need to terminate R (specific error message in image below). Current testing suggests this is more likely to occur if you type anything in either the left boxes and then click in the file selection area (opening the file browser window is NOT needed), followed by close UI the browser, the process does not terminate politely. It also appears to happen if you close the shiny interface too fast after running the app.

Work arounds

  • BEST: Hit the refresh button in the top of the shiny browser twice. The app will run as expected EXCEPT for the warning to select the .mat file only showing up after the 2nd entry. However, all entries will properly have the green name comparison bar following file upload (with correct rat name) and analyze will work for all continuous file entries.
  • Hit the refresh button in the top of the shiny browser once. The first file upload will now stop at a blue bar (file uploaded) and not advance to a green bar confirming name check. However, all continuous entries will allow for analysis. Again the warning to select the .mat file only shows up after the 2nd entry. Entries 2+ will properly have the green name comparison bar following file upload (with correct rat name) and analyze will work for all continuous file entries.
    Note that I believe the refresh app button in Rstudio (that replace the run app) and the refresh button in the shiny browser are equivalent, but this is based of the single refresh which I have currently tested.

Differences between the 1st and 2nd file entry
Shiny form resets normally, but:
During the 1st file entry, no fields start with any issues. During the 2nd run, all fields except 'Your name' start blanked, and the 'Analyze' button returns to normal appearance. Typing rat name causes the orange warning text 'Select .mat file:' to appear, which does not happen on entry 1.

image

tofof commented

I am unable to get the shiny app to analyze any file.

All files die on line 1707 of main.R, inside Generate_Weight_Trials_Graph(). This code is unfamiliar to me, and I don't know its purpose or how to debug it. The specific error generated is error in `if_else()`: ! `false` must be a vector, not `NULL`.

This error happens any time the Generate_Weight_Trials_Graph() function is called, including in isolation from the console, e.g. Generate_Weight_Trials_Graph("Purple1", 209).

I am forced to conclude that the code that is live and in use is not the code that is checked in.

tofof commented

Further investigation reveals that the problem is the NULL being used in the 'false' value of the if_else (the error message is perfect, in this case). The true and false arguments must be vectors of the same length and type as one another, and here, true returns a string (from paste0), so false needed to be "" not NULL.

The checked in code could never have worked and I am not sure how it came to be merged into production.