Skip to content

Commit

Permalink
♻️ Makefile: variable summary files (for lab.*.tsv)
Browse files Browse the repository at this point in the history
  • Loading branch information
WillForan committed Dec 5, 2023
1 parent b0f61db commit 5376790
Showing 1 changed file with 32 additions and 15 deletions.
47 changes: 32 additions & 15 deletions results/Makefile
Original file line number Diff line number Diff line change
@@ -1,29 +1,46 @@
.SUFFIXES:
.PHONY: .ALWAYS all
.ALWAYS:
.PRECIOUS: lab.info.tsv heroku.info.tsv lab.raw.tsv
.ALWAYS: /Volumes/Hera/Projects/Habit/mr/habit/txt/all_habit.json

all: summary.csv data_all.tsv
all: lab.summary.csv # prev data_all.tsv, no longer need to update heroku.summary.csv

#mkifdiff from lncdtools
raw.json: .ALWAYS
psql `./dburl` -A -qtc \
"select json_agg(json_build_object('id',worker_id,'task',task_name,'created_at', created_at, 'finished_at',finished_at, 'ver', version,'timepoint',timepoint, 'run_number',run_number,'json', json::json)) from run where finished_at is not null;" | \
mkifdiff $@;
heroku.raw.json: .ALWAYS
echo "heroku no longer used (20221229)"
#psql `./dburl` -A -qtc \
# "select json_agg(json_build_object('id',worker_id,'task',task_name,'created_at', created_at, 'finished_at',finished_at, 'ver', version,'timepoint',timepoint, 'run_number',run_number,'json', json::json)) from run where finished_at is not null;" | \
# mkifdiff $@;

raw.tsv: raw.json
/Volumes/Hera/Projects/Habit/mr/habit/txt/all_habit.json:
make -C /Volumes/Hera/Projects/Habit/mr/habit/ txt/all_habit.json

lab.raw.json: /Volumes/Hera/Projects/Habit/mr/habit/txt/all_habit.json
cp $< $@


# raw data for R to read: heroku.raw.tsv and lab.raw.tsv
%.raw.tsv: %.raw.json
./dbjsontotsv.jq < $< > $@

survey.tsv: raw.json
# separately, get info "survey" and age data
%.info.tsv: %.raw.json
./extra_info.jq < $< > $@

# not needed when using .info.tsv and raw.tsv
bea_res_concat.tsv: $(wildcard /Volumes/L/bea_res/Data/Tasks/Habit/MR/1*_2*/*tsv)
cat_skiphead $? > $@
# tsv from orig json via /Volumes/Hera/Projects/Habit/mr/habit/Makefile
cat_skiphead $^ > $@

# previously generated by read.R's fix_and_save
# data_id-hidden.tsv: heroku.data.tsv

data_id-hidden.tsv: data.tsv
data.tsv: raw.tsv
Rscript -e "source('./read.R'); fix_and_save()"
# data_heroku.tsv, data_lab.tsv
%.data.tsv: %.raw.tsv
Rscript -e "source('./read.R'); fix_and_save(infile='$<',outname='$@')"

summary.csv: data.tsv survey.tsv
./summary.R
%.summary.csv: %.info.tsv %.data.tsv
./summary.R $^ $@ # order is important: info data output

data_all.tsv: data.tsv bea_res_concat.tsv
data_all.tsv: heroku.data.tsv lab.data.tsv #bea_res_concat.tsv
cat_skiphead $^ > $@

0 comments on commit 5376790

Please sign in to comment.