Skip to content

Commit

Permalink
Merge pull request #31 from pranavanba/main
Browse files Browse the repository at this point in the history
Update provenance for Current Freeze indexing
  • Loading branch information
pranavanba authored May 4, 2024
2 parents e0daa58 + 6163098 commit 00f4a87
Showing 1 changed file with 22 additions and 10 deletions.
32 changes: 22 additions & 10 deletions scripts/main/archive-to-current.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
rm(list = ls())

library(synapser)
library(tidyverse)

rm(list = ls())

#' Replace equal sign with underscore
#'
#' This function renames a directory path by replacing equal signs with underscores.
Expand All @@ -21,6 +21,11 @@ replace_equal_with_underscore <- function(directory_path) {
}
}

unlink(x = c(config::get("AWS_ARCHIVE_DOWNLOAD_LOCATION", "prod"),
config::get("PARQUET_FINAL_LOCATION", "prod")),
recursive = TRUE,
force = TRUE)

synapser::synLogin(authToken = Sys.getenv('SYNAPSE_AUTH_TOKEN'))

rm(list = names(config::get(config = "staging")))
Expand Down Expand Up @@ -103,9 +108,20 @@ if (!is.null(synFindEntityId(validated_date, config::get("PARQUET_FOLDER_ARCHIVE
}

# Index each file in Synapse
latest_commit <- gh::gh("/repos/:owner/:repo/commits/main", owner = "Sage-Bionetworks", repo = "recover-parquet-external")
# latest_commit_tree_url <- latest_commit$html_url %>% stringr::str_replace("commit", "tree")
latest_commit_this_file <- paste0(latest_commit$html_url %>% stringr::str_replace("commit", "blob"), "/scripts/main/archive-to-current.R")
latest_commit <-
gh::gh("/repos/:owner/:repo/commits/main",
owner = "Sage-Bionetworks",
repo = "recover-parquet-external")

latest_commit_this_file <-
paste0(latest_commit$html_url %>% stringr::str_replace("commit", "blob"),
"/scripts/main/archive-to-current.R")

act <-
synapser::Activity(name = "Indexing",
description = "Indexing external parquet datasets",
used = synFindEntityId(validated_date, config::get("PARQUET_FOLDER_ARCHIVE", "prod")),
executed = latest_commit_this_file)

if(nrow(synapse_manifest_to_upload) > 0){
for(file_number in seq_len(nrow(synapse_manifest_to_upload))){
Expand All @@ -126,11 +142,7 @@ if (!is.null(synFindEntityId(validated_date, config::get("PARQUET_FOLDER_ARCHIVE
parentId = tmp$parent,
name = new_fileName)

f <- synStore(f,
activityName = "Indexing",
activityDescription = "Indexing external parquet datasets",
used = PARQUET_FOLDER_INTERNAL,
executed = latest_commit_this_file)
f <- synStore(f, activity = act)

}
}
Expand Down

0 comments on commit 00f4a87

Please sign in to comment.