diff --git a/DESCRIPTION b/DESCRIPTION index fcd6189..bb6a373 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -62,7 +62,8 @@ Imports: cli, purrr, lifecycle, - httr2 + httr2, + desc RoxygenNote: 7.3.2 Suggests: knitr, diff --git a/NEWS.md b/NEWS.md index 9974084..9b5efb0 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,13 @@ # QCkit v1.2.1 +## 2025-01-09 + * `create_datastore_script` now has a new parameter, lib_type. If "R" is specified it will pull as much info as it can from the DESCRIPTION file of an R package and use that info to fill out the Core Bibliography tab on the reference landing page. + +## 2025-01-06 + * Add ability to set the Origination flag in DataStore via the `create_datastore_script` function. Defaults to TRUE. + +## 2025-01-05 + * Fixed bug in `create_datastore_script` that occurred when the way the DataStore API handled access constraints changed between V7 and V8. Also improved formatting of screen print and make the DataStore reference link clickable. + ## 2025-12-31 * Updated DataStore APIs to hit v8 API instead of now deprecated v7 API endponts diff --git a/R/datastore_interactions.R b/R/datastore_interactions.R index 21b3763..c7b3954 100644 --- a/R/datastore_interactions.R +++ b/R/datastore_interactions.R @@ -1,22 +1,31 @@ #' Turn a GitHub release into a DataStore Script Reference #' -#' @description Given a GitHub owner ("nationalparkservice") and public repo ("EMLeditor"), the function uses the GitHub API to access the latest release version on GitHub and generate a corresponding draft Script reference on DataStore. +#' @description Given a GitHub owner ("nationalparkservice") and public repo ("EMLeditor"), the function uses the GitHub API to access the latest release version on GitHub and generate a corresponding draft public Script reference on DataStore. #' #' WARNING: if you are not an author of the repo on GitHub, you should probably NOT be the one adding it to DataStore unless you have very good reason. If you want to cite a GitHub release/repo and need a DOI, contact the repo maintainer and suggest they use this function to put it on DataStore for you. #' -#' It searches DataStore for references with a similar title (where the title is repo + release tag). If `force = FALSE` and there are similarly titled references, the function will return a list of them and ask if the user really wants a new DataStore reference generated. Assuming yes (or if there are no existing DataStore references with a similar title or `force = TRUE`), the function will: 1) download the .zip of the latest GitHub release for the repo, 2) initiate a draft reference on DataStore, 3) give the draft reference a title (repo + release tag), 4) upload the .zip from GitHub 5) add a web link to the release on GitHub. -#' -#' `create_datastore_script()` will also access the keywords from your GitHub repo ("Topics") and add them to the draft references as keywords. It will automatically set your reference and all the files and links to public, allow data managers to edit the reference, and set the quality to "Operational". Unless you have good reason backed by a policy that specifically includes information from your release, please do not change these settings (and perhaps reconsider using public github repositories). -#' +#' The function searches DataStore for references with a similar title (where the title is repo + release tag). If `force = FALSE` and there are similarly titled references, the function will return a list of them and ask if the user really wants a new DataStore reference generated. Assuming yes (or if there are no existing DataStore references with a similar title or if `force = TRUE`), the function will: +#' 1) download the .zip of the latest GitHub release for the repo, +#' 2) initiate a draft reference on DataStore, +#' 3) give the draft reference a title (repo + release tag), +#' 4) upload the .zip from GitHub +#' 5) add a web link to the release on GitHub. +#' 6) add the items listed under GitHub repo "Topics" as keywords to the DataStore Script reference +#' 7) Set for or by NPS flag +#' 8) Set the issued date +#' 9) If you indicate it is an R package, the authors, steward, description, and other fields will be filled out on the Core tab +#'#' #' The user will still need to go access the draft Script reference on DataStore to fill in the remaining fields (which are not accessible via API and so cannot be automated through this function) and activate the reference (thereby generating and registering a citeable DOI). #' #' If the Reference is a version of an older reference, the user will have to access the older version and indicate that it is an older version of the current Reference. The user will also have to manually add the new Reference to a Project for the repo, if desired. #' #' @param owner String. The owner of the account where the GitHub repo resides. For example, "nationalparkservice" #' @param repo String. The repo with a release that should be turned into a DataStore Script reference. For example, "EMLeditor" +#' @param lib_type String. Can be one of three values: generic_script, R, or python. Defaults to "generic_script". #' @param path String. The location where the release .zip from GitHub should be downloaded to (and uploaded from). Defaults to the working directory of the R Project (i.e. `here::here()`). #' @param force Logical. Defaults to FALSE. In the default status the function has a number of interactive components, such as searching DataStore for similarly titled References and asking if a new Reference is really what the user wants. When set to TRUE, all interactive components are turned off and the function will proceed unless it hits an error. Setting force = TRUE may be useful for scripting purposes. #' @param dev Logical. Defaults to FALSE. In the default status, the function generates and populates a new draft Script reference on the DataStore production server. If set to TRUE, the draft Script reference will be generated and populated on the DataStore development server. Setting dev = TRUE may be useful for testing the function without generating excessive references on the DataStore production server. +#' @param for_or_by_NPS Logical. Was the code, script, or software created either for or by NPS? Defaults to TRUE. #' @param chunk_size_mb The "chunk" size to break the file into for upload. If your network is slow and your uploads are failing, try decreasing this number (e.g. 0.5 or 0.25). #' @param retry How many times to retry uploading a file chunk if it fails on the first try. #' @@ -30,11 +39,19 @@ #' } create_datastore_script <- function(owner, repo, + lib_type = c("generic_script", + "R", + "python"), path = here::here(), force = FALSE, dev = FALSE, + for_or_by_NPS = TRUE, chunk_size_mb = 1, retry = 1) { + + #check "lib_type" for valid values; if no value supplied defaults to "generic_script": + lib_type <- match.arg(lib_type) + gh_url <- paste0("https://api.github.com/repos/", owner, "/", @@ -64,18 +81,18 @@ create_datastore_script <- function(owner, #quick search of DataStore for the string "dynamic title" post_url <- paste0(.QC_ds_secure_api(), "QuickSearch?q=", dynamic_title) - req <- httr::GET(post_url, + req_search <- httr::GET(post_url, httr::authenticate(":", "", "ntlm"), httr::add_headers('accept' = 'application/json')) #check status code; suggest logging in to VPN if errors occur: - status_code <- httr::stop_for_status(req)$status_code + status_code <- httr::stop_for_status(req_search)$status_code if (!status_code == 200) { stop("ERROR: DataStore connection failed. Are you logged in to the VPN?\n") } #get search results and turn into a dataframe: - json <- httr::content(req, "text") + json <- httr::content(req_search, "text") rjson <- jsonlite::fromJSON(json) items <- as.data.frame(rjson$items) @@ -86,17 +103,18 @@ create_datastore_script <- function(owner, if (length(seq_along(matches$title) > 0)) { cat("One or more DataStore references with title containing: ", new_ref_title, - " already exists:", sep = "") + " already exists:\n", sep = "") cat("Reference ID: ", matches$referenceId, "; Title: ", - matches$title, sep = "") + matches$title, + "\n\n", sep = "") cat("Are you sure you want to create a new draft reference for ", new_ref_title, "?", sep = "") var1 <- readline(prompt = cat("\n\n1: Yes\n2: No\n\n")) if (var1 == 2) { cat("You have not generated a new DataStore reference.") - return() + return(invisible(NULL)) } } } @@ -131,9 +149,9 @@ create_datastore_script <- function(owner, httr::write_disk(download_file_path, overwrite = TRUE)))))) if (force == FALSE) { - cat("Writing: ", + cat("Downloading and Writing: ", crayon::blue$bold(download_file_path), - ".\n", sep = "") + ".\n\n", sep = "") } #generate json body for rest api call to create the reference: @@ -154,17 +172,17 @@ create_datastore_script <- function(owner, } #create the draft reference: - req <- httr::POST(post_url, + req_draft <- httr::POST(post_url, httr::authenticate(":", "", "ntlm"), httr::add_headers('Content-Type' = 'application/json'), body = bdy) #check status code; suggest logging in to VPN if errors occur: - status_code <- httr::stop_for_status(req)$status_code + status_code <- httr::stop_for_status(req_draft)$status_code if (!status_code == 200) { stop("ERROR: DataStore connection failed. Are you logged in to the VPN?\n") } #get newly created reference id: - json <- httr::content(req, "text") + json <- httr::content(req_draft, "text") rjson <- jsonlite::fromJSON(json) ds_ref <- rjson$referenceCode @@ -179,7 +197,7 @@ create_datastore_script <- function(owner, } #inform user a new reference has been generated: if (force == FALSE) { - cat("A draft reference has been created on DataStore.\n") + cat("A draft reference has been created on DataStore.\n\n") } #use reference id to put the file: @@ -271,7 +289,7 @@ create_datastore_script <- function(owner, if (force == FALSE) { cat("Your file, ", crayon::blue$bold(file_name), ", has been uploaded to:\n", sep = "") - cat(ds_resource_url, "\n", sep = "") + cat(ds_resource_url, "\n\n", sep = "") } #add a web link: #release url: @@ -300,19 +318,19 @@ create_datastore_script <- function(owner, } #upload the weblink: - req <- httr::POST( + req_weblink <- httr::POST( url = api_url, httr::add_headers('Content-Type' = 'application/json'), httr::authenticate(":", "", "ntlm"), body = bdy) - status_code <- httr::stop_for_status(req)$status_code + status_code <- httr::stop_for_status(req_weblink)$status_code if (status_code != 200) { stop("ERROR: DataStore connection failed. Your web link was not added.") } if (force == FALSE) { cat("The following web link has been added to your Script Reference: \n") - cat(weblink, "\n", sep = "") + cat(weblink, "\n\n", sep = "") } #add keywords @@ -367,6 +385,7 @@ create_datastore_script <- function(owner, if (force == FALSE) { cat("Your DataStore Reference now has the following keywords:\n") print(rjson_kw) + cat("\n") } } @@ -383,12 +402,11 @@ create_datastore_script <- function(owner, mylist <- list(internal = FALSE, filesInternal = FALSE, FileRestricted = FALSE, - sensitivity = "Not Sensitive", - distribution = "No Restriction", - quality = "Operational", - additionalUserDefined = "", - noDataMgrEdit = FALSE, - linksRestricted = FALSE) + additionalConstraints = "none", + legalAuthority = list("none"), + otherAuthority = "No Restriction", + justification = "none", + contactEmail = "none") bdy <- jsonlite::toJSON(mylist, pretty = TRUE, auto_unbox = TRUE) if (dev == TRUE) { @@ -399,19 +417,144 @@ create_datastore_script <- function(owner, ds_ref, "/AccessConstraints") } - #create the draft reference: - req <- httr::PUT(post_url, + #set reference to public: + req_public <- httr::PUT(post_url, httr::authenticate(":", "", "ntlm"), httr::add_headers('Content-Type' = 'application/json'), body = bdy) #check status code; suggest logging in to VPN if errors occur: - status_code <- httr::stop_for_status(req)$status_code + status_code <- httr::stop_for_status(req_public)$status_code if (!status_code == 200) { stop("ERROR: DataStore connection failed. Are you logged in to the VPN?\n") } - #get newly created reference id: - json <- httr::content(req, "text") - rjson <- jsonlite::fromJSON(json) + + #set bibliography patch URL + if (dev == TRUE) { + patch_url <- paste0(.QC_ds_dev_api(), + "Reference/", + ds_ref, + "/Bibliography") + } else { + patch_url <- paste0(.QC_ds_secure_api(), + "Reference/", + ds_ref, + "/Bibliography") + } + + #Set issuedDate & Agency originated: + date <- list(year = format(Sys.time(), "%Y"), + month = format(Sys.time(), "%m"), + day = format(Sys.time(), "%d")) + bdy <- list(issuedDate = date, + isAgencyOriginated = for_or_by_NPS) + + bdy <- jsonlite::toJSON(bdy, pretty = TRUE, auto_unbox = TRUE) + + NPS_req <- httr::PATCH(patch_url, + httr::authenticate(":", "", "ntlm"), + httr::add_headers('Content-Type' = 'application/json'), + body = bdy) + + #check status code; suggest logging in to VPN if errors occur: + status_code <- httr::stop_for_status(NPS_req)$status_code + if (!status_code == 200) { + stop("ERROR: DataStore connection failed. Are you logged in to the VPN?\n") + } + + # get and use R DESCRIPTION file: + if (lib_type == "R") { + + descript_url <- paste0("https://raw.githubusercontent.com/", + owner, "/", + repo, "/", + "master/DESCRIPTION") + + #create file name: + file_name <- paste0(repo, "_", gh_req_rjson$tag_name, "_DESCRIPTION") + #create file path + download_file_path <- paste0("releases/", file_name) + + #download the file (.zip) from github: + invisible(capture.output( + suppressMessages( + httr::content( + httr::GET(descript_url, + httr::progress(), + httr::write_disk(download_file_path, + overwrite = TRUE)))))) + # read in the DESCRIPTION file + desc2 <- tryCatch(desc::description$new(file = paste0("releases/", + file_name)), + error = function(e){}, + #warnings for bad or missing DESCRIPTION files + warning = function(w){ + msg <- paste0("Warning: your DESCRIPTION file is ", + "missing or malformatted. Some ", + "DataStore fields could not be ", + "automatically entered. Are you sure ", + "the repo contains a valid R package?") + cat(msg) + }) + + if (!is.null(desc2)) { + + #create authors (contact1) + #authors <- desc::desc_get_author("aut", + # file = paste0("releases/", file_name)) + authors <- desc2$get_author("aut") + #if(!is.null(authors)) { + aut_list <- list() + for (i in 1:length(seq_along(authors))) { + aut <- list(title = NULL, + primaryName = authors[[i]]$family, + firstName = authors[[i]]$given, + middleName = NULL, + suffix = NULL, + affiliation = NULL, + isCorporate = FALSE, + ORCID = authors[[i]]$comment[[1]]) + aut_list <- append(aut_list, list(aut)) + } + contact1 <- aut_list + + #create contacts (contact2) + contacts <- desc2$get_author("cre") + contact2 <- list() + for (i in 1:length(contacts)) { + con <- list(title = NULL, + primaryName = contacts[[i]]$family, + firstName = contacts[[i]]$given, + middleName = NULL, + suffix = NULL, + affiliation = NULL, + isCorporate = FALSE, + ORCID = contacts[[i]]$comment[[1]]) + contact2 <- append(contact2, list(con)) + } + } + + package_descript <- desc2$get("Description")[[1]] + + bdy <- list(miscellaneousCode = "R", + abstract = package_descript, + contacts1 = contact1, + contacts2 = contact2) + + bdy <- jsonlite::toJSON(bdy, pretty = TRUE, null = "null", auto_unbox = TRUE) + + contacts_req <- httr::PATCH(patch_url, + httr::authenticate(":", "", "ntlm"), + httr::add_headers('Content-Type' = 'application/json'), + body = bdy) + + #check status code; suggest logging in to VPN if errors occur: + status_code <- httr::stop_for_status(contacts_req)$status_code + if (!status_code == 200) { + stop("ERROR: DataStore connection failed. Are you logged in to the VPN?\n") + } + } + + # make reference URL if (dev == TRUE) { @@ -425,12 +568,11 @@ create_datastore_script <- function(owner, if (force == FALSE) { cat("Your reference has been set to unrestricted with no sensitivity.\n") - cat("Your reference has been set to \"Operational\" quality.\n") - cat("Unless you have a documented reason to do so, please leave the reference public.\n") + cat("Unless you have a documented reason to do so, please leave the reference public.\n\n") cat("Your draft reference can be accessed at:\n") - - cat(crayon::blue$bold(ds_ref_url)) + ds_ref_url <- utils::URLencode(ds_ref_url) + cli::cli_text("{.url {ds_ref_url}}") } invisible(ds_ref_url) diff --git a/docs/CONTRIBUTING.html b/docs/CONTRIBUTING.html index 2a11824..c128572 100644 --- a/docs/CONTRIBUTING.html +++ b/docs/CONTRIBUTING.html @@ -133,7 +133,7 @@
If you would like to contribute code please make the adjustments and issue a pull request. The development team will review your code prior to merging and pull request. Before issuing a pull request make sure: 1) You have added a description of any changes made to the changelog in NEWS.md 2) If you have added a function, make sure you also include unit tests that cover the function. If you have changed a function, make sure the unit tests still pass. 3) If you have added or changed a function, make sure that the package loads using devtools::load_all(). 2) You have updated any necessary documentation using devtools::document() 3) You have updated the associated web pages using pkgdown::build_site_github_pages() 4) You have checked that there are no errors or warnings when the package is built using devtools::check().
If you would like to contribute code please make the adjustments and issue a pull request. The development team will review your code prior to merging and pull request. Before issuing a pull request make sure: 1) You have added a description of any changes made to the changelog in NEWS.md 2) If you have added a function, make sure you also include unit tests that cover the function. If you have changed a function, make sure the unit tests still pass. 3) If you have added or changed a function, make sure that the package loads using devtools::load_all(). 2) You have updated any necessary documentation using devtools::document() 3) You have updated the associated web pages using pkgdown::build_site_github_pages() 4) You have checked that there are no errors or warnings when the package is built using devtools::check().
# Install and load QCkit via NPSdataverse:
-devtools::install_github("nationalparkservice/NPSdataverse")
+devtools::install_github("nationalparkservice/NPSdataverse")
library(NPSdataverse)
# Alternatively, install and load just QCkit:
-devtools::install_github("nationalparkservice/QCkit")
+devtools::install_github("nationalparkservice/QCkit")
library(QCkit)Source: DESCRIPTION
Baker R, Patterson J, DeVivo J, Quevedo I, Wright S (2025). +
Baker R, Patterson J, DeVivo J, Quevedo I, Wright S (2026). QCkit: NPS Inventory and Monitoring Quality Control Toolkit. R package version 1.2.1, https://nationalparkservice.github.io/QCkit/, https://github.com/nationalparkservice/QCkit/.
@Manual{,
title = {QCkit: NPS Inventory and Monitoring Quality Control Toolkit},
author = {Robert Baker and Judd Patterson and Joe DeVivo and Issac Quevedo and Sarah Wright},
- year = {2025},
+ year = {2026},
note = {R package version 1.2.1, https://nationalparkservice.github.io/QCkit/},
url = {https://github.com/nationalparkservice/QCkit/},
}
diff --git a/docs/index.html b/docs/index.html
index e4a4bba..187a588 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -69,12 +69,12 @@
# install.packages("devtools")
-devtools::install_github("nationalparkservice/QCkit")
+devtools::install_github("nationalparkservice/QCkit")
library(QCkit)
QCkit is also part of the NPSdataverse and can be installed along with the other components of NPSdataverse:
# install.packages("devtools")
-devtools::install_github("nationalparkservice/NPSdataverse")
+devtools::install_github("nationalparkservice/NPSdataverse")
library(NPSdataverse)create_datastore_script now has a new parameter, lib_type. If “R” is specified it will pull as much info as it can from the DESCRIPTION file of an R package and use that info to fill out the Core Bibliography tab on the reference landing page.create_datastore_script function. Defaults to TRUE.Given a GitHub owner ("nationalparkservice") and public repo ("EMLeditor"), the function uses the GitHub API to access the latest release version on GitHub and generate a corresponding draft Script reference on DataStore.
+Given a GitHub owner ("nationalparkservice") and public repo ("EMLeditor"), the function uses the GitHub API to access the latest release version on GitHub and generate a corresponding draft public Script reference on DataStore.
WARNING: if you are not an author of the repo on GitHub, you should probably NOT be the one adding it to DataStore unless you have very good reason. If you want to cite a GitHub release/repo and need a DOI, contact the repo maintainer and suggest they use this function to put it on DataStore for you.
-It searches DataStore for references with a similar title (where the title is repo + release tag). If force = FALSE and there are similarly titled references, the function will return a list of them and ask if the user really wants a new DataStore reference generated. Assuming yes (or if there are no existing DataStore references with a similar title or force = TRUE), the function will: 1) download the .zip of the latest GitHub release for the repo, 2) initiate a draft reference on DataStore, 3) give the draft reference a title (repo + release tag), 4) upload the .zip from GitHub 5) add a web link to the release on GitHub.
create_datastore_script() will also access the keywords from your GitHub repo ("Topics") and add them to the draft references as keywords. It will automatically set your reference and all the files and links to public, allow data managers to edit the reference, and set the quality to "Operational". Unless you have good reason backed by a policy that specifically includes information from your release, please do not change these settings (and perhaps reconsider using public github repositories).
The user will still need to go access the draft Script reference on DataStore to fill in the remaining fields (which are not accessible via API and so cannot be automated through this function) and activate the reference (thereby generating and registering a citeable DOI).
-If the Reference is a version of an older reference, the user will have to access the older version and indicate that it is an older version of the current Reference. The user will also have to manually add the new Reference to a Project for the repo, if desired.
+The function searches DataStore for references with a similar title (where the title is repo + release tag). If force = FALSE and there are similarly titled references, the function will return a list of them and ask if the user really wants a new DataStore reference generated. Assuming yes (or if there are no existing DataStore references with a similar title or if force = TRUE), the function will:
download the .zip of the latest GitHub release for the repo,
initiate a draft reference on DataStore,
give the draft reference a title (repo + release tag),
upload the .zip from GitHub
add a web link to the release on GitHub.
add the items listed under GitHub repo "Topics" as keywords to the DataStore Script reference
Set for or by NPS flag
Set the issued date
If you indicate it is an R package, the authors, steward, description, and other fields will be filled out on the Core tab +#' +The user will still need to go access the draft Script reference on DataStore to fill in the remaining fields (which are not accessible via API and so cannot be automated through this function) and activate the reference (thereby generating and registering a citeable DOI).
If the Reference is a version of an older reference, the user will have to access the older version and indicate that it is an older version of the current Reference. The user will also have to manually add the new Reference to a Project for the repo, if desired.
create_datastore_script(
owner,
repo,
- path = here::here(),
+ lib_type = c("generic_script", "R", "python"),
+ path = here::here(),
force = FALSE,
dev = FALSE,
+ for_or_by_NPS = TRUE,
chunk_size_mb = 1,
retry = 1
)String. Can be one of three values: generic_script, R, or python. Defaults to "generic_script".
String. The location where the release .zip from GitHub should be downloaded to (and uploaded from). Defaults to the working directory of the R Project (i.e. here::here()).
String. The location where the release .zip from GitHub should be downloaded to (and uploaded from). Defaults to the working directory of the R Project (i.e. here::here()).
Logical. Was the code, script, or software created either for or by NPS? Defaults to TRUE.
The "chunk" size to break the file into for upload. If your network is slow and your uploads are failing, try decreasing this number (e.g. 0.5 or 0.25).
document_missing_values(
file_name,
- directory = here::here(),
+ directory = here::here(),
colname = NA,
missing_val_codes = NA,
replace_value = NA
@@ -130,7 +130,7 @@ Details
Examples
if (FALSE) { # \dontrun{
document_missing_values(file_name = "mydata.csv",
- directory = here::here(),
+ directory = here::here(),
colname = NA, #do not change during function development
missing_val_codes = c("missing", "blank", "no data"),
replace_value = NA)
diff --git a/docs/reference/get_custom_flags.html b/docs/reference/get_custom_flags.html
index 3e31552..2b40c44 100644
--- a/docs/reference/get_custom_flags.html
+++ b/docs/reference/get_custom_flags.html
@@ -91,7 +91,7 @@ Creates dataframe(s) summarizing data quality
Usage
get_custom_flags(
- directory = here::here(),
+ directory = here::here(),
cols = (""),
output = c("all", "files", "columns")
)
diff --git a/docs/reference/get_dc_flags.html b/docs/reference/get_dc_flags.html
index 8d1be1f..a6b110d 100644
--- a/docs/reference/get_dc_flags.html
+++ b/docs/reference/get_dc_flags.html
@@ -63,7 +63,7 @@ Create Table of Data Quality Flags in Flagging Columns within individual dat
diff --git a/docs/reference/get_df_flags.html b/docs/reference/get_df_flags.html
index fff9e1a..539229d 100644
--- a/docs/reference/get_df_flags.html
+++ b/docs/reference/get_df_flags.html
@@ -63,7 +63,7 @@ Create Table of Data Quality Flags Found in Data Files within a Data Package
diff --git a/docs/reference/get_dp_flags.html b/docs/reference/get_dp_flags.html
index b608844..3104ffe 100644
--- a/docs/reference/get_dp_flags.html
+++ b/docs/reference/get_dp_flags.html
@@ -63,7 +63,7 @@ Create Table of Data Quality Flags Found in a Data Package
diff --git a/docs/reference/remove_empty_tables.html b/docs/reference/remove_empty_tables.html
index 7f78346..14dfdc1 100644
--- a/docs/reference/remove_empty_tables.html
+++ b/docs/reference/remove_empty_tables.html
@@ -64,7 +64,7 @@ Value
Examples
-test_list <- list(item_a = tibble::tibble,
+test_list <- list(item_a = tibble::tibble,
item_b = mtcars,
item_c = iris)
diff --git a/docs/reference/replace_blanks.html b/docs/reference/replace_blanks.html
index e6e7120..1d072a7 100644
--- a/docs/reference/replace_blanks.html
+++ b/docs/reference/replace_blanks.html
@@ -105,7 +105,7 @@ Replaces all blank cells a missing value code of your choice
Usage
- replace_blanks(directory = here::here(), missing_val_code = NA)
+ replace_blanks(directory = here::here(), missing_val_code = NA)
@@ -139,7 +139,7 @@ Examples replace_blanks()
#replace all blank cells in .csvs in the directory ./test_data with "NODATA"
- dir <- here::here("test_data")
+ dir <- here::here("test_data")
replace_blanks(directory = dir, missing_val_code = "NODATA")
#replace all blank cells in .csvs in the current directory with -99999
diff --git a/man/create_datastore_script.Rd b/man/create_datastore_script.Rd
index 1503204..b1d9ac4 100644
--- a/man/create_datastore_script.Rd
+++ b/man/create_datastore_script.Rd
@@ -7,9 +7,11 @@
create_datastore_script(
owner,
repo,
+ lib_type = c("generic_script", "R", "python"),
path = here::here(),
force = FALSE,
dev = FALSE,
+ for_or_by_NPS = TRUE,
chunk_size_mb = 1,
retry = 1
)
@@ -19,12 +21,16 @@ create_datastore_script(
\item{repo}{String. The repo with a release that should be turned into a DataStore Script reference. For example, "EMLeditor"}
+\item{lib_type}{String. Can be one of three values: generic_script, R, or python. Defaults to "generic_script".}
+
\item{path}{String. The location where the release .zip from GitHub should be downloaded to (and uploaded from). Defaults to the working directory of the R Project (i.e. \code{here::here()}).}
\item{force}{Logical. Defaults to FALSE. In the default status the function has a number of interactive components, such as searching DataStore for similarly titled References and asking if a new Reference is really what the user wants. When set to TRUE, all interactive components are turned off and the function will proceed unless it hits an error. Setting force = TRUE may be useful for scripting purposes.}
\item{dev}{Logical. Defaults to FALSE. In the default status, the function generates and populates a new draft Script reference on the DataStore production server. If set to TRUE, the draft Script reference will be generated and populated on the DataStore development server. Setting dev = TRUE may be useful for testing the function without generating excessive references on the DataStore production server.}
+\item{for_or_by_NPS}{Logical. Was the code, script, or software created either for or by NPS? Defaults to TRUE.}
+
\item{chunk_size_mb}{The "chunk" size to break the file into for upload. If your network is slow and your uploads are failing, try decreasing this number (e.g. 0.5 or 0.25).}
\item{retry}{How many times to retry uploading a file chunk if it fails on the first try.}
@@ -33,15 +39,24 @@ create_datastore_script(
Invisibly returns the URL to the DataStore draft reference that was created.
}
\description{
-Given a GitHub owner ("nationalparkservice") and public repo ("EMLeditor"), the function uses the GitHub API to access the latest release version on GitHub and generate a corresponding draft Script reference on DataStore.
+Given a GitHub owner ("nationalparkservice") and public repo ("EMLeditor"), the function uses the GitHub API to access the latest release version on GitHub and generate a corresponding draft public Script reference on DataStore.
WARNING: if you are not an author of the repo on GitHub, you should probably NOT be the one adding it to DataStore unless you have very good reason. If you want to cite a GitHub release/repo and need a DOI, contact the repo maintainer and suggest they use this function to put it on DataStore for you.
-It searches DataStore for references with a similar title (where the title is repo + release tag). If \code{force = FALSE} and there are similarly titled references, the function will return a list of them and ask if the user really wants a new DataStore reference generated. Assuming yes (or if there are no existing DataStore references with a similar title or \code{force = TRUE}), the function will: 1) download the .zip of the latest GitHub release for the repo, 2) initiate a draft reference on DataStore, 3) give the draft reference a title (repo + release tag), 4) upload the .zip from GitHub 5) add a web link to the release on GitHub.
-
-\code{create_datastore_script()} will also access the keywords from your GitHub repo ("Topics") and add them to the draft references as keywords. It will automatically set your reference and all the files and links to public, allow data managers to edit the reference, and set the quality to "Operational". Unless you have good reason backed by a policy that specifically includes information from your release, please do not change these settings (and perhaps reconsider using public github repositories).
-
+The function searches DataStore for references with a similar title (where the title is repo + release tag). If \code{force = FALSE} and there are similarly titled references, the function will return a list of them and ask if the user really wants a new DataStore reference generated. Assuming yes (or if there are no existing DataStore references with a similar title or if \code{force = TRUE}), the function will:
+\enumerate{
+\item download the .zip of the latest GitHub release for the repo,
+\item initiate a draft reference on DataStore,
+\item give the draft reference a title (repo + release tag),
+\item upload the .zip from GitHub
+\item add a web link to the release on GitHub.
+\item add the items listed under GitHub repo "Topics" as keywords to the DataStore Script reference
+\item Set for or by NPS flag
+\item Set the issued date
+\item If you indicate it is an R package, the authors, steward, description, and other fields will be filled out on the Core tab
+#'
The user will still need to go access the draft Script reference on DataStore to fill in the remaining fields (which are not accessible via API and so cannot be automated through this function) and activate the reference (thereby generating and registering a citeable DOI).
+}
If the Reference is a version of an older reference, the user will have to access the older version and indicate that it is an older version of the current Reference. The user will also have to manually add the new Reference to a Project for the repo, if desired.
}