ropensci / ruODK

ruODK: An R Client for the ODK Central API
https://docs.ropensci.org/ruODK/
GNU General Public License v3.0
42 stars 13 forks source link

Issue ingesting submission data via the API functions #141

Closed tezza79 closed 1 year ago

tezza79 commented 2 years ago

Problem

ruODK function(s) used

Unexpected behaviour

Reproducible example

# insert reprex here
library(ruODK)
#> Warning: package 'ruODK' was built under R version 4.1.3

# setting setting variables
# usethis::edit_r_environ('project')

# ruODK Setup
ruODK::ru_setup(
  svc = Sys.getenv("ODKC_SRV"), 
  un = Sys.getenv("ODKC_TEST_UN"), 
  pw = Sys.getenv("ODKC_TEST_PW"),
  verbose = T
)
#> <ruODK settings>
#>   Default ODK Central Project ID: 3 
#>   Default ODK Central Form ID: SDGI_Beta 
#>   Default ODK Central URL: https://antares.getodk.cloud 
#>   Default ODK Central Username: terry_v_brooks@hotmail.com 
#>   Default ODK Central Password: run ruODK::get_default_pw() to show 
#>   Default ODK Central Passphrase: run ruODK::get_default_pp() to show 
#>   Default Time Zone: UTC 
#>   Default ODK Central Version: 1.1 
#>   Default HTTP GET retries: 3 
#>   Verbose messages: TRUE 
#>   Test ODK Central Project ID:  
#>   Test ODK Central Form ID:  
#>   Test ODK Central Form ID (ZIP tests):  
#>   Test ODK Central Form ID (Attachment tests):  
#>   Test ODK Central Form ID (Parsing tests):  
#>   Test ODK Central Form ID (WKT tests):  
#>   Test ODK Central URL:  
#>   Test ODK Central Username: terry_v_brooks@hotmail.com 
#>   Test ODK Central Password: run ruODK::get_test_pw() to show 
#>   Test ODK Central Passphrase: run ruODK::get_test_pp() to show 
#>   Test ODK Central Version: 1.1
ruODK::ru_settings()
#> <ruODK settings>
#>   Default ODK Central Project ID: 3 
#>   Default ODK Central Form ID: SDGI_Beta 
#>   Default ODK Central URL: https://antares.getodk.cloud 
#>   Default ODK Central Username: terry_v_brooks@hotmail.com 
#>   Default ODK Central Password: run ruODK::get_default_pw() to show 
#>   Default ODK Central Passphrase: run ruODK::get_default_pp() to show 
#>   Default Time Zone: UTC 
#>   Default ODK Central Version: 1.1 
#>   Default HTTP GET retries: 3 
#>   Verbose messages: TRUE 
#>   Test ODK Central Project ID:  
#>   Test ODK Central Form ID:  
#>   Test ODK Central Form ID (ZIP tests):  
#>   Test ODK Central Form ID (Attachment tests):  
#>   Test ODK Central Form ID (Parsing tests):  
#>   Test ODK Central Form ID (WKT tests):  
#>   Test ODK Central URL:  
#>   Test ODK Central Username: terry_v_brooks@hotmail.com 
#>   Test ODK Central Password: run ruODK::get_test_pw() to show 
#>   Test ODK Central Passphrase: run ruODK::get_test_pp() to show 
#>   Test ODK Central Version: 1.1

# get submission data
odata_subm <- ruODK::odata_submission_get(verbose = TRUE)
#> i Downloading submissions...
#> <U+2714> Downloaded submissions.
#> i Reading form schema...
#> i Form schema v1.1
#> Error in `vec_as_location()`:
#> ! `...` must be empty.
#> x Problematic argument:
#> * call = call

Created on 2022-09-08 by the reprex package (v2.0.0)

ODK Central version:

# utils::sessionInfo()
R version 4.1.0 (2021-05-18)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19043)

Matrix products: default

locale:
[1] LC_COLLATE=English_United Kingdom.1252 
[2] LC_CTYPE=English_United Kingdom.1252   
[3] LC_MONETARY=English_United Kingdom.1252
[4] LC_NUMERIC=C                           
[5] LC_TIME=English_United Kingdom.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] reprex_2.0.0

loaded via a namespace (and not attached):
 [1] pillar_1.8.1      compiler_4.1.0    highr_0.9         R.methodsS3_1.8.1
 [5] R.utils_2.10.1    tools_4.1.0       digest_0.6.29     evaluate_0.14    
 [9] lifecycle_1.0.1   tibble_3.1.8      R.cache_0.15.0    pkgconfig_2.0.3  
[13] rlang_1.0.4       DBI_1.1.1         cli_3.0.1         rstudioapi_0.13  
[17] yaml_2.3.5        xfun_0.32         fastmap_1.1.0     withr_2.5.0      
[21] dplyr_1.0.7       httr_1.4.2        styler_1.6.1      knitr_1.33       
[25] generics_0.1.3    fs_1.5.0          vctrs_0.3.8       tidyselect_1.1.2 
[29] glue_1.4.2        R6_2.5.1          processx_3.5.2    fansi_0.5.0      
[33] ruODK_1.3.11      rmarkdown_2.16    clipr_0.7.1       callr_3.7.0      
[37] purrr_0.3.4       magrittr_2.0.1    ps_1.6.0          backports_1.2.1  
[41] htmltools_0.5.3   usethis_2.0.1     assertthat_0.2.1  utf8_1.2.1       
[45] R.oo_1.24.0      

lognaturel commented 2 years ago

It looks like there's something about the form definition that is unexpected in some way.

Would it be possible for you to build a simplified form that results in the same issue? Or even easier for you, I see you're on a getodk.cloud server so perhaps you'd be ok with someone from ODK support looking at your form definition? CC @yanokwa

> Error in vec_as_location():

> ! ... must be empty.

I don't have much ruODK knowledge but this suggests to me that there's an issue related to a geopoint field.

florianm commented 1 year ago

@tezza79 have you had any success with this issue?

A way to debug this is to break up the all-in-one magic of odata_submission_get into individual steps as per https://docs.ropensci.org/ruODK/articles/odata-api.html#detour-data-rectangling:

odata_subm_raw <- ruODK::odata_submission_get(verbose = TRUE, parse=FALSE)
odata_subm_rect <- odata_subm_raw %>% ruODK::odata_submission_rectangle()
odata_subm_gpnt <- odata_subm_rect %>% ruODK::handle_ru_geopoints()

If this turns out to be a data or form design issue rather than a but in ruODK, would you mind letting me know here so I can close this issue?

tezza79 commented 1 year ago

Hi Florian,

Thanks for the below information. This worked and is looking great. I am not sure what was going wrong before. I think maybe some collision in dependent package version on my side.

The issue can be closed.

Many thanks,

Terry.