Skip to content

Commit

Permalink
add ability to add version comment
Browse files Browse the repository at this point in the history
  • Loading branch information
rxu17 committed Oct 29, 2024
1 parent 9c89b28 commit 9079192
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
4 changes: 2 additions & 2 deletions main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,12 @@ workflow BPC_PIPELINE {
update_potential_phi_fields_table(ch_comment, params.production)
// validate_data.out.view()
} else if (params.step == "merge_and_uncode_rca_uploads"){
merge_and_uncode_rca_uploads("default", ch_cohort, params.production)
merge_and_uncode_rca_uploads("default", ch_cohort, ch_comment, params.production)
} else if (params.step == "genie_bpc_pipeline"){
update_potential_phi_fields_table(ch_comment, params.production)
run_quac_upload_report_error(update_potential_phi_fields_table.out, ch_cohort)
run_quac_upload_report_warning(run_quac_upload_report_error.out, ch_cohort, params.production)
merge_and_uncode_rca_uploads(run_quac_upload_report_warning.out, ch_cohort, params.production)
merge_and_uncode_rca_uploads(run_quac_upload_report_warning.out, ch_cohort, ch_comment, params.production)
// remove_patients_from_merged(merge_and_uncode_rca_uploads.out, ch_cohort, params.production)
update_data_table(merge_and_uncode_rca_uploads.out, ch_comment, params.production)
update_date_tracking_table(update_data_table.out, ch_cohort, ch_comment, params.production)
Expand Down
1 change: 1 addition & 0 deletions modules/merge_and_uncode_rca_uploads.nf
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ process merge_and_uncode_rca_uploads {
input:
val previous
val cohort
val comment
val production

output:
Expand Down
24 changes: 20 additions & 4 deletions scripts/uploads/merge_and_uncode_rca_uploads.R
Original file line number Diff line number Diff line change
Expand Up @@ -487,12 +487,22 @@ get_irr <- function(data) {
return(irr)
}

save_to_synapse <- function(path, parent_id, file_name = NA, prov_name = NA, prov_desc = NA, prov_used = NA, prov_exec = NA) {
#' Stores the file, version comment and provenance to Synapse
#' @param path (string) name of cohort
#' @param parent_id (string) whether we are running in production env or staging env
#' @param comment (string) some sort of comment about the new version of the file
#' @param file_name (string) file name
#' @param prov_name (string) name of provenance
#' @param prov_desc (string) provenance description
#' @param prov_used (string) url/link to provenance used
#' @param prov_exec (string) url/link to what was used to execute provenance
save_to_synapse <- function(path, parent_id, comment, file_name = NA, prov_name = NA, prov_desc = NA, prov_used = NA, prov_exec = NA) {

if (is.na(file_name)) {
file_name = path
}
file <- File(path = path, parentId = parent_id, name = file_name)
file$properties$versionComment <- comment

if (!is.na(prov_name) || !is.na(prov_desc) || !is.na(prov_used) || !is.na(prov_exec)) {
act <- Activity(name = prov_name,
Expand Down Expand Up @@ -635,7 +645,9 @@ get_output_folder_id <- function(config, environment){
#' Remove leading and trailing whitespace from a string.
#' @param cohort (string) name of cohort
#' @param environment (string) whether we are running in production env or staging env
save_output_synapse <- function(cohort, environment) {
#' @param comment (string) some sort of comment about the new version of the file
#' related to cohort run
save_output_synapse <- function(cohort, environment, comment) {

parent_id <- get_output_folder_id(config, environment)
file_output_pri <- get_pri_file_name(cohort)
Expand All @@ -647,6 +659,7 @@ save_output_synapse <- function(cohort, environment) {
save_to_synapse(path = file_output_pri,
file_name = gsub(pattern = ".csv|.tsv", replacement = "", x = file_output_pri),
parent_id = parent_id,
comment = comment,
prov_name = "BPC non-IRR upload data",
prov_desc = "Merged and uncoded BPC upload data from sites academic REDCap instances with IRR cases removed",
prov_used = c(as.character(unlist(config$upload[[cohort]])),
Expand All @@ -658,6 +671,7 @@ save_output_synapse <- function(cohort, environment) {
save_to_synapse(path = file_output_irr,
file_name = gsub(pattern = ".csv|.tsv", replacement = "", x = file_output_irr),
parent_id = parent_id,
comment = comment,
prov_name = "BPC IRR upload data",
prov_desc = "Merged and uncoded BPC upload IRR case data from sites academic REDCap instances",
prov_used = c(as.character(unlist(config$upload[[cohort]])),
Expand Down Expand Up @@ -690,7 +704,9 @@ main <- function(){
make_option(c("--production"), action="store_true", default = FALSE,
help="Whether to run in production mode or not (staging mode)."),
make_option(c("-v", "--verbose"), action="store_true", default = FALSE,
help="Print out verbose output on script progress")
help="Print out verbose output on script progress"),
make_option(c("-c", "--comment"), type = "character",
help="Comment for new table snapshot version. This must be unique and is tied to the cohort run.")
)
opt <- parse_args(OptionParser(option_list=option_list))

Expand Down Expand Up @@ -792,7 +808,7 @@ main <- function(){
print(glue("{now(timeOnly = T)}: Saving uncoded data to Synapse..."))
}

save_output_synapse(cohort, environment = env)
save_output_synapse(cohort, environment = env, comment = opt$comment)
}

# clean up for memory
Expand Down

0 comments on commit 9079192

Please sign in to comment.