You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@texera.apache.org by GitBox <gi...@apache.org> on 2026/07/29 09:48:23 UTC
[GH] (texera/backport/6805-splice-metric-list-verbatim-instead-of-d-v1.2): Workflow run "Required Checks" is working again!
The GitHub Actions job "Required Checks" on texera.git/backport/6805-splice-metric-list-verbatim-instead-of-d-v1.2 has succeeded.
Run started by GitHub user Yicong-Huang (triggered by Yicong-Huang).
Head commit for run:
b4ce5a081dc7d38086a6582914e8a8539fb3d36c / Kary Zheng <15...@users.noreply.github.com>
fix(MachineLearningScorer): splice metric_list verbatim instead of double-encoding (#6805)
### What changes were proposed in this PR?
Fixes a double-encoding bug in `MachineLearningScorerOpDesc` where the
selected metrics collapse into a single malformed `metric_list` element.
`getSelectedMetrics()` returns the chosen metric names as one
comma-separated, already-quoted fragment (e.g. `'Accuracy','F1 Score'`)
and is spliced into the generated Python as a list:
```
metric_list = [${getSelectedMetrics()}]
```
Its return type was **`EncodableString`**, so the Python template
builder **re-encoded the whole fragment as one Python string value**
instead of splicing it verbatim. The emitted code became:
```python
metric_list = [self.decode_python_template('J0FjY3VyYWN5JywnRjEgU2NvcmUn')]
```
where the base64 `J0FjY3VyYWN5JywnRjEgU2NvcmUn` decodes to
`'Accuracy','F1 Score'` — i.e. the entire quoted list collapses into
**one** decoded string element:
```python
metric_list = ["'Accuracy','F1 Score'"] # ONE element, incl. inner quotes
```
instead of the intended:
```python
metric_list = ['Accuracy', 'F1 Score']
```
So every downstream `if 'X' in metric_list` and `for metric in
metric_list` / `metrics_func[metric]` operates on that single malformed
element — the selected metrics are never matched, and the classification
path hits a `KeyError` on the bogus key. The Scorer produces wrong/empty
output for both the classification and regression paths.
**Fix:** change `getSelectedMetrics()`'s return type from
`EncodableString` to plain `String`, so the builder splices it verbatim
into `metric_list = ['Accuracy','F1 Score']`. The method body is
unchanged.
```diff
- private def getSelectedMetrics(): EncodableString = {
+ private def getSelectedMetrics(): String = {
val metric = if (isRegression) regressionMetrics else classificationMetrics
metric.map(metric => getMetricName(metric)).mkString("'", "','", "'")
}
```
### Any related issues, documentation, discussions?
Closes #6790
### How was this PR tested?
Added a regression test to `MachineLearningScorerOpDescSpec` that
constructs the descriptor with `classificationMetrics = List(accuracy,
f1Score)`, calls `generatePythonCode()`, and asserts:
- the emitted code contains `metric_list = ['Accuracy','F1 Score']`
(verbatim), and
- the metric names are **not** base64-re-encoded through the template
builder.
Both assertions fail on `main` (the line is emitted as `metric_list =
[self.decode_python_template('J0FjY3VyYWN5JywnRjEgU2NvcmUn')]`) and pass
with this change.
Ran the full suite locally:
```
sbt "WorkflowOperator/testOnly org.apache.texera.amber.operator.machineLearning.Scorer.MachineLearningScorerOpDescSpec"
...
Tests: succeeded 7, failed 0, canceled 0, ignored 0, pending 0
All tests passed.
```
### Was this PR authored or co-authored using generative AI tooling?
Generated-by: Claude Code (Claude Opus 4.8)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
(backported from commit 3a51bfb8761e96d10460f097b0e1803e27c2c5d0)
Co-authored-by: Claude Opus 4.8 (1M context) <no...@anthropic.com>
Report URL: https://github.com/apache/texera/actions/runs/30431368711
With regards,
GitHub Actions via GitBox