The GitHub Actions job "Required Checks" on 
texera.git/gh-readonly-queue/main/pr-7577-d61214a689be3b83eaa27499efe7daa13de71671
 has failed.
Run started by GitHub user aglinxinyuan (triggered by aglinxinyuan).

Head commit for run:
e46564f178e86feab51255d785d67fe3d8a49df0 / Eugene Gu <[email protected]>
test(workflow-operator): cover the vectorizer branches of Sklearn code 
generation (#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)

Report URL: https://github.com/apache/texera/actions/runs/31665872838

With regards,
GitHub Actions via GitBox

Reply via email to