ctmm-initiative / ctmmweb

Web app for analyzing animal tracking data, built upon ctmm R package
http://biology.umd.edu/movement.html
GNU General Public License v3.0
34 stars 22 forks source link

as.telemetry import warning messages #63

Closed NoonanM closed 6 years ago

NoonanM commented 6 years ago

A user ran the model fitting on some of there data and got the following error message:

[2018-03-27 18:40:27] Trying different models...  
running parallel in SOCKET cluster of 1 
Parallel Error, try restart R session
Timing stopped at: 0.03 0 1.93
Warning: Error in cat: argument 1 (type 'list') cannot be handled by 'cat'
Stack trace (innermost first):
    80: cat
    79: value[[3L]]
    78: tryCatchOne
    77: tryCatchList
    76: tryCatch
    75: par_lapply
    74: _f
    73: withVisible
    72: par_try_tele_guess_mem
    71: system.time
    70: print
    69: eval
    68: eval
    67: withProgress
    66: observeEventHandler [C:/Users/Patricia/Documents/R/win-library/3.4/ctmmweb/app/server.R#1718]
     2: shiny::runApp
     1: app
ERROR: [on_request_read] connection reset by peer

I looked into it, and the issue was with their data. They had duplicate time stamps in their data. When you use as.telemetry() in the command line, it returns warning messages when this occurs so users can diagnose the problem. In the app, the warning messages are suppressed and there is no way for the user to see any potential issues with their data prior to the model fitting step.

Related to this, it might be useful to have a feature that allows users to clean out duplicate timestamps along with the outlier filtering step.

xhdong-umd commented 6 years ago

With socket cluster in windows, the error message in the parallel workers are in different R process and you cannot see them. In contrast the linux/mac mode it's still possible to collect the error message.

The simplest method to deal with error in parallel is to run the same operation with parallel disabled again. That should show the proper error message for this case, and rule out all the subtle, system dependent errors in parallel mode.

As for data cleaning, the real difficulties are all the possibilities. As long as the problem is well defined we can deal with it, just we may need to define many cases.

xhdong-umd commented 6 years ago

Wait, I think the error message in as.telemetry should not be suppressed as that happened in the import step. Did they see the message in console when importing?

If they are using the web app where is no console, I built a button to show the error message specifically for this purpose, first check Capture Error Message before the operation, then click the Error Message button after error occurred.

NoonanM commented 6 years ago

Yes, the user disabled parallel, and was still getting errors.

I called as.telemetry on their data in RStudio and got the following warning messages:

Warning messages:
1: In telemetry.clean(telist[[i]], id = id[i]) :
  Times might be out of order or duplicated in CE_04_TITI. Make sure that timeformat and timezone are correctly specified.
2: In telemetry.clean(telist[[i]], id = id[i]) :
  Duplicate times in CE_04_TITI. Data cannot be fit without an error model.
3: In telemetry.clean(telist[[i]], id = id[i]) :
  Duplicate times in CE_19_SILVIO. Data cannot be fit without an error model.
4: In telemetry.clean(telist[[i]], id = id[i]) :
  Duplicate times in CE_31_ANNA. Data cannot be fit without an error model.

So from the ctmm() warning messages it was clear why those models were failing, but I couldn't diagnose the problem in the app.

NoonanM commented 6 years ago

No warning messages were displayed when the data were loaded in.

xhdong-umd commented 6 years ago

Did they use hosted app or local app? There is a menu in right top corner to tell the installation date, what was the date?

NoonanM commented 6 years ago

Ok, the warnings are stored upon loading. You can see them if you click on the Error Messages button, but it's not obvious that that was needed.

NoonanM commented 6 years ago

Is there any way to make the warning messages from as.telemetry() pop up automatically after loading in the data?

xhdong-umd commented 6 years ago

For hosted web app, there is no R console. I have to make quite some effort to capture the console messages.

It's possible to write one time code to pop up message for message in one place, but any other places have similar need will need another treatment. The best option is to keep an area to show console message live, just like R console. Unfortunately that was quite difficult. Several people attempted but failed to get a good solution.

I'll check this after I finished my current task.

NoonanM commented 6 years ago

Ok, sounds good. At the very least, the import warning messages should be kept because they're designed to help users with common data quality issues.

chfleming commented 6 years ago

Just to note, the duplicate times is a message and not an error, because duplicate times can work fine with an error model (if they obey the error model). Its okay for users to have the option of discarding duplicate times. However, there is no one best way to discard duplicate times, because it depends on their characteristics/cause.

For duplicate times that are outliers (bugs), users should be able to fix this during the outlier detection step. An automated option to drop the duplicate times with the highest associated speed could also work.

For duplicate times that are informative (i.e., approximately represent ordinary telemetry error), the duplicate times' associated locations & HDOPs can be consolidated.

I will write a function and/or as.telemetry() option to handle the duplicate times with options to (1) do nothing, (2) drop higher speed duplicates, (3) consolidate duplicates.

xhdong-umd commented 6 years ago

It's quite challenging to manipulate with error output, file connection, error handling. And the app have two modes for error messages

I used to make this an option, now I think the hosted mode need to use capture mode anyway, and the console when available is always better (there are more context), so I'll fix the mode depend on app running mode.

For now, if there is warning in as.telemetry import

screen shot 2018-04-03 at 10 26 22 am

There will be more context in console so I think this is better than the captured window.

screen shot 2018-04-03 at 10 27 17 am

All other warning messages are also in console in this mode.

screen shot 2018-04-03 at 9 46 56 am

For warnings/errors other than the as.telemetry import, the message will be available by clicking a button in side bar (when app is running in hosted mode).

screen shot 2018-04-03 at 9 51 53 am

The messages also included app installation date and session info.

screen shot 2018-04-02 at 4 17 27 pm
xhdong-umd commented 6 years ago

I updated the hosted web app and tested, the warnings are working as expected

xhdong-umd commented 6 years ago

I made the error message to console/app as an option and leave the default to be message to app. I also took a lot of effort to maintain and clean up the connections and sink properly.

The error message will be saved to save progress zip if errors are captured in app.