Skip to content

Commit

Permalink
Merge pull request #104 from PIP-Technical-Team/gdp-update
Browse files Browse the repository at this point in the history
Fix for Gdp data
  • Loading branch information
randrescastaneda authored Jul 29, 2024
2 parents 88429b2 + 0e926eb commit b620b1d
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 3 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Imports:
glue,
gh,
httr,
pipfun (>= 0.0.1.9001),
pipfun (>= 0.0.2),
lifecycle,
joyn,
dm,
Expand All @@ -57,7 +57,7 @@ Imports:
VignetteBuilder: knitr
Remotes:
github::PIP-Technical-Team/pipload@ongoing,
github::PIP-Technical-Team/pipfun@ongoing
github::PIP-Technical-Team/pipfun@DEV
URL: https://pip-technical-team.github.io/pipaux/
Config/testthat/edition: 3
ByteCompile: true
Expand Down
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# pipaux (development version)

- Save data to GitHub for GDP data.

# pipaux 0.1.2

- Added a dummy `pip_sna()` function to make it compatible with `auto_aux_update()`
Expand Down
11 changes: 11 additions & 0 deletions R/auto_aux_update.R
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,17 @@ return_value <- function(aux, dependencies) {
return(unique(c(val, aux)))
}

#' Function to write dataframe to GitHub
#'
#' @param df A dataframe
#'
#' @return base64 encoded dataframe
#' @export
#'
#' @examples
#' \dontrun {
#' convert_df_to_base64(mtcars)
#' }
convert_df_to_base64 <- function(df) {
df |>
write.table(quote = FALSE,
Expand Down
4 changes: 3 additions & 1 deletion R/pip_gdp_update.R
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,9 @@ pip_gdp_update <- function(maindir = gls$PIP_DATA_DIR,
msrdir = msrdir,
force = force
)

# Push data (gdp) to GitHub as gdp.csv
pipfun::save_to_gh(gdp, measure = measure, branch = branch)
# All aux files that depend on gdp will be loaded from Github
return(invisible(saved))

}
7 changes: 7 additions & 0 deletions tests/testthat/test-auto_aux_update.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,15 @@ dependencies <- list(ppp = "country_list",
missing_data = c("country_list", "pce", "gdp", "pop", "pfw")
)


base64_value_mtcars <- "bXBnLGN5bCxkaXNwLGhwLGRyYXQsd3QscXNlYyx2cyxhbSxnZWFyLGNhcmIKMjEsNiwxNjAsMTEwLDMuOSwyLjYyLDE2LjQ2LDAsMSw0LDQKMjEsNiwxNjAsMTEwLDMuOSwyLjg3NSwxNy4wMiwwLDEsNCw0CjIyLjgsNCwxMDgsOTMsMy44NSwyLjMyLDE4LjYxLDEsMSw0LDEKMjEuNCw2LDI1OCwxMTAsMy4wOCwzLjIxNSwxOS40NCwxLDAsMywxCjE4LjcsOCwzNjAsMTc1LDMuMTUsMy40NCwxNy4wMiwwLDAsMywyCjE4LjEsNiwyMjUsMTA1LDIuNzYsMy40NiwyMC4yMiwxLDAsMywxCjE0LjMsOCwzNjAsMjQ1LDMuMjEsMy41NywxNS44NCwwLDAsMyw0CjI0LjQsNCwxNDYuNyw2MiwzLjY5LDMuMTksMjAsMSwwLDQsMgoyMi44LDQsMTQwLjgsOTUsMy45MiwzLjE1LDIyLjksMSwwLDQsMgoxOS4yLDYsMTY3LjYsMTIzLDMuOTIsMy40NCwxOC4zLDEsMCw0LDQKMTcuOCw2LDE2Ny42LDEyMywzLjkyLDMuNDQsMTguOSwxLDAsNCw0CjE2LjQsOCwyNzUuOCwxODAsMy4wNyw0LjA3LDE3LjQsMCwwLDMsMwoxNy4zLDgsMjc1LjgsMTgwLDMuMDcsMy43MywxNy42LDAsMCwzLDMKMTUuMiw4LDI3NS44LDE4MCwzLjA3LDMuNzgsMTgsMCwwLDMsMwoxMC40LDgsNDcyLDIwNSwyLjkzLDUuMjUsMTcuOTgsMCwwLDMsNAoxMC40LDgsNDYwLDIxNSwzLDUuNDI0LDE3LjgyLDAsMCwzLDQKMTQuNyw4LDQ0MCwyMzAsMy4yMyw1LjM0NSwxNy40MiwwLDAsMyw0CjMyLjQsNCw3OC43LDY2LDQuMDgsMi4yLDE5LjQ3LDEsMSw0LDEKMzAuNCw0LDc1LjcsNTIsNC45MywxLjYxNSwxOC41MiwxLDEsNCwyCjMzLjksNCw3MS4xLDY1LDQuMjIsMS44MzUsMTkuOSwxLDEsNCwxCjIxLjUsNCwxMjAuMSw5NywzLjcsMi40NjUsMjAuMDEsMSwwLDMsMQoxNS41LDgsMzE4LDE1MCwyLjc2LDMuNTIsMTYuODcsMCwwLDMsMgoxNS4yLDgsMzA0LDE1MCwzLjE1LDMuNDM1LDE3LjMsMCwwLDMsMgoxMy4zLDgsMzUwLDI0NSwzLjczLDMuODQsMTUuNDEsMCwwLDMsNAoxOS4yLDgsNDAwLDE3NSwzLjA4LDMuODQ1LDE3LjA1LDAsMCwzLDIKMjcuMyw0LDc5LDY2LDQuMDgsMS45MzUsMTguOSwxLDEsNCwxCjI2LDQsMTIwLjMsOTEsNC40MywyLjE0LDE2LjcsMCwxLDUsMgozMC40LDQsOTUuMSwxMTMsMy43NywxLjUxMywxNi45LDEsMSw1LDIKMTUuOCw4LDM1MSwyNjQsNC4yMiwzLjE3LDE0LjUsMCwxLDUsNAoxOS43LDYsMTQ1LDE3NSwzLjYyLDIuNzcsMTUuNSwwLDEsNSw2CjE1LDgsMzAxLDMzNSwzLjU0LDMuNTcsMTQuNiwwLDEsNSw4CjIxLjQsNCwxMjEsMTA5LDQuMTEsMi43OCwxOC42LDEsMSw0LDI="

test_that("return_value works as expected", {
expect_equal(return_value("pce", dependencies), c("country_list", "wdi", "pce"))
expect_equal(return_value("wdi", dependencies), "wdi")
expect_equal(return_value("gdp", dependencies), c("country_list", "wdi", "maddison", "pfw", "pop", "weo", "gdp"))
})

test_that("convert_df_to_base64 works as expected", {
expect_equal(convert_df_to_base64(mtcars), base64_value_mtcars)
})

0 comments on commit b620b1d

Please sign in to comment.