feat(py_image_layer): configurable default layer compression#1219
Open
thirtyseven wants to merge 1 commit into
Open
feat(py_image_layer): configurable default layer compression#1219thirtyseven wants to merge 1 commit into
thirtyseven wants to merge 1 commit into
Conversation
Add a //py:layer_compression string_flag (gzip|zstd, default gzip) that sets the default compression for any py_image_layer layer that doesn't pin its own algorithm via py_layer_tier.compression. Flip it globally with --@aspect_rules_py//py:layer_compression=zstd. The flag is read through a private _layer_compression attr on both layer aspects and the rule, mirroring how _layer_tier is plumbed. _compression_for and _declare_group_tar fall back to the flag value (and derive the .tar.gz / .tar.zst extension from it) instead of hard-coding gzip.
thesayyn
reviewed
Jul 1, 2026
| # Users can set --@aspect_rules_py//py:layer_compression=zstd to change the | ||
| # default compression py_image_layer uses for any layer that doesn't pin its | ||
| # own algorithm via py_layer_tier.compression. | ||
| string_flag( |
Member
There was a problem hiding this comment.
Shouldn't this be read by layer_tier and set the default compression to this value instead of every py_image_layer deciding that.
py_binary startup benchmark
sys.path quality
✅ No regression detected (PR is +0.3% vs HEAD main) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
py_image_layeralways compresses layers with gzip unless apy_layer_tierpins a per-group algorithm. There's no way to flip the default (e.g. to zstd) globally without editing every tier.Change
Adds a
//py:layer_compressionstring_flag(gzip|zstd, defaultgzip). It sets the default compression for any layer that doesn't pin its own algorithm viapy_layer_tier.compression:_layer_compressionattr on both layer aspects and the rule, mirroring how_layer_tieris plumbed._compression_forand_declare_group_tarfall back to the flag value and derive the.tar.gz/.tar.zstextension from it, instead of hard-coding gzip.py_layer_tier.compressionstill wins over the flag.Test
Built the
//cases/oci/py_image_layere2e case both ways:*_default.tar.gz,*_squashed.tar.gz--@aspect_rules_py//py:layer_compression=zstd→*_default.tar.zst,*_squashed.tar.zstDefault behavior is unchanged (still gzip), so existing tar-listing snapshots are unaffected.