eugenegujing opened a new pull request, #7577:
URL: https://github.com/apache/texera/pull/7577

   ### What changes were proposed in this PR?
   
   This PR adds unit test coverage for the vectorizer branches of the Python 
code generation in the two shared Sklearn base descriptors:
   
   - `SklearnTrainingOpDesc` (base of the 26 Sklearn training operators)
   - `SklearnClassifierOpDesc` (base of the 25 Sklearn classifier operators)
   
   Both templates branch on the `countVectorizer` and `tfidfTransformer` 
properties to select the text column and prepend `CountVectorizer()` / 
`TfidfTransformer()` stages to the generated `make_pipeline` call, but no test 
in the repository generated code with either flag set: every existing 
`generatePythonCode()` assertion runs with both flags default-false, and the 
specs that do set `countVectorizer = true` are Jackson round-trip tests that 
never invoke code generation.
   
   Two new specs exercise each base through a representative concrete subclass 
(`SklearnTrainingKNNOpDesc` / `SklearnKNNOpDesc`), matching how the operators 
use the bases:
   
   - `SklearnTrainingOpDescCodegenSpec` (4 tests)
   - `SklearnClassifierOpDescCodegenSpec` (4 tests)
   
   Each spec covers all four flag combinations the templates distinguish, with 
positive and negative assertions: the both-false baseline (whole-feature path, 
no vectorizer stages), `countVectorizer` alone (text-column selection plus 
`CountVectorizer()` stage), both flags (stage order asserted via the full 
`make_pipeline(CountVectorizer(), TfidfTransformer(), ...)` call), and 
`tfidfTransformer` alone (a reachable codegen branch even though the UI hides 
the field when `countVectorizer` is off). Attribute names are 
`EncodableString`s, so the expected values are built with the production 
`PythonTemplateBuilder.wrapWithPythonDecoderExpr`, pinning the real base64 
decode expressions in the generated code.
   
   No production code is changed.
   
   ### Any related issues, documentation, discussions?
   
   Closes #7574
   
   ### How was this PR tested?
   
   This PR is itself test-only. The new specs were run with:
   
   ```
   sbt "WorkflowOperator/testOnly 
org.apache.texera.amber.operator.sklearn.SklearnClassifierOpDescCodegenSpec 
org.apache.texera.amber.operator.sklearn.training.SklearnTrainingOpDescCodegenSpec"
   ```
   
   All 8 tests pass. The suite was additionally mutation-checked: six manual 
template mutations (swapping the `CountVectorizer`/`TfidfTransformer` stage 
order, gating the text-column selection on the wrong flag, and ignoring the 
`tfidfTransformer` flag, in each base) each caused test failures, and the 
sources were restored afterwards. `scalafmtCheck` passes.
   
   ### Was this PR authored or co-authored using generative AI tooling?
   
   Co-authored by: Claude Code (Claude Fable 5)
   


-- 
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]

Reply via email to