Skip to content

Commit 0bc5a7d

Browse files
authored
Merge pull request #1211 from cmu-delphi/produce-microdata-raceeth
Support upload of raceeth microdata in Makefile
2 parents be29276 + 9d3a8b5 commit 0bc5a7d

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

facebook/Makefile

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ QUALTRICS=$(shell $(PYTHON) -m delphi_utils get input_dir)
1313
WEIGHTS=$(shell $(PYTHON) -m delphi_utils get weights_in_dir)
1414
CIDS=$(shell $(PYTHON) -m delphi_utils get weights_out_dir)
1515
INDIVIDUAL=$(shell $(PYTHON) -m delphi_utils get individual_dir)
16+
INDIVIDUAL_RACEETH=$(shell $(PYTHON) -m delphi_utils get individual_raceeth_dir)
1617
ARCHIVE=$(shell $(PYTHON) -m delphi_utils get archive_dir)
1718
RECEIVING=$(shell $(PYTHON) -m delphi_utils get export_dir)
1819
FB_CC=$(shell $(PYTHON) -m delphi_utils get qualtrics.notify-bad-weights)
@@ -26,6 +27,7 @@ MAX_WEIGHTED=ls -1 $(WEIGHTS) | grep dap | tail -1 | sed 's/_.*//;s/-//g;'
2627
ANTIJOIN:="antijoin.cids.sorted.txt"
2728
CIDS_DEST:="fb-interchange/cmu_respondent_ids"
2829
INDIVID_DEST:="fb-public-results/"
30+
INDIVID_RACEETH_DEST:="protected-race-ethnicity-data/"
2931
RAW_DEST:="raw"
3032

3133
# dry-run mode: generate all files, but do not post them anywhere, and disable all emails to outside parties.
@@ -52,11 +54,12 @@ tidy: receiving
5254
cp params.json tidy/
5355
mv $(RECEIVING)/*.csv tidy/$(RECEIVING)
5456
mv $(INDIVIDUAL)/*.csv* tidy/$(INDIVIDUAL)
57+
mv $(INDIVIDUAL_RACEETH)/*.csv* tidy/$(INDIVIDUAL_RACEETH)
5558
tar -czf scratch/tidy-`date +"%Y-%m-%d-%H%M%S"`.tgz --exclude='tidy-*.tgz' tidy
5659
mv scratch/*.tgz tidy/
5760

5861
clean:
59-
rm -f $(RECEIVING)/*.csv $(INDIVIDUAL)/*.csv $(CIDS)/*.csv
62+
rm -f $(RECEIVING)/*.csv $(INDIVIDUAL)/*.csv $(INDIVIDUAL_RACEETH)/*.csv $(CIDS)/*.csv
6063

6164
clean-archive:
6265
rm -f $(ARCHIVE)/*.Rds
@@ -98,6 +101,7 @@ params.json: $(TODAY)
98101
PAT=`grep fb-survey params.json | awk 'BEGIN{FS="\""}{print $$2}' | sed 's/ /_/g;s/^/-e /'`; \
99102
$(PYTHON) -m delphi_utils set \
100103
debug false \
104+
produce_individual_raceeth true \
101105
end_date $(YESTERDAY) \
102106
input <(find $(QUALTRICS) -maxdepth 1 -newer $< -type f -name "*.csv" | sort | grep $${PAT} | tr '\n' ',' | sed 's_$(QUALTRICS)/__g;s/,$$//' ) \
103107
parallel true \
@@ -136,7 +140,7 @@ run-R: $(CIDS)
136140
grep "scheduled core" tmp ; \
137141
[ "$$?" -eq 1 ]
138142

139-
pipeline: scratch init-qualtrics params.json $(WEIGHTS) run-R post-cids post-individual post-done tidy
143+
pipeline: scratch init-qualtrics params.json $(WEIGHTS) run-R post-cids post-individual post-individual-raceeth post-done tidy
140144
grep $(TODAY) params.json
141145
[ -f $(YESTERDAY) ] && rm $(YESTERDAY) || true
142146
touch $@
@@ -193,6 +197,19 @@ post-individual: $(TODAY) $(INDIVIDUAL)
193197
echo "SUCCESS: $(DRY_MESSAGE)Posted `echo $${POST} | wc -w` microresponse files" >> $(MESSAGES)
194198
touch $@
195199

200+
post-individual-raceeth: $(TODAY) $(INDIVIDUAL_RACEETH)
201+
POST=`find $(INDIVIDUAL_RACEETH) -maxdepth 1 -newer $(TODAY) -name "cvid_responses_*.csv"`; \
202+
[ -n "$${POST}" ]; \
203+
BATCH=""; \
204+
for f in $${POST}; do \
205+
(grep token $$f; [[ $$? -eq 1 ]]); \
206+
gzip -f $$f; \
207+
BATCH="$${BATCH}put $${f}.gz ${INDIVID_RACEETH_DEST}\n"; \
208+
done; \
209+
$(SFTP_POST); \
210+
echo "SUCCESS: $(DRY_MESSAGE)Posted `echo $${POST} | wc -w` race-ethnicity microresponse files" >> $(MESSAGES)
211+
touch $@
212+
196213
post-done: post-cids
197214
touch $(YESTERDAY).done
198215
BATCH="put $(YESTERDAY).done $(CIDS_DEST)\n"; \

facebook/params.json.production.template

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
"end_date": "2020-08-28",
88
"export_dir": "./receiving",
99
"individual_dir": "./individual",
10+
"individual_raceeth_dir": "./individual_raceeth",
11+
"produce_individual_raceeth": false,
1012
"input": [
1113
"2020-08-29.2020-08-22.2020-08-29.Survey_of_COVID-Like_Illness_-_TODEPLOY_......_-_US_Expansion.csv",
1214
"2020-08-29.2020-08-22.2020-08-29.Survey_of_COVID-Like_Illness_-_TODEPLOY-_US_Expansion_-_With_Translations.csv"

0 commit comments

Comments
 (0)