Commit graph

2 commits

Author SHA1 Message Date
Ryan Kuester
18b9e6f2a8
test(python): rewrite unsupported-compression test for legacy path (#3646)
An upcoming change switches compress() to emitting DECODE-based
models. The Python ops resolver registers the DECODE operator
unconditionally, so those models load successfully even in a build
without compression support. That breaks this test's original
approach, which ran a model through compress() and expected the load
to fail. Rewrite it to instead inject a raw COMPRESSION_METADATA
entry into the flatbuffer via model_editor, directly exercising the
HasCompressionMetadata() detection path for legacy-compressed models.

Decoupling the test from compress() output lets it verify the
legacy-rejection behavior independently of what compress() emits, so
it passes both before and after the switch.

BUG=part of #3256
2026-08-03 21:33:59 -07:00
Ryan Kuester
74b9db940a
feat(python): throw error when loading compressed models without support (#3167)
When a model contains COMPRESSION_METADATA but the interpreter was built
without compression support, throw a RuntimeError with a helpful message
directing users to build with --//:with_compression=true.

The implementation uses inline functions in compression_utils.h
that are optimized away when compression is disabled, ensuring
all code paths remain compile-checked, and readable without
preprocessor clutter.

Includes test_compression_unsupported.py to verify the error detection,
which only runs when compression is disabled.

BUG=#3125
2025-08-04 23:11:45 +00:00