Skip to content
This repository has been archived by the owner on Jun 1, 2023. It is now read-only.

Commit

Permalink
make all tmp files qs for faster read/write
Browse files Browse the repository at this point in the history
  • Loading branch information
limnoliver committed Mar 30, 2022
1 parent 96bc069 commit 682466f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
1 change: 1 addition & 0 deletions 2_nwis_pull.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ packages:
- ggthemes
- scipiper
- dplyr
- qs

sources:
- 2_nwis_pull/src/inventory_nwis.R
Expand Down
12 changes: 6 additions & 6 deletions 2_nwis_pull/src/nwis_pull.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ plan_nwis_pull <- function(partitions_ind, service) {
download <- scipiper::create_task_step(
step_name = 'download',
target_name = function(task_name, step_name, ...) {
file.path(folders$tmp, sprintf('%s_%s.rds', service, task_name))
file.path(folders$tmp, sprintf('%s_%s.qs', service, task_name))
},
command = function(steps, ...) {
paste(
Expand Down Expand Up @@ -71,13 +71,13 @@ create_nwis_pull_makefile <- function(makefile, task_plan, final_targets) {
# .ind file that we will want to share because it represents the shared cache
combine_nwis_data <- function(ind_file, ...){

rds_files <- c(...)
qs_files <- c(...)
df_list <- list()

for (i in seq_len(length(rds_files))){
for (i in seq_len(length(qs_files))){

message(paste0("Reading in and processing file ", rds_files[i]))
temp_dat <- readRDS(rds_files[i])
message(paste0("Reading in and processing file ", qs_files[i]))
temp_dat <- qs::qread(qs_files[i])

if (grepl('_uv_', ind_file)) {
reduced_dat <- choose_temp_column_uv(temp_dat)
Expand Down Expand Up @@ -147,7 +147,7 @@ get_nwis_data <- function(data_file, partition, nwis_pull_params, service, verbo
# write the data to rds file. do this even if there were 0
# results because remake expects this function to always create the target
# file
saveRDS(nwis_dat, data_file)
qs::qsave(nwis_dat, data_file)
}

choose_temp_column_dv <- function(temp_dat) {
Expand Down

0 comments on commit 682466f

Please sign in to comment.