PG1204 opened a new pull request, #7297: URL: https://github.com/apache/texera/pull/7297
### What changes were proposed in this PR? The HuggingFace operator's pre-loop config validations (prompt column, zero-shot candidate labels, question-answering context column, sentence-similarity/text-ranking sentences column) used Python `assert`. That has two problems: `assert` is **stripped entirely under `python -O`**, silently disabling the checks, and it raises `AssertionError` instead of the `ValueError` used elsewhere in the operator. This converts the four `assert X, (msg)` checks to `if not X: raise ValueError(msg)`. Behavior is otherwise identical, same messages, same fail-fast on misconfiguration, but the checks now survive `-O` and raise a consistent error type. This is the `assert`->`ValueError` half of #7199. The other half is `zero-shot-image-classification` raising a `ValueError` inside the per-row loop (which crashes the operator rather than writing a per-row error), is left as a follow-up, since it needs a structural change and a separate design decision. ### Any related issues, documentation, discussions? Addresses #7199 (the `assert`->`ValueError` part; the zero-shot per-row-crash follow-up remains). ### How was this PR tested? `sbt "WorkflowOperator/testOnly org.apache.texera.amber.operator.huggingFace.* org.apache.texera.amber.util.PythonCodeRawInvalidTextSpec"`: passes (126 tests). Added a test asserting the generated script contains no `assert ` and uses the explicit `raise ValueError` form; `PythonCodeRawInvalidTextSpec` py-compiles the generated Python (guards the multi-line indentation change). scalafmt clean. ### Was this PR authored or co-authored using generative AI tooling? This PR was co-authored with Claude Opus 4.8 in compliance with ASF policy. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
