This is an automated email from the ASF dual-hosted git repository. github-merge-queue[bot] pushed a commit to branch gh-readonly-queue/main/pr-8764-5db1ca0e7fa20647216cbe573792360a1d368c78 in repository https://gitbox.apache.org/repos/asf/texera.git
commit e0fe77acf7506c2b6e185b9849cb71a5d5b4fdc6 Author: Kary Zheng <[email protected]> AuthorDate: Sat Oct 3 07:43:18 2026 +0000 feat(operator): refuse duplicate sklearn parameter rows on export too (#8764) ### What changes were proposed in this PR? The standalone export of the advanced sklearn trainers now runs the same distinct-parameter check as the engine path. Two rows naming one parameter used to emit the keyword twice, so the export reported success and the script then failed with a SyntaxError. The export now fails and names the parameter. ### Any related issues, documentation, discussions? Closes #8757. ### How was this PR tested? A new case in `SklearnAdvancedBaseDescSpec` exports an operator with two rows naming one parameter and expects the refusal. It fails without the change. ### Was this PR authored or co-authored using generative AI tooling? Generated-by: Claude Code (Claude Opus 5.5) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 <[email protected]> --- .../sklearnAdvanced/base/SklearnAdvancedBaseDesc.scala | 1 + .../sklearnAdvanced/base/SklearnAdvancedBaseDescSpec.scala | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/common/workflow-operator/src/main/scala/org/apache/texera/amber/operator/machineLearning/sklearnAdvanced/base/SklearnAdvancedBaseDesc.scala b/common/workflow-operator/src/main/scala/org/apache/texera/amber/operator/machineLearning/sklearnAdvanced/base/SklearnAdvancedBaseDesc.scala index 8ee4ba5898..7875a2fbb0 100644 --- a/common/workflow-operator/src/main/scala/org/apache/texera/amber/operator/machineLearning/sklearnAdvanced/base/SklearnAdvancedBaseDesc.scala +++ b/common/workflow-operator/src/main/scala/org/apache/texera/amber/operator/machineLearning/sklearnAdvanced/base/SklearnAdvancedBaseDesc.scala @@ -312,6 +312,7 @@ abstract class SklearnMLOperatorDescriptor[T <: ParamClass] * quotes (`table[col]`) and raise NameError. Returns (model-args, para_str). */ private def getParameterStandalone(paraList: List[HyperParameters[T]]): (String, String) = { + requireDistinctParameters(paraList) val workflowParam = new StringBuilder val portParam = new StringBuilder val paramString = new StringBuilder diff --git a/common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/machineLearning/sklearnAdvanced/base/SklearnAdvancedBaseDescSpec.scala b/common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/machineLearning/sklearnAdvanced/base/SklearnAdvancedBaseDescSpec.scala index 1d8550c51c..754c64ab5d 100644 --- a/common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/machineLearning/sklearnAdvanced/base/SklearnAdvancedBaseDescSpec.scala +++ b/common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/machineLearning/sklearnAdvanced/base/SklearnAdvancedBaseDescSpec.scala @@ -366,6 +366,17 @@ class SklearnAdvancedBaseDescSpec extends AnyFlatSpec with Matchers { thrown.getMessage should include("n_neighbors") } + it should "refuse two rows setting one parameter when the workflow is exported" in { + val d = newOp( + List( + hyperParam("n_neighbors", "int", fromWorkflow = false, value = "5"), + hyperParam("n_neighbors", "int", fromWorkflow = true, attribute = "k_col") + ) + ) + val thrown = the[IllegalArgumentException] thrownBy d.generateStandaloneCode() + thrown.getMessage should include("n_neighbors") + } + it should "accept rows setting different parameters" in { val d = new TestSklearnMLOp val paraList = List(
