Skip to content

Commit

Permalink
Refactor rodent db creation
Browse files Browse the repository at this point in the history
save download and build times for vignette
  • Loading branch information
joelnitta committed Aug 31, 2022
1 parent 29ed3f1 commit f1024fa
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 17 deletions.
Binary file added other/rodent_build_times.rds
Binary file not shown.
30 changes: 13 additions & 17 deletions other/rodent_db.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,17 @@ if (!dir.exists(rodents_path)) {
}
# set the restez path to a memorable location
restez_path_set(rodents_path)
# download domain 15.
# Wrap in a while loop to repeat download attempt until finishes.
tries <- 0
dwntm <- system.time({
while (TRUE) {
x <- try(db_download(preselection = 15))
if (inherits(x, "try-error")) {
cat("ERROR: ", x, "\n")
tries <- tries + 1
message(paste("Trying again, attempt number", tries))
Sys.sleep(10)
} else {
break
}
}
})
# download domain 10 and build db, record times
# if max_tries > 1, should set overwrite to FALSE or will start over again
dl_time <- system.time(
db_download(preselection = 10, max_tries = 100, overwrite = FALSE))

crttm <- system.time(db_create(min_length = 100, max_length = 1000))
db_time <- system.time(db_create(min_length = 100, max_length = 1000))

# save times to RDS for documentation in vignette
rodent_times <- list(
dl_time = dl_time,
db_time = db_time
)

saveRDS(rodent_times, "other/rodent_build_times.rds")

0 comments on commit f1024fa

Please sign in to comment.