Skip S3 deployment on branch builds by default - #5558
Conversation
ffb37d2 to
b3a0a02
Compare
46a51bb to
bb9d4a9
Compare
krivard
left a comment
There was a problem hiding this comment.
This is marked as draft but actually looks pretty good as-is? some minor typos & rewords for clarity, and we should take some time at HUDL to show folks the new ropes.
You may also wish to update the following dev docs that mention branch builds:
- Data Validation Reference
- Nightly Data Builds
Happy to re-review any new docs content if needed.
| inputs: | ||
| deploy_to_gcs: | ||
| type: boolean | ||
| description: "Deploy build outputs to GCS? (branch builds only)" | ||
| required: false | ||
| default: true | ||
| deploy_to_s3: | ||
| type: boolean | ||
| description: "Deploy build outputs to S3? (branch builds only; S3 egress fees are large)" | ||
| required: false | ||
| default: false |
There was a problem hiding this comment.
I don't love having params that are always requested but sometimes used and sometimes ignored. Alas I don't think there's a better way to do it. Once this merges I would recommend reviewing the new build interface at a HUDL so everyone knows what these mean and why the defaults are set the way they are.
| # Nightly and stable builds always deploy to both targets; branch builds | ||
| # (workflow_dispatch) override these from the workflow inputs below. |
| echo "DEPLOY_TO_GCS=${{ inputs.deploy_to_gcs }}" | ||
| echo "DEPLOY_TO_S3=${{ inputs.deploy_to_s3 }}" | ||
| echo "GIT_TAG=$BUILD_ID_RAW" | ||
| } >> "$GITHUB_ENV" |
There was a problem hiding this comment.
Lol forced by the linter!
|
|
||
| git_tag: str | ||
| environment: Literal["staging", "production"] | ||
| # Tri-state overrides for the cloud storage upload targets. ``None`` means "use |
There was a problem hiding this comment.
"Tri-state" always autocompletes to "area" in my brain so this massively threw me for a bit
checking understanding: the three states are (boolean True) (boolean False) (None)
There was a problem hiding this comment.
Ah yeah sorry, the 3 states are True, False, and null Agree this isn't clear.
| def test_deployment_plan_rejects_no_upload_target(): | ||
| """A plan that uploads nowhere is rejected at construction time.""" |
There was a problem hiding this comment.
Do we need both this test and test_upload_outputs_raises_when_no_target_enabled?
There was a problem hiding this comment.
Meh, maybe not. I guess they're testing the same underlying check, but entering the execution at different points. There's a little bit of plumbing between them, but not much.
|
@krivard I think the code is pretty much ready. I just hadn't given it a full self-review to get it ready for someone else's eyeballs. But it's also a very manageable size and if you think it's good enough with these comments addressed, happy to merge! |
Uploading ETL outputs to S3 incurs egress fees that, for a full PUDL build, cost more than running the entire ETL. Branch builds currently deploy to both GCS and S3 purely as a test, then delete the staged data again. The nightly build exercises the real S3 deployment every night, so re-testing it on every branch build has little marginal value, while the GCS deployment is free and covers nearly all the same code paths. Branch builds now deploy to GCS but not S3 by default. The build-pudl and deploy-pudl workflow_dispatch forms expose deploy_to_gcs / deploy_to_s3 checkboxes to override this per run, and when neither target is enabled build-pudl skips triggering deploy-pudl entirely (e.g. a build run only to regenerate row counts). Nightly and stable deployments are unchanged and still deploy to both. - DeploymentPlan gains tri-state deploy_to_gcs / deploy_to_s3 overrides and symmetric upload_to_gcs / upload_to_s3 properties: GCS defaults on for every deploy type, S3 defaults on for nightly/stable and off for branch builds. A plan that would deploy nowhere is rejected. - upload_outputs() only builds the fs clients and upload targets for the enabled destinations; _assert_permanent_paths_are_empty tolerates a missing filesystem. - pudl_deploy grows --deploy-gcs/--no-deploy-gcs and --deploy-s3/--no-deploy-s3 flags, threaded through resolve_build. - deploy-pudl.yml and build-pudl.yml expose matching workflow_dispatch inputs; build-pudl passes the resolved values to the batch job, and pudl_batch.sh forwards them to deploy-pudl and gates both trigger_deployment call sites. - Add unit tests and a release notes entry. Closes #5557
Co-authored-by: Kathryn Mazaitis <1158666+krivard@users.noreply.github.com>
fafbcdc to
6246648
Compare
|
@krivard Updated some documentation to reflect the new deployment defaults. |
krivard
left a comment
There was a problem hiding this comment.
I've clearly seen the word "only" too many times today and now it's lost all meaning
Co-authored-by: Kathryn Mazaitis <1158666+krivard@users.noreply.github.com>
Co-authored-by: Kathryn Mazaitis <1158666+krivard@users.noreply.github.com>
Overview
What problem does this address?
Branch builds (any
build-pudlrun kicked off viaworkflow_dispatchfrom the GitHub website or API) currently test the data deployment process by runningdeploy-pudl, which uploads all ETL outputs to both GCS and AWS S3, to astaging/prefix that is deleted again almost immediately.Uploading to S3 incurs egress fees that, for a full PUDL build, cost more than running the entire ETL. We pay this on every branch build even though the nightly build already exercises the real S3 deployment every night, and the GCS deployment (no egress fees) covers nearly all of the same code paths for free.
We deploy about 30 GB of data for every build now, so that's about $3.60 per copy that gets uploaded to S3. If we push to both
nightly/andeel-hole/paths separately, that's $7.20 per branch build (on top of the ~$1 for the ETL itself)What did you change?
Branch builds now deploy to GCS but not S3 by default. Nightly and stable deployments are unchanged and still deploy to both.
DeploymentPlan(src/pudl/deploy/pudl.py) gainsdeploy_to_gcs/deploy_to_s3overrides and symmetricupload_to_gcs/upload_to_s3properties: GCS defaults on for every deploy type; S3 defaults on for nightly/stable and off for branch builds. A plan that would deploy nowhere is rejected.upload_outputs()only constructs thegcsfs/s3fsclients and upload targets for the enabled destinations;_assert_permanent_paths_are_emptytolerates a missing filesystem.pudl_deploygrows--deploy-gcs/--no-deploy-gcsand--deploy-s3/--no-deploy-s3flags, threaded throughresolve_build.deploy-pudl.ymlandbuild-pudl.ymlexpose matchingworkflow_dispatchinputs (deploy_to_gcsdefault true,deploy_to_s3default false forbuild-pudl).build-pudlpasses the resolved values to the batch job, andpudl_batch.shforwards them todeploy-pudland gates bothtrigger_deploymentcall sites — when neither target is enabled,deploy-pudlis not triggered at all (e.g. a build run only to regenerate row counts).Closes #5557
Documentation
Make sure to update relevant aspects of the documentation:
docs/release_notes.rstTesting
tests/unit/deploy/deploy_pudl_test.pycover the default/override logic onDeploymentPlanand thatupload_outputsskips S3 (and never constructs an S3 client) when disabled.To-do list
pixi run pytest-unitandpixi run pytest-integration(2-5 minutes total) and fix any issues that come up.pixi run prek-runto run linters and static code analysis checks.pixi run pytest-ci