USAID-OHA-SI / grabr

OHA/SI APIs package
https://usaid-oha-si.github.io/grabr/
Other
1 stars 2 forks source link

run error with datim_orgunits #37

Closed achafetz closed 10 months ago

achafetz commented 1 year ago
datim_orgunits("Tanzania")

image

baboyma commented 11 months ago

Hi AC,

Can you take another look at this? Looks like countries with undocumented levels in the org_levels, don't get child-parent mapping right.

Here is an example:

grabr::datim_orgunits("Tanzania", glamr::datim_user(), glamr::datim_pwd())
grabr::datim_orgunits("Tanzania", glamr::datim_user(), glamr::datim_pwd(), reshape = T)
achafetz commented 11 months ago

Lucky me that TZA updated their PSNU levels I guess.

First line runs well 👍 grabr::datim_orgunits("Tanzania", glamr::datim_user(), glamr::datim_pwd())

Second line runs into an issue - str_replace() appears to be missing an explicit reference - stringr::str_replace() - somwhere within the function image

I think it is coming from here https://github.com/USAID-OHA-SI/grabr/blob/be34c97e33b1222a891c6dc32d39dbb9f82e9a59/R/extract_datim.R#L1235

achafetz commented 11 months ago

Tests

#test 1 - bad creds
datim_orgunits("Malawi", user = "blah", password = "blah")

#test 2 - default 
datim_orgunits("Malawi") %>% dplyr::glimpse()

#test 3 - reshape = T
datim_orgunits("Malawi", reshape = TRUE) %>% dplyr::glimpse()

Test 1

With bad credentials, we get the correct error message, but it doesn't appear we have a clean exit. We have code here looking like the code continued to try to run after the bad creds and then ran into an error (because there wasn't a dataframe)

image

Test 2

With the default setting, we get a print out about "New names" that we should ideally supress.

image

Test 3

Testing with the update and still getting an getting a new error: "Unknown or uninitialised column: orgunit_level"

image

baboyma commented 10 months ago

Pushed some new updates - fixes level issue and reshaping. Give it another try when you can

achafetz commented 10 months ago

Tests

#test 1 - bad creds
datim_orgunits("Malawi", user = "blah", password = "blah")

#test 2 - default 
datim_orgunits("Malawi") %>% dplyr::glimpse()

#test 3 - reshape = T
datim_orgunits("Malawi", reshape = TRUE) %>% dplyr::glimpse()

Test 1

✅ provided bad creds and got back an "unauthorized" error message image

Test 2

🟡 run works, but we get a print out about "New names" that we should ideally supress. image

Test3

❌ error within subfuction clean_orgunits() that there are unused arguments (username, password, baseurl) 🟡 print out "New names" should ideally supress. image

baboyma commented 10 months ago

Fixed - Dropped some params and forgot to update downstream functions.

Note: the warnings new names are upstreams. Comming from as_tibble() with name_repairs. Will track those down over time.

Thanks for these tests