The GitHub Actions job "Required Checks" on texera.git/main has succeeded. Run started by GitHub user github-merge-queue[bot] (triggered by github-merge-queue[bot]).
Head commit for run: e5192c16fbb7d45fb6fbc8ce92c862fbf0902d27 / Xinyuan Lin <[email protected]> refactor(workflow-operator): share chart Python codegen (#9646) ### What changes were proposed in this PR? Share duplicated runtime (`generatePythonCode`) and standalone (`generateStandaloneCode`) Plotly Python code generation across four visualization operators in `common/workflow-operator` (`4` files, `+370/-574`, `-204` net lines): | File | Shared codegen | Net LOC | | --- | --- | ---: | | `NetworkGraphOpDesc.scala` | Extracts `NetworkGraphPython.body(indent)` for graph construction, seeded `spring_layout`, edge/node traces, and figure layout | `+107/-181` (-74) | | `BulletChartOpDesc.scala` | Extracts `deltaReferenceLiteral`, `thresholdLiteral`, `stepsLiteral`, and `BulletChartPython` (`helperDefs`, `stepsListBody`, `figureBody`) | `+97/-139` (-42) | | `TreePlotOpDesc.scala` | Extracts `TreePlotPython.annotationsBody`, `parseEdges`, and `figureBody` (reusing `PythonCodeFragment.render`) | `+94/-135` (-41) | | `ContinuousErrorBandsOpDesc.scala` | Extracts `buildFigure(tableVar, render, indent)`, a plain `s"..."` template whose `EncodableString => String` callback writes each typed-in value as a decode expression in the operator and a `pyStringLiteral` in the exported script | `+72/-119` (-47) | It also adds `RuntimeStandaloneParitySpec` (`+481`), tagged `NeedsPythonPackages`, which runs both paths of all four charts over the same tables (see below). Notes for reviewers: - Runtime `pyb` base64 encoding (`self.decode_python_template(...)`) and standalone `pyStringLiteral` escaping are preserved unchanged. - No existing operator tests were modified; all user-facing behavior and error messages remain identical. That includes the step error `BulletChartPython.helperDefs` writes, which reads `≥` in the operator and `>=` in the exported script, as on `main`. - `ContinuousErrorBandsOpDesc.createPlotlyFigure()` returns the figure already rendered in the operator's dialect, so its `.plain` now shows decode expressions too. Only `ContinuousErrorBandsOpDescSpec` reads that `.plain`, through `carries`, which accepts either form. ### Any related issues, documentation, discussions? Closes #9645 ### How was this PR tested? Verified on `a234e15d0d` (based on `origin/main` `95e2748b97`) with JDK 17 (Corretto 17.0.20.1), `sbt 1.12.9`, and Python 3.12.7 (`pandas 2.2.3`, `plotly 5.24.1`, `networkx 3.5`): ```bash sbt "WorkflowOperator/scalafixAll --check" "WorkflowOperator/scalafmtCheckAll" UDF_PYTHON_PATH=/path/to/python3.12 sbt \ "WorkflowOperator/testOnly *RuntimeStandaloneParitySpec *NetworkGraphOpDescSpec *BulletChartOpDescSpec *TreePlotOpDescSpec *ContinuousErrorBandsOpDescSpec *ColorPatternSpec *GaugeChartOpDescSpec *PythonCodeRawInvalidTextSpec" \ "WorkflowCompilingService/testOnly *WorkflowToPythonTranslatorSpec" ``` - **Lint / format:** `WorkflowOperator/scalafixAll --check` and `WorkflowOperator/scalafmtCheckAll` exit `0`. - **Unit tests:** - `WorkflowOperator`: `8` suites, `122` cases (`121` passed, `1` pre-existing `pendingUntilFixed` in `BulletChartOpDescSpec`, `0` failed, `0` canceled). `PythonCodeRawInvalidTextSpec` reports raw-invalid `118/118` and py-compile `118/118`. - `WorkflowCompilingService`: `WorkflowToPythonTranslatorSpec` `19/19` passed. - **Runtime/standalone parity:** `RuntimeStandaloneParitySpec` runs the operator code (pytexera stubbed, as in `TreePlotOpDescSpec`) and the exported script (placeholders bound, as in `GaugeChartOpDescSpec`) of all four charts. Each of its `10` cases expects the same figures, or the same refusal reason, from both paths and pins what they draw. Each chart has settings whose text carries a quote. - It passes unchanged with `main`'s four operator sources swapped in, so it pins the behavior this refactor preserves. - It fails when `dest_col` is left unbound in the Network Graph operator, when `edge_col` is left unbound in the Tree Plot export, and when the error band's upper and lower bounds are swapped in both paths. - After the second review, `662837bff4` gates the run on pandas and plotly only, since only the Network Graph code imports networkx, inside each path's `try`. With networkx hidden, the two Network Graph cases fail on the `ImportError` and the other eight pass. Its `source` now carries a quote too, and a `sourceLit` built without escaping fails the same two cases. `Test/scalafmtCheck` and `Test/scalafix --check` pass, and the spec passes 10/10 with none canceled. - **Generated code:** the review-round changes to `BulletChartOpDesc` and `ContinuousErrorBandsOpDesc` leave the operator code and the exported script byte-identical to `cd3fc253ee`, including settings with quotes, `|`, newlines and backslashes. ### Was this PR authored or co-authored using generative AI tooling? Generated-by: Antigravity Generated-by: Claude Code (Opus 5.5) --------- Co-authored-by: Claude Opus 5.5 <[email protected]> Report URL: https://github.com/apache/texera/actions/runs/45585354887 With regards, GitHub Actions via GitBox
