From 8317435cbc1349c04878cb0147f20cc6ccbf9373 Mon Sep 17 00:00:00 2001 From: deanmarchiori Date: Wed, 17 Apr 2024 08:11:29 +1000 Subject: [PATCH 1/3] removing specific paths and references to EHA --- R/create_translation_log.R | 2 +- R/download_googledrive_files.R | 7 ++++--- R/get_odk_form_schema.R | 2 +- R/get_odk_responses.R | 2 +- R/read_googlesheets.R | 2 +- man/create_translation_log.Rd | 2 +- man/download_dropbox.Rd | 4 ++-- man/download_googledrive_files.Rd | 7 ++++--- 8 files changed, 15 insertions(+), 13 deletions(-) diff --git a/R/create_translation_log.R b/R/create_translation_log.R index 835e93d..eb41eee 100644 --- a/R/create_translation_log.R +++ b/R/create_translation_log.R @@ -16,7 +16,7 @@ #' \dontrun{ #' create_translation_log(response_data = semi_clean_data, #' form_schema = odk_schema_data, -#' url = "https://odk.eha.io/#/projects/5/forms/RVF2_animal_owner/submissions")) +#' url = "https://odk.xyz.io/#/projects/project-name/submissions")) #' } #' create_translation_log <- diff --git a/R/download_googledrive_files.R b/R/download_googledrive_files.R index a1eda7f..11415fe 100644 --- a/R/download_googledrive_files.R +++ b/R/download_googledrive_files.R @@ -18,14 +18,15 @@ #' @examples #' \dontrun{ #' download_googledrive_files( -#' drive_path = "https://drive.google.com/drive/u/0/folders/144cVfY4l087qeBz0Kkd31KAb5os9tw28", +#' key_path = here::here("./key.json"), +#' drive_path = "https://drive.google.com/drive/u/0/folders/asdjfnasiffas8ef7y7y89rf", #' search_pattern = "*.xlsx", -#' out_path = here::here("data/kzn_animal_ship/") +#' out_path = here::here("data/project_data/") #' ) #' } #' download_googledrive_files <- - function(key_path = here::here("./auth/rvf2-workflow-automation-2877f538ddb9.json"), + function(key_path, drive_path, search_pattern, MIME_type = NULL, diff --git a/R/get_odk_form_schema.R b/R/get_odk_form_schema.R index 96f4cd6..627a700 100644 --- a/R/get_odk_form_schema.R +++ b/R/get_odk_form_schema.R @@ -18,7 +18,7 @@ #' @seealso [ruODK::form_schema_ext()] #' @examples #' \dontrun{ -#' get_odk_form_schema(url ="https://odk.eha.io/v1/projects/5/forms/RVF2_animal_owner.svc", +#' get_odk_form_schema(url ="https://odk.xyz.io/v1/projects/5/forms/survey.svc", #' un = Sys.getenv("ODK_USERNAME"), #' pw = Sys.getenv("ODK_PASSWORD"), #' odkc_version = Sys.getenv("ODKC_VERSION")) diff --git a/R/get_odk_responses.R b/R/get_odk_responses.R index 348ea5c..0167c70 100644 --- a/R/get_odk_responses.R +++ b/R/get_odk_responses.R @@ -19,7 +19,7 @@ #' @seealso [ruODK::form_schema_ext()] #' @examples #' \dontrun{ -#' get_odk_responses(url ="https://odk.eha.io/v1/projects/5/forms/RVF2_animal_owner.svc", +#' get_odk_responses(url ="https://odk.xyz.io/v1/projects/5/forms/survey.svc", #' un = Sys.getenv("ODK_USERNAME"), #' pw = Sys.getenv("ODK_PASSWORD"), #' odkc_version = Sys.getenv("ODKC_VERSION")) diff --git a/R/read_googlesheets.R b/R/read_googlesheets.R index f650c0d..354e067 100644 --- a/R/read_googlesheets.R +++ b/R/read_googlesheets.R @@ -16,7 +16,7 @@ #' } #' read_googlesheets <- - function(key_path = here::here("./auth/rvf2-workflow-automation-2877f538ddb9.json"), + function(key_path, sheet = "all", ss, ...) { diff --git a/man/create_translation_log.Rd b/man/create_translation_log.Rd index 040a985..e1ffd6c 100644 --- a/man/create_translation_log.Rd +++ b/man/create_translation_log.Rd @@ -25,7 +25,7 @@ for possible translation. \dontrun{ create_translation_log(response_data = semi_clean_data, form_schema = odk_schema_data, - url = "https://odk.eha.io/#/projects/5/forms/RVF2_animal_owner/submissions")) + url = "https://odk.xyz.io/#/projects/project-name/submissions")) } } diff --git a/man/download_dropbox.Rd b/man/download_dropbox.Rd index 3c34452..a5346bc 100644 --- a/man/download_dropbox.Rd +++ b/man/download_dropbox.Rd @@ -23,8 +23,8 @@ Downloads files from dropbox into a given directory } \examples{ \dontrun{ - download_dropbox(dropbox_path = "DTRA_RVF2/RVF Mosquito Datasets", - dropbox_filename = "Mosquito dataset as at 01-02-2024.xlsx", + download_dropbox(dropbox_path = "XYZ/Project-Datasets", + dropbox_filename = "Project dataset as at 01-02-2024.xlsx", download_path = here::here("data"), overwrite = TRUE) } diff --git a/man/download_googledrive_files.Rd b/man/download_googledrive_files.Rd index 3a2558a..e9b4bb4 100644 --- a/man/download_googledrive_files.Rd +++ b/man/download_googledrive_files.Rd @@ -5,7 +5,7 @@ \title{Download Google Drive Files} \usage{ download_googledrive_files( - key_path = here::here("./auth/rvf2-workflow-automation-2877f538ddb9.json"), + key_path, drive_path, search_pattern, MIME_type = NULL, @@ -37,9 +37,10 @@ and is not deterministic when recursively searching. Please pay attention to wha \examples{ \dontrun{ download_googledrive_files( - drive_path = "https://drive.google.com/drive/u/0/folders/144cVfY4l087qeBz0Kkd31KAb5os9tw28", + key_path = here::here("./key.json"), + drive_path = "https://drive.google.com/drive/u/0/folders/asdjfnasiffas8ef7y7y89rf", search_pattern = "*.xlsx", - out_path = here::here("data/kzn_animal_ship/") + out_path = here::here("data/project_data/") ) } From 4c7b0ed08e6f3e67e756edaf179f55fdcc9cca86 Mon Sep 17 00:00:00 2001 From: deanmarchiori Date: Wed, 17 Apr 2024 08:12:15 +1000 Subject: [PATCH 2/3] removing dropbox refresh function. this can be done within the users targets workflow --- R/download_dropbox.R | 6 ++---- R/dropbox_refresh.R | 23 ----------------------- R/dropbox_upload.R | 7 ++----- R/get_dropbox_val_logs.R | 5 ++--- man/refresh_db_token.Rd | 22 ---------------------- 5 files changed, 6 insertions(+), 57 deletions(-) delete mode 100644 R/dropbox_refresh.R delete mode 100644 man/refresh_db_token.Rd diff --git a/R/download_dropbox.R b/R/download_dropbox.R index 5e51cf3..1706e92 100644 --- a/R/download_dropbox.R +++ b/R/download_dropbox.R @@ -12,8 +12,8 @@ #' @seealso [rdrop2::drop_download()] #' @examples #' \dontrun{ -#' download_dropbox(dropbox_path = "DTRA_RVF2/RVF Mosquito Datasets", -#' dropbox_filename = "Mosquito dataset as at 01-02-2024.xlsx", +#' download_dropbox(dropbox_path = "XYZ/Project-Datasets", +#' dropbox_filename = "Project dataset as at 01-02-2024.xlsx", #' download_path = here::here("data"), #' overwrite = TRUE) #' } @@ -23,8 +23,6 @@ download_dropbox <- dropbox_filename, download_path, ...) { - # locate and update token - refresh_db_token() # check if exists if (!rdrop2::drop_exists(paste(dropbox_path, dropbox_filename, sep = "/"))) { diff --git a/R/dropbox_refresh.R b/R/dropbox_refresh.R deleted file mode 100644 index 4a5c9ae..0000000 --- a/R/dropbox_refresh.R +++ /dev/null @@ -1,23 +0,0 @@ -#' Dropbox Refresh -#' -#' This is a helper function to trigger the auto-refresh of a dropbox token -#' -#' @details -#' This is not an exported function and is only called in download_dropbox() as -#' a means of refreshing a token. It works by forcing the download of a small sample -#' file from a fixed file path on EcoHealth drop box. -#' -#' @param path to drop box token `.rds` object -#' -#' @return invisible -#' -refresh_db_token <- function(path = "auth/db_token.rds") { - rdrop2::drop_auth(rdstoken = path, cache = FALSE) - # download a small file to get the token to refresh properly. Allows upload functions to work. - rdrop2::drop_download( - "/dtra_rvf2/data/rvf2_github_data/tinyfile.txt", - local_path = here::here("auth"), - overwrite = TRUE - ) - file.remove(here::here("auth/tinyfile.txt")) -} diff --git a/R/dropbox_upload.R b/R/dropbox_upload.R index 18e4a07..e4cee4c 100644 --- a/R/dropbox_upload.R +++ b/R/dropbox_upload.R @@ -16,17 +16,14 @@ #' \dontrun{ #' dropbox_upload( #' kzn_animal_ship_semiclean, -#' file_path = here::here("outputs/kzn_animal_ship_semiclean.csv"), -#' dropbox_path = "DTRA_RVF2/Data/rvf2_github_data/semi_clean_data" +#' file_path = here::here("outputs/data.csv"), +#' dropbox_path = "XYZ/Data/semi_clean_data" #' ) #' } #' dropbox_upload <- function(log, file_path, dropbox_path) { log_export <- readr::write_csv(log, file_path) - # upload token - refresh_db_token() - # upload rdrop2::drop_upload(file_path, dropbox_path) diff --git a/R/get_dropbox_val_logs.R b/R/get_dropbox_val_logs.R index baeda82..61909b6 100644 --- a/R/get_dropbox_val_logs.R +++ b/R/get_dropbox_val_logs.R @@ -14,12 +14,11 @@ #' @export #' @examples #' \dontrun{ -#' get_dropbox_val_logs(file_name = "log_levellogger.csv", folder = NULL) +#' get_dropbox_val_logs(file_name = "log.csv", folder = NULL) #' } #' get_dropbox_val_logs <- - function(file_name, folder, path_name = "DTRA_RVF2/Data/rvf2_github_data/validation_logs") { - refresh_db_token() + function(file_name, folder, path_name) { # path handling when log isnt in a dedicated subfolder on drop box if (is.null(folder)) { diff --git a/man/refresh_db_token.Rd b/man/refresh_db_token.Rd deleted file mode 100644 index e2e6775..0000000 --- a/man/refresh_db_token.Rd +++ /dev/null @@ -1,22 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/dropbox_refresh.R -\name{refresh_db_token} -\alias{refresh_db_token} -\title{Dropbox Refresh} -\usage{ -refresh_db_token(path = "auth/db_token.rds") -} -\arguments{ -\item{path}{to drop box token `.rds` object} -} -\value{ -invisible -} -\description{ -This is a helper function to trigger the auto-refresh of a dropbox token -} -\details{ -This is not an exported function and is only called in download_dropbox() as -a means of refreshing a token. It works by forcing the download of a small sample -file from a fixed file path on EcoHealth drop box. -} From 760ce51dd40619bd5be84caedda70a88b4efb70f Mon Sep 17 00:00:00 2001 From: deanmarchiori Date: Wed, 17 Apr 2024 08:14:00 +1000 Subject: [PATCH 3/3] updating package documentation --- man/dropbox_upload.Rd | 4 ++-- man/get_dropbox_val_logs.Rd | 8 ++------ man/get_odk_form_schema.Rd | 2 +- man/get_odk_responses.Rd | 2 +- man/read_googlesheets.Rd | 7 +------ 5 files changed, 7 insertions(+), 16 deletions(-) diff --git a/man/dropbox_upload.Rd b/man/dropbox_upload.Rd index 5e83057..3dc94d5 100644 --- a/man/dropbox_upload.Rd +++ b/man/dropbox_upload.Rd @@ -27,8 +27,8 @@ CSV file and then uploads to a DropBox path. \dontrun{ dropbox_upload( kzn_animal_ship_semiclean, - file_path = here::here("outputs/kzn_animal_ship_semiclean.csv"), - dropbox_path = "DTRA_RVF2/Data/rvf2_github_data/semi_clean_data" + file_path = here::here("outputs/data.csv"), + dropbox_path = "XYZ/Data/semi_clean_data" ) } diff --git a/man/get_dropbox_val_logs.Rd b/man/get_dropbox_val_logs.Rd index 41925bc..0edd13a 100644 --- a/man/get_dropbox_val_logs.Rd +++ b/man/get_dropbox_val_logs.Rd @@ -4,11 +4,7 @@ \alias{get_dropbox_val_logs} \title{Get Dropbox Validation Logs} \usage{ -get_dropbox_val_logs( - file_name, - folder, - path_name = "DTRA_RVF2/Data/rvf2_github_data/validation_logs" -) +get_dropbox_val_logs(file_name, folder, path_name) } \arguments{ \item{file_name}{character file name with extension of the validation log} @@ -30,7 +26,7 @@ session. } \examples{ \dontrun{ - get_dropbox_val_logs(file_name = "log_levellogger.csv", folder = NULL) + get_dropbox_val_logs(file_name = "log.csv", folder = NULL) } } diff --git a/man/get_odk_form_schema.Rd b/man/get_odk_form_schema.Rd index 5cec1ea..5af7bb3 100644 --- a/man/get_odk_form_schema.Rd +++ b/man/get_odk_form_schema.Rd @@ -33,7 +33,7 @@ authentication. See \url{https://github.com/ropensci/ruODK} } \examples{ \dontrun{ - get_odk_form_schema(url ="https://odk.eha.io/v1/projects/5/forms/RVF2_animal_owner.svc", + get_odk_form_schema(url ="https://odk.xyz.io/v1/projects/5/forms/survey.svc", un = Sys.getenv("ODK_USERNAME"), pw = Sys.getenv("ODK_PASSWORD"), odkc_version = Sys.getenv("ODKC_VERSION")) diff --git a/man/get_odk_responses.Rd b/man/get_odk_responses.Rd index 37096ed..a554382 100644 --- a/man/get_odk_responses.Rd +++ b/man/get_odk_responses.Rd @@ -34,7 +34,7 @@ authentication. See \url{https://github.com/ropensci/ruODK} } \examples{ \dontrun{ - get_odk_responses(url ="https://odk.eha.io/v1/projects/5/forms/RVF2_animal_owner.svc", + get_odk_responses(url ="https://odk.xyz.io/v1/projects/5/forms/survey.svc", un = Sys.getenv("ODK_USERNAME"), pw = Sys.getenv("ODK_PASSWORD"), odkc_version = Sys.getenv("ODKC_VERSION")) diff --git a/man/read_googlesheets.Rd b/man/read_googlesheets.Rd index c450699..d5e3e63 100644 --- a/man/read_googlesheets.Rd +++ b/man/read_googlesheets.Rd @@ -4,12 +4,7 @@ \alias{read_googlesheets} \title{Read Google Sheets Data} \usage{ -read_googlesheets( - key_path = here::here("./auth/rvf2-workflow-automation-2877f538ddb9.json"), - sheet = "all", - ss, - ... -) +read_googlesheets(key_path, sheet = "all", ss, ...) } \arguments{ \item{key_path}{character path to Google authentication key json file}