Skip to content

Commit

Permalink
Adding some debugging output & removing the duplicate line that was b…
Browse files Browse the repository at this point in the history
…reaking the build.
  • Loading branch information
jdangerx committed Jan 8, 2024
1 parent 3f42a46 commit a958d57
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 16 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/build-deploy-pudl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ jobs:
- name: Make GCP Batch config file
if: ${{ env.SKIP_BUILD != 'true' }}
env:
PUDL_OUTPUT_PATH: ${{ env.GCS_OUTPUT_BUCKET }}/${{ env.BUILD_ID }}
PUDL_GCS_OUTPUT: ${{ env.GCS_OUTPUT_BUCKET }}/${{ env.BUILD_ID }}
run: |-
./devtools/generate_batch_config.py \
--output ${{ env.BATCH_JOB_JSON }} \
Expand Down Expand Up @@ -162,8 +162,7 @@ jobs:
--container-env GITHUB_ACTION_TRIGGER=${{ github.event_name }} \
--container-env NIGHTLY_TAG=${{ env.NIGHTLY_TAG }} \
--container-env PUDL_BOT_PAT=${{ secrets.PUDL_BOT_PAT }} \
--container-env PUDL_GCS_OUTPUT=${{ env.PUDL_GCS_OUTPUT }}
--container-env PUDL_GCS_OUTPUT=${{ env.PUDL_OUTPUT_PATH }} \
--container-env PUDL_GCS_OUTPUT=${{ env.PUDL_GCS_OUTPUT }} \
--container-env PUDL_SETTINGS_YML="/home/mambauser/pudl/src/pudl/package_data/settings/etl_full.yml" \
--container-env SLACK_TOKEN=${{ secrets.PUDL_DEPLOY_SLACK_TOKEN }} \
--container-env ZENODO_SANDBOX_TOKEN_PUBLISH=${{ secrets.ZENODO_SANDBOX_TOKEN_PUBLISH }} \
Expand Down
18 changes: 5 additions & 13 deletions docker/gcp_pudl_etl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# This script won't work locally because it needs adequate GCP permissions.

function send_slack_msg() {
echo "sending slack message"
curl -X POST -H "Content-type: application/json" -H "Authorization: Bearer ${SLACK_TOKEN}" https://slack.com/api/chat.postMessage --data "{\"channel\": \"C03FHB9N0PQ\", \"text\": \"$1\"}"
}

Expand All @@ -13,15 +14,18 @@ function upload_file_to_slack() {
function authenticate_gcp() {
# Set the default gcloud project id so the zenodo-cache bucket
# knows what project to bill for egress
echo "authenticating GCP"
gcloud config set project "$GCP_BILLING_PROJECT"
}

function initialize_postgres() {
echo "initializing postgres"
sudo -u postgres pg_ctl start -l logfile && \
sudo -u postgres psql -c "CREATE USER dagster WITH SUPERUSER PASSWORD 'dagster_password'"
}

function run_pudl_etl() {
echo "starting to run PUDL ETL"
send_slack_msg ":large_yellow_circle: Deployment started for $BUILD_ID :floppy_disk:"
initialize_postgres && \
authenticate_gcp && \
Expand All @@ -48,16 +52,6 @@ function run_pudl_etl() {
&& touch "$PUDL_OUTPUT/success"
}

function shutdown_vm() {
upload_file_to_slack "$LOGFILE" "pudl_etl logs for $BUILD_ID:"
# Shut down the vm instance when the etl is done.
echo "Shutting down VM."
ACCESS_TOKEN=$(curl \
"http://metadata.google.internal/computeMetadata/v1/instance/service-accounts/default/token" \
-H "Metadata-Flavor: Google" | jq -r '.access_token')
curl -X POST -H "Content-Length: 0" -H "Authorization: Bearer ${ACCESS_TOKEN}" "https://compute.googleapis.com/compute/v1/projects/catalyst-cooperative-pudl/zones/$GCE_INSTANCE_ZONE/instances/$GCE_INSTANCE/stop"
}

function save_outputs_to_gcs() {
echo "Copying outputs to GCP bucket $PUDL_GCS_OUTPUT" && \
gsutil -m cp -r "$PUDL_OUTPUT" "$PUDL_GCS_OUTPUT" && \
Expand Down Expand Up @@ -213,6 +207,4 @@ if [[ $ETL_SUCCESS == 0 && \
notify_slack "success"
else
notify_slack "failure"
fi

shutdown_vm
fi

0 comments on commit a958d57

Please sign in to comment.