Skip to content

[Backfill corrections] hone AWS publish behavior #1796

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 1, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions backfill_corrections/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,13 @@ run:
/bin/bash -c "cp params.host.json params.json && make gurobi.lic && make standardize-dirs && make run-local OPTIONS=\"${OPTIONS}\" LOG_FILE=${LOG_FILE}"

publish:
NUM_FILES=`find $(USR_EXPORT_DIR) -name "*csv.gz" | wc -l`; \
NUM_FILES=`find $(USR_EXPORT_DIR) -name "prediction*.csv.gz" | wc -l`; \
if [[ $$NUM_FILES -gt 0 ]]; then \
aws configure set aws_access_key_id $(AWS_KEY_ID); \
aws configure set aws_secret_access_key $(AWS_SECRET_KEY); \
aws s3 cp $(USR_EXPORT_DIR) $(S3_BUCKET)/ --recursive --exclude "*" --include "*.csv.gz" --acl public-read; \
AWS_MSG=`aws s3 cp $(USR_EXPORT_DIR) $(S3_BUCKET)/ --recursive --exclude "*" --include "*/prediction*.csv.gz"`; \
echo "$${AWS_MSG}"; \
[[ `echo "$${AWS_MSG}" | grep "upload:" | wc -l` -eq $$NUM_FILES ]] || ( echo "ERROR: Not all $${NUM_FILES} expected files were uploaded" && exit 74 ); \
Comment on lines +92 to +94
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thought (nonblocking): it really feels like there should be a way to do this with tee or process substitution instead of variables and echo

I played with it for a while and the closest I got was teeing to stderr, which would probably be excluded from the log and that's not what we want... and your way is definitely more readable.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it's awkward to have the file upload running as a side effect.

There are some suggestions online to tee to /dev/tty or $(tty) but I can't actually get this to work on my own computer. Something to look into.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that could work when running from a terminal, but normal pipeline operations typically run headless alas

echo "SUCCESS: published $${NUM_FILES} files to the S3 bucket" >> $(LOG_FILE); \
else \
echo "No files in $(USR_EXPORT_DIR) to publish" >> $(LOG_FILE); \
Expand Down