Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handling the case where there are no query results #18

Open
shankari opened this issue Dec 1, 2020 · 8 comments
Open

Handling the case where there are no query results #18

shankari opened this issue Dec 1, 2020 · 8 comments

Comments

@shankari
Copy link
Collaborator

shankari commented Dec 1, 2020

If there are no query results, then many functions break. For the most recent change (#17), these were:

normalise_uuid
summarise_server_calls
tidy_server_calls

A workaround is to add the following short-circuit code to the beginning of each function.

+  if (nrow(.data) == 0) {
+    return(.data);
+  }

The query results can return no values early in the data collection; when there have been no trips yet, for example, or the user has not synced with the server yet.

I am not an R expert, so was curious about how you plan to handle the case in which there are no query results. Instead of adding short-circuit code to each function, is there a way to create a blank data table at the query level?

@asiripanich
Copy link
Owner

My proposal is that if there are no participants, the dashboard should just return an error for now. But if there are no trips, the easiest way, that I can think of right now, to solve this without running into a fatal error is to return a emptied data.table that has all the columns needed by the other functions. This is equivalent to subsetting a data.table with data[0, ].

asiripanich added a commit that referenced this issue Dec 1, 2020
@shankari
Copy link
Collaborator Author

shankari commented Dec 2, 2020

@asiripanich there will be participants because we register during onboarding. But there might not be trips or server calls corresponding to /usercache/get and /usercache/put.

@shankari
Copy link
Collaborator Author

shankari commented Dec 2, 2020

the commit looks good to me

@shankari shankari closed this as completed Dec 2, 2020
@asiripanich
Copy link
Owner

This still needs to be patched.

@asiripanich asiripanich reopened this Dec 24, 2020
@shankari
Copy link
Collaborator Author

shankari commented Jun 8, 2021

I am now getting a new error with the dashboards for the new deployments

Running: mod_load_data_server
About to load trips
Finished query, about to clean trips
Warning: Error in [[<-.data.frame: replacement has 0 rows, data has 13
  [No stack trace available]
Warning in min(data_r$participants$update_ts) :
  no non-missing arguments to min; returning Inf
Warning in min(data_r$participants$update_ts) :
  no non-missing arguments to min; returning Inf
Warning: Error in UseMethod: no applicable method for 'transmute' applied to an object of class "NULL"
  [No stack trace available]
Warning: Error in UseMethod: no applicable method for 'transmute' applied to an object of class "NULL"
  [No stack trace available]
Warning in grSoftVersion() :
  unable to load shared object '/usr/local/lib/R/modules//R_X11.so':
  libXt.so.6: cannot open shared object file: No such file or directory
Warning: Error in FUN: object 'n_days' not found
  [No stack trace available]
Warning: Error in FUN: object 'curr_platform' not found
  [No stack trace available]
Warning: Error in drop_list_columns: is.data.frame(.data) is not TRUE
  80: <Anonymous>
Anonymize trajectories
Warning: Error in anonymize_uuid: is.data.frame(.data) is not TRUE
  69: <Anonymous>
Warning: Error in anonymize_uuid: is.data.frame(.data) is not TRUE
  81: <Anonymous>
disconnecting from the emission collections..

@shankari
Copy link
Collaborator Author

shankari commented Jun 8, 2021

the key seems to be this error in tidy_cleaned_trips

Error in [[<-.data.frame: replacement has 0 rows, data has 13

there are two users with 11 and 2 trips. So we get 13 trips correctly. Not quite sure why they are getting filtered out.

@shankari
Copy link
Collaborator Author

shankari commented Jun 8, 2021

so I loaded a bunch of other trips from two test users and the dashboard works fine now. I think that the problem might occur if there are no trips with labels. I have attached a mongodump that can be used to reproduce the problem and test the fix.
mongodump_13_trips_no_work.tar.gz

@asiripanich
Copy link
Owner

the key seems to be this error in tidy_cleaned_trips

Error in [[<-.data.frame: replacement has 0 rows, data has 13

there are two users with 11 and 2 trips. So we get 13 trips correctly. Not quite sure why they are getting filtered out.

@allenmichael099 is fixing this in #46.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants