You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@texera.apache.org by "aglinxinyuan (via GitHub)" <gi...@apache.org> on 2026/05/03 04:11:09 UTC
[PR] test(workflow-operator): pin Sklearn OpDesc registry strings [texera]
aglinxinyuan opened a new pull request, #4827:
URL: https://github.com/apache/texera/pull/4827
### What changes were proposed in this PR?
Add `SklearnOpDescRegistrySpec` covering every concrete `SklearnClassifierOpDesc` (24 subclasses) and `SklearnTrainingOpDesc` (26 subclasses) with the exact `(importStatement, userFriendlyModelName)` pair each one returns. A typo in either string would silently misroute either the generated Python pipeline or the user-facing UI label; pinning them in one table makes that a test failure.
Also covers:
- `SklearnClassifierOpDesc` base default (empty strings)
- `SklearnTrainingOpDesc` base default (RandomForest)
- `generatePythonCode` smoke test for a classifier (`UDFOperatorV2`) and a training (`UDFTableOperator`) subclass, verifying the import string is embedded
### Any related issues, documentation, discussions?
Closes #4826
### How was this PR tested?
`sbt "WorkflowOperator/testOnly org.apache.texera.amber.operator.sklearn.SklearnOpDescRegistrySpec"` — 104/104 tests pass.
### Was this PR authored or co-authored using generative AI tooling?
Generated-by: Claude Code (Claude Opus 4.7)
--
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: notifications-unsubscribe@texera.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] test(workflow-operator): pin Sklearn OpDesc registry strings [texera]
Posted by "aglinxinyuan (via GitHub)" <gi...@apache.org>.
aglinxinyuan commented on code in PR #4827:
URL: https://github.com/apache/texera/pull/4827#discussion_r3177854293
##########
common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/sklearn/SklearnOpDescRegistrySpec.scala:
##########
@@ -0,0 +1,339 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.texera.amber.operator.sklearn
+
+import org.apache.texera.amber.operator.sklearn.training._
+import org.scalatest.flatspec.AnyFlatSpec
+
+/**
+ * Pins the wiring (Python import statement + user-friendly model name) for
+ * every concrete `SklearnClassifierOpDesc` and `SklearnTrainingOpDesc`. A
+ * typo in either string would silently misroute downstream UI labels and
+ * breakage of the generated Python pipeline.
+ */
+class SklearnOpDescRegistrySpec extends AnyFlatSpec {
+
+ // ---------------------------------------------------------------------------
+ // Classifier registry (24 concrete SklearnClassifierOpDesc subclasses)
+ // ---------------------------------------------------------------------------
+
+ private val classifierEntries: List[(SklearnClassifierOpDesc, String, String)] = List(
+ (
+ new SklearnAdaptiveBoostingOpDesc(),
+ "from sklearn.ensemble import AdaBoostClassifier",
+ "Adaptive Boosting"
+ ),
+ (new SklearnBaggingOpDesc(), "from sklearn.ensemble import BaggingClassifier", "Bagging"),
+ (
+ new SklearnBernoulliNaiveBayesOpDesc(),
+ "from sklearn.naive_bayes import BernoulliNB",
+ "Bernoulli Naive Bayes"
+ ),
+ (
+ new SklearnComplementNaiveBayesOpDesc(),
+ "from sklearn.naive_bayes import ComplementNB",
+ "Complement Naive Bayes"
+ ),
+ (
+ new SklearnDecisionTreeOpDesc(),
+ "from sklearn.tree import DecisionTreeClassifier",
+ "Decision Tree"
+ ),
+ (new SklearnExtraTreeOpDesc(), "from sklearn.tree import ExtraTreeClassifier", "Extra Tree"),
+ (
+ new SklearnExtraTreesOpDesc(),
+ "from sklearn.ensemble import ExtraTreesClassifier",
+ "Extra Trees"
+ ),
+ (
+ new SklearnGaussianNaiveBayesOpDesc(),
+ "from sklearn.naive_bayes import GaussianNB",
+ "Gaussian Naive Bayes"
+ ),
+ (
+ new SklearnGradientBoostingOpDesc(),
+ "from sklearn.ensemble import GradientBoostingClassifier",
+ "Gradient Boosting"
+ ),
+ (
+ new SklearnKNNOpDesc(),
+ "from sklearn.neighbors import KNeighborsClassifier",
+ "K-nearest Neighbors"
+ ),
+ (
+ new SklearnLinearSVMOpDesc(),
+ "from sklearn.svm import LinearSVC",
+ "Linear Support Vector Machine"
+ ),
+ (
+ new SklearnLogisticRegressionCVOpDesc(),
+ "from sklearn.linear_model import LogisticRegressionCV",
+ "Logistic Regression Cross Validation"
+ ),
+ (
+ new SklearnLogisticRegressionOpDesc(),
+ "from sklearn.linear_model import LogisticRegression",
+ "Logistic Regression"
+ ),
+ (
+ new SklearnMultiLayerPerceptronOpDesc(),
+ "from sklearn.neural_network import MLPClassifier",
+ "Multi-layer Perceptron"
+ ),
+ (
+ new SklearnMultinomialNaiveBayesOpDesc(),
+ "from sklearn.naive_bayes import MultinomialNB",
+ "Multinomial Naive Bayes"
+ ),
+ (
+ new SklearnNearestCentroidOpDesc(),
+ "from sklearn.neighbors import NearestCentroid",
+ "Nearest Centroid"
+ ),
+ (
+ new SklearnPassiveAggressiveOpDesc(),
+ "from sklearn.linear_model import PassiveAggressiveClassifier",
+ "Passive Aggressive"
+ ),
+ (
+ new SklearnPerceptronOpDesc(),
+ "from sklearn.linear_model import Perceptron",
+ "Linear Perceptron"
+ ),
+ (
+ new SklearnProbabilityCalibrationOpDesc(),
+ "from sklearn.calibration import CalibratedClassifierCV",
+ "Probability Calibration"
+ ),
+ (
+ new SklearnRandomForestOpDesc(),
+ "from sklearn.ensemble import RandomForestClassifier",
+ "Random Forest"
+ ),
+ (
+ new SklearnRidgeCVOpDesc(),
+ "from sklearn.linear_model import RidgeClassifierCV",
+ "Ridge Regression Cross Validation"
+ ),
+ (
+ new SklearnRidgeOpDesc(),
+ "from sklearn.linear_model import RidgeClassifier",
+ "Ridge Regression"
+ ),
+ (
+ new SklearnSDGOpDesc(),
+ "from sklearn.linear_model import SGDClassifier",
+ "Stochastic Gradient Descent"
+ ),
+ (new SklearnSVMOpDesc(), "from sklearn.svm import SVC", "Support Vector Machine")
+ )
+
+ classifierEntries.foreach {
+ case (desc, expectedImport, expectedName) =>
+ val cls = desc.getClass.getSimpleName
+ cls should s"return import statement '$expectedImport'" in {
+ assert(desc.getImportStatements == expectedImport)
+ }
+ it should s"return user-friendly model name '$expectedName'" in {
+ assert(desc.getUserFriendlyModelName == expectedName)
+ }
+ }
+
+ "SklearnClassifierOpDesc base class" should "default to empty strings before subclass overrides" in {
+ val anonymous = new SklearnClassifierOpDesc {}
+ assert(anonymous.getImportStatements == "")
+ assert(anonymous.getUserFriendlyModelName == "")
+ }
+
+ it should "embed the import statement into generatePythonCode for a concrete subclass" in {
+ val desc = new SklearnLogisticRegressionOpDesc()
+ desc.target = "y"
+ desc.countVectorizer = false
+ // `tfidfTransformer` is a val on the base class, defaults to false.
+ val code = desc.generatePythonCode()
+ assert(code.contains("from sklearn.linear_model import LogisticRegression"))
+ // Classifier OpDescs emit a UDFTableOperator pipeline.
+ assert(code.contains("ProcessTableOperator"))
+ }
+
+ // ---------------------------------------------------------------------------
+ // Training registry (26 concrete SklearnTrainingOpDesc subclasses)
+ // ---------------------------------------------------------------------------
+
+ private val trainingEntries: List[(SklearnTrainingOpDesc, String, String)] = List(
+ (
+ new SklearnTrainingAdaptiveBoostingOpDesc(),
+ "from sklearn.ensemble import AdaBoostClassifier",
+ "Training: Adaptive Boosting"
+ ),
+ (
+ new SklearnTrainingBaggingOpDesc(),
+ "from sklearn.ensemble import BaggingClassifier",
+ "Training: Bagging Training" // current source value (typo-style duplication preserved)
Review Comment:
Done in d37d1ae5e8 — corrected the `getUserFriendlyModelName` to `Training: Bagging` to match the rest of the SklearnTraining* registry pattern, and updated the spec expectation accordingly.
--
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: notifications-unsubscribe@texera.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] test(workflow-operator): pin Sklearn OpDesc registry strings [texera]
Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #4827:
URL: https://github.com/apache/texera/pull/4827#discussion_r3177614123
##########
common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/sklearn/SklearnOpDescRegistrySpec.scala:
##########
@@ -0,0 +1,339 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.texera.amber.operator.sklearn
+
+import org.apache.texera.amber.operator.sklearn.training._
+import org.scalatest.flatspec.AnyFlatSpec
+
+/**
+ * Pins the wiring (Python import statement + user-friendly model name) for
+ * every concrete `SklearnClassifierOpDesc` and `SklearnTrainingOpDesc`. A
+ * typo in either string would silently misroute downstream UI labels and
+ * breakage of the generated Python pipeline.
+ */
+class SklearnOpDescRegistrySpec extends AnyFlatSpec {
+
+ // ---------------------------------------------------------------------------
+ // Classifier registry (24 concrete SklearnClassifierOpDesc subclasses)
+ // ---------------------------------------------------------------------------
+
+ private val classifierEntries: List[(SklearnClassifierOpDesc, String, String)] = List(
+ (
+ new SklearnAdaptiveBoostingOpDesc(),
+ "from sklearn.ensemble import AdaBoostClassifier",
+ "Adaptive Boosting"
+ ),
+ (new SklearnBaggingOpDesc(), "from sklearn.ensemble import BaggingClassifier", "Bagging"),
+ (
+ new SklearnBernoulliNaiveBayesOpDesc(),
Review Comment:
`classifierEntries` is missing `SklearnDummyClassifierOpDesc`, even though `SklearnDummyClassifierOpDesc` is a concrete `SklearnClassifierOpDesc` subclass (see `.../SklearnDummyClassifierOpDesc.scala`). This means the spec does not currently pin the import/name wiring for all concrete classifiers, and the header comment claiming 24 subclasses is also out of date (there are 25). Add the missing entry (and update the count comment) so a typo in that OpDesc is caught by this test suite.
##########
common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/sklearn/SklearnOpDescRegistrySpec.scala:
##########
@@ -0,0 +1,339 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.texera.amber.operator.sklearn
+
+import org.apache.texera.amber.operator.sklearn.training._
+import org.scalatest.flatspec.AnyFlatSpec
+
+/**
+ * Pins the wiring (Python import statement + user-friendly model name) for
+ * every concrete `SklearnClassifierOpDesc` and `SklearnTrainingOpDesc`. A
+ * typo in either string would silently misroute downstream UI labels and
+ * breakage of the generated Python pipeline.
+ */
+class SklearnOpDescRegistrySpec extends AnyFlatSpec {
+
+ // ---------------------------------------------------------------------------
+ // Classifier registry (24 concrete SklearnClassifierOpDesc subclasses)
+ // ---------------------------------------------------------------------------
+
+ private val classifierEntries: List[(SklearnClassifierOpDesc, String, String)] = List(
+ (
+ new SklearnAdaptiveBoostingOpDesc(),
+ "from sklearn.ensemble import AdaBoostClassifier",
+ "Adaptive Boosting"
+ ),
+ (new SklearnBaggingOpDesc(), "from sklearn.ensemble import BaggingClassifier", "Bagging"),
+ (
+ new SklearnBernoulliNaiveBayesOpDesc(),
+ "from sklearn.naive_bayes import BernoulliNB",
+ "Bernoulli Naive Bayes"
+ ),
+ (
+ new SklearnComplementNaiveBayesOpDesc(),
+ "from sklearn.naive_bayes import ComplementNB",
+ "Complement Naive Bayes"
+ ),
+ (
+ new SklearnDecisionTreeOpDesc(),
+ "from sklearn.tree import DecisionTreeClassifier",
+ "Decision Tree"
+ ),
+ (new SklearnExtraTreeOpDesc(), "from sklearn.tree import ExtraTreeClassifier", "Extra Tree"),
+ (
+ new SklearnExtraTreesOpDesc(),
+ "from sklearn.ensemble import ExtraTreesClassifier",
+ "Extra Trees"
+ ),
+ (
+ new SklearnGaussianNaiveBayesOpDesc(),
+ "from sklearn.naive_bayes import GaussianNB",
+ "Gaussian Naive Bayes"
+ ),
+ (
+ new SklearnGradientBoostingOpDesc(),
+ "from sklearn.ensemble import GradientBoostingClassifier",
+ "Gradient Boosting"
+ ),
+ (
+ new SklearnKNNOpDesc(),
+ "from sklearn.neighbors import KNeighborsClassifier",
+ "K-nearest Neighbors"
+ ),
+ (
+ new SklearnLinearSVMOpDesc(),
+ "from sklearn.svm import LinearSVC",
+ "Linear Support Vector Machine"
+ ),
+ (
+ new SklearnLogisticRegressionCVOpDesc(),
+ "from sklearn.linear_model import LogisticRegressionCV",
+ "Logistic Regression Cross Validation"
+ ),
+ (
+ new SklearnLogisticRegressionOpDesc(),
+ "from sklearn.linear_model import LogisticRegression",
+ "Logistic Regression"
+ ),
+ (
+ new SklearnMultiLayerPerceptronOpDesc(),
+ "from sklearn.neural_network import MLPClassifier",
+ "Multi-layer Perceptron"
+ ),
+ (
+ new SklearnMultinomialNaiveBayesOpDesc(),
+ "from sklearn.naive_bayes import MultinomialNB",
+ "Multinomial Naive Bayes"
+ ),
+ (
+ new SklearnNearestCentroidOpDesc(),
+ "from sklearn.neighbors import NearestCentroid",
+ "Nearest Centroid"
+ ),
+ (
+ new SklearnPassiveAggressiveOpDesc(),
+ "from sklearn.linear_model import PassiveAggressiveClassifier",
+ "Passive Aggressive"
+ ),
+ (
+ new SklearnPerceptronOpDesc(),
+ "from sklearn.linear_model import Perceptron",
+ "Linear Perceptron"
+ ),
+ (
+ new SklearnProbabilityCalibrationOpDesc(),
+ "from sklearn.calibration import CalibratedClassifierCV",
+ "Probability Calibration"
+ ),
+ (
+ new SklearnRandomForestOpDesc(),
+ "from sklearn.ensemble import RandomForestClassifier",
+ "Random Forest"
+ ),
+ (
+ new SklearnRidgeCVOpDesc(),
+ "from sklearn.linear_model import RidgeClassifierCV",
+ "Ridge Regression Cross Validation"
+ ),
+ (
+ new SklearnRidgeOpDesc(),
+ "from sklearn.linear_model import RidgeClassifier",
+ "Ridge Regression"
+ ),
+ (
+ new SklearnSDGOpDesc(),
+ "from sklearn.linear_model import SGDClassifier",
+ "Stochastic Gradient Descent"
+ ),
+ (new SklearnSVMOpDesc(), "from sklearn.svm import SVC", "Support Vector Machine")
+ )
+
+ classifierEntries.foreach {
+ case (desc, expectedImport, expectedName) =>
+ val cls = desc.getClass.getSimpleName
+ cls should s"return import statement '$expectedImport'" in {
+ assert(desc.getImportStatements == expectedImport)
+ }
+ it should s"return user-friendly model name '$expectedName'" in {
+ assert(desc.getUserFriendlyModelName == expectedName)
+ }
+ }
+
+ "SklearnClassifierOpDesc base class" should "default to empty strings before subclass overrides" in {
+ val anonymous = new SklearnClassifierOpDesc {}
+ assert(anonymous.getImportStatements == "")
+ assert(anonymous.getUserFriendlyModelName == "")
+ }
+
+ it should "embed the import statement into generatePythonCode for a concrete subclass" in {
+ val desc = new SklearnLogisticRegressionOpDesc()
+ desc.target = "y"
+ desc.countVectorizer = false
+ // `tfidfTransformer` is a val on the base class, defaults to false.
+ val code = desc.generatePythonCode()
+ assert(code.contains("from sklearn.linear_model import LogisticRegression"))
+ // Classifier OpDescs emit a UDFTableOperator pipeline.
+ assert(code.contains("ProcessTableOperator"))
+ }
+
+ // ---------------------------------------------------------------------------
+ // Training registry (26 concrete SklearnTrainingOpDesc subclasses)
+ // ---------------------------------------------------------------------------
+
+ private val trainingEntries: List[(SklearnTrainingOpDesc, String, String)] = List(
+ (
+ new SklearnTrainingAdaptiveBoostingOpDesc(),
+ "from sklearn.ensemble import AdaBoostClassifier",
+ "Training: Adaptive Boosting"
+ ),
+ (
+ new SklearnTrainingBaggingOpDesc(),
+ "from sklearn.ensemble import BaggingClassifier",
+ "Training: Bagging Training" // current source value (typo-style duplication preserved)
Review Comment:
`SklearnTrainingBaggingOpDesc` is pinned to the user-facing name `Training: Bagging Training` (duplicated word). If this duplication is unintended (as the inline comment suggests), it's better to fix the OpDesc and update the expected value here; otherwise the new test will make it easy to accidentally keep shipping the typo because any correction will start failing CI.
##########
common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/sklearn/SklearnOpDescRegistrySpec.scala:
##########
@@ -0,0 +1,339 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.texera.amber.operator.sklearn
+
+import org.apache.texera.amber.operator.sklearn.training._
+import org.scalatest.flatspec.AnyFlatSpec
+
+/**
+ * Pins the wiring (Python import statement + user-friendly model name) for
+ * every concrete `SklearnClassifierOpDesc` and `SklearnTrainingOpDesc`. A
+ * typo in either string would silently misroute downstream UI labels and
+ * breakage of the generated Python pipeline.
+ */
+class SklearnOpDescRegistrySpec extends AnyFlatSpec {
+
+ // ---------------------------------------------------------------------------
+ // Classifier registry (24 concrete SklearnClassifierOpDesc subclasses)
+ // ---------------------------------------------------------------------------
+
+ private val classifierEntries: List[(SklearnClassifierOpDesc, String, String)] = List(
+ (
+ new SklearnAdaptiveBoostingOpDesc(),
+ "from sklearn.ensemble import AdaBoostClassifier",
+ "Adaptive Boosting"
+ ),
+ (new SklearnBaggingOpDesc(), "from sklearn.ensemble import BaggingClassifier", "Bagging"),
+ (
+ new SklearnBernoulliNaiveBayesOpDesc(),
+ "from sklearn.naive_bayes import BernoulliNB",
+ "Bernoulli Naive Bayes"
+ ),
+ (
+ new SklearnComplementNaiveBayesOpDesc(),
+ "from sklearn.naive_bayes import ComplementNB",
+ "Complement Naive Bayes"
+ ),
+ (
+ new SklearnDecisionTreeOpDesc(),
+ "from sklearn.tree import DecisionTreeClassifier",
+ "Decision Tree"
+ ),
+ (new SklearnExtraTreeOpDesc(), "from sklearn.tree import ExtraTreeClassifier", "Extra Tree"),
+ (
+ new SklearnExtraTreesOpDesc(),
+ "from sklearn.ensemble import ExtraTreesClassifier",
+ "Extra Trees"
+ ),
+ (
+ new SklearnGaussianNaiveBayesOpDesc(),
+ "from sklearn.naive_bayes import GaussianNB",
+ "Gaussian Naive Bayes"
+ ),
+ (
+ new SklearnGradientBoostingOpDesc(),
+ "from sklearn.ensemble import GradientBoostingClassifier",
+ "Gradient Boosting"
+ ),
+ (
+ new SklearnKNNOpDesc(),
+ "from sklearn.neighbors import KNeighborsClassifier",
+ "K-nearest Neighbors"
+ ),
+ (
+ new SklearnLinearSVMOpDesc(),
+ "from sklearn.svm import LinearSVC",
+ "Linear Support Vector Machine"
+ ),
+ (
+ new SklearnLogisticRegressionCVOpDesc(),
+ "from sklearn.linear_model import LogisticRegressionCV",
+ "Logistic Regression Cross Validation"
+ ),
+ (
+ new SklearnLogisticRegressionOpDesc(),
+ "from sklearn.linear_model import LogisticRegression",
+ "Logistic Regression"
+ ),
+ (
+ new SklearnMultiLayerPerceptronOpDesc(),
+ "from sklearn.neural_network import MLPClassifier",
+ "Multi-layer Perceptron"
+ ),
+ (
+ new SklearnMultinomialNaiveBayesOpDesc(),
+ "from sklearn.naive_bayes import MultinomialNB",
+ "Multinomial Naive Bayes"
+ ),
+ (
+ new SklearnNearestCentroidOpDesc(),
+ "from sklearn.neighbors import NearestCentroid",
+ "Nearest Centroid"
+ ),
+ (
+ new SklearnPassiveAggressiveOpDesc(),
+ "from sklearn.linear_model import PassiveAggressiveClassifier",
+ "Passive Aggressive"
+ ),
+ (
+ new SklearnPerceptronOpDesc(),
+ "from sklearn.linear_model import Perceptron",
+ "Linear Perceptron"
+ ),
+ (
+ new SklearnProbabilityCalibrationOpDesc(),
+ "from sklearn.calibration import CalibratedClassifierCV",
+ "Probability Calibration"
+ ),
+ (
+ new SklearnRandomForestOpDesc(),
+ "from sklearn.ensemble import RandomForestClassifier",
+ "Random Forest"
+ ),
+ (
+ new SklearnRidgeCVOpDesc(),
+ "from sklearn.linear_model import RidgeClassifierCV",
+ "Ridge Regression Cross Validation"
+ ),
+ (
+ new SklearnRidgeOpDesc(),
+ "from sklearn.linear_model import RidgeClassifier",
+ "Ridge Regression"
+ ),
+ (
+ new SklearnSDGOpDesc(),
+ "from sklearn.linear_model import SGDClassifier",
+ "Stochastic Gradient Descent"
+ ),
+ (new SklearnSVMOpDesc(), "from sklearn.svm import SVC", "Support Vector Machine")
+ )
+
+ classifierEntries.foreach {
+ case (desc, expectedImport, expectedName) =>
+ val cls = desc.getClass.getSimpleName
+ cls should s"return import statement '$expectedImport'" in {
+ assert(desc.getImportStatements == expectedImport)
+ }
+ it should s"return user-friendly model name '$expectedName'" in {
+ assert(desc.getUserFriendlyModelName == expectedName)
+ }
+ }
+
+ "SklearnClassifierOpDesc base class" should "default to empty strings before subclass overrides" in {
+ val anonymous = new SklearnClassifierOpDesc {}
+ assert(anonymous.getImportStatements == "")
+ assert(anonymous.getUserFriendlyModelName == "")
+ }
+
+ it should "embed the import statement into generatePythonCode for a concrete subclass" in {
+ val desc = new SklearnLogisticRegressionOpDesc()
+ desc.target = "y"
+ desc.countVectorizer = false
+ // `tfidfTransformer` is a val on the base class, defaults to false.
+ val code = desc.generatePythonCode()
+ assert(code.contains("from sklearn.linear_model import LogisticRegression"))
+ // Classifier OpDescs emit a UDFTableOperator pipeline.
+ assert(code.contains("ProcessTableOperator"))
+ }
+
+ // ---------------------------------------------------------------------------
+ // Training registry (26 concrete SklearnTrainingOpDesc subclasses)
+ // ---------------------------------------------------------------------------
+
+ private val trainingEntries: List[(SklearnTrainingOpDesc, String, String)] = List(
+ (
+ new SklearnTrainingAdaptiveBoostingOpDesc(),
+ "from sklearn.ensemble import AdaBoostClassifier",
+ "Training: Adaptive Boosting"
+ ),
+ (
+ new SklearnTrainingBaggingOpDesc(),
+ "from sklearn.ensemble import BaggingClassifier",
+ "Training: Bagging Training" // current source value (typo-style duplication preserved)
+ ),
+ (
+ new SklearnTrainingBernoulliNaiveBayesOpDesc(),
+ "from sklearn.naive_bayes import BernoulliNB",
+ "Training: Bernoulli Naive Bayes"
+ ),
+ (
+ new SklearnTrainingComplementNaiveBayesOpDesc(),
+ "from sklearn.naive_bayes import ComplementNB",
+ "Training: Complement Naive Bayes"
+ ),
+ (
+ new SklearnTrainingDecisionTreeOpDesc(),
+ "from sklearn.tree import DecisionTreeClassifier",
+ "Training: Decision Tree"
+ ),
+ (
+ new SklearnTrainingDummyClassifierOpDesc(),
+ "from sklearn.dummy import dummy", // current source value (typo preserved — should be DummyClassifier)
Review Comment:
The expected import string for `SklearnTrainingDummyClassifierOpDesc` is pinned to `from sklearn.dummy import dummy`, which is not a valid scikit-learn import (the symbol is `DummyClassifier`). Keeping this expectation will lock in a runtime-breaking generated Python pipeline for the DummyClassifier operators; consider fixing the underlying OpDesc(s) to use the correct import and updating this spec accordingly, rather than preserving the typo.
--
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: notifications-unsubscribe@texera.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] test(workflow-operator): pin Sklearn OpDesc registry strings [texera]
Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #4827:
URL: https://github.com/apache/texera/pull/4827#discussion_r3180290488
##########
common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/sklearn/SklearnOpDescRegistrySpec.scala:
##########
@@ -0,0 +1,346 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.texera.amber.operator.sklearn
+
+import org.apache.texera.amber.operator.sklearn.training._
+import org.scalatest.flatspec.AnyFlatSpec
+
+/**
+ * Pins the wiring (Python import statement + user-friendly model name) for
+ * every concrete `SklearnClassifierOpDesc` and `SklearnTrainingOpDesc`. A
+ * typo in either string would silently misroute downstream UI labels and
+ * breakage of the generated Python pipeline.
+ */
+class SklearnOpDescRegistrySpec extends AnyFlatSpec {
+
+ // ---------------------------------------------------------------------------
+ // Classifier registry (25 concrete SklearnClassifierOpDesc subclasses)
+ // ---------------------------------------------------------------------------
+
+ private val classifierEntries: List[(SklearnClassifierOpDesc, String, String)] = List(
+ (
+ new SklearnAdaptiveBoostingOpDesc(),
+ "from sklearn.ensemble import AdaBoostClassifier",
+ "Adaptive Boosting"
Review Comment:
This spec relies on the manually-maintained `classifierEntries`/`trainingEntries` lists but does not assert that they cover *all* non-abstract `SklearnClassifierOpDesc` / `SklearnTrainingOpDesc` subclasses on the classpath. As a result, adding a new OpDesc could silently bypass this registry test. Consider adding a completeness assertion by scanning for concrete subclasses (similar to `PythonReflectionUtils.scanCandidates`/`PythonCodeRawInvalidTextSpec`) and comparing the discovered class set to the table entries.
##########
common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/sklearn/SklearnOpDescRegistrySpec.scala:
##########
@@ -0,0 +1,346 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.texera.amber.operator.sklearn
+
+import org.apache.texera.amber.operator.sklearn.training._
+import org.scalatest.flatspec.AnyFlatSpec
+
+/**
+ * Pins the wiring (Python import statement + user-friendly model name) for
+ * every concrete `SklearnClassifierOpDesc` and `SklearnTrainingOpDesc`. A
+ * typo in either string would silently misroute downstream UI labels and
+ * breakage of the generated Python pipeline.
+ */
+class SklearnOpDescRegistrySpec extends AnyFlatSpec {
+
+ // ---------------------------------------------------------------------------
+ // Classifier registry (25 concrete SklearnClassifierOpDesc subclasses)
+ // ---------------------------------------------------------------------------
+
+ private val classifierEntries: List[(SklearnClassifierOpDesc, String, String)] = List(
+ (
+ new SklearnAdaptiveBoostingOpDesc(),
+ "from sklearn.ensemble import AdaBoostClassifier",
+ "Adaptive Boosting"
+ ),
+ (new SklearnBaggingOpDesc(), "from sklearn.ensemble import BaggingClassifier", "Bagging"),
+ (
+ new SklearnBernoulliNaiveBayesOpDesc(),
+ "from sklearn.naive_bayes import BernoulliNB",
+ "Bernoulli Naive Bayes"
+ ),
+ (
+ new SklearnComplementNaiveBayesOpDesc(),
+ "from sklearn.naive_bayes import ComplementNB",
+ "Complement Naive Bayes"
+ ),
+ (
+ new SklearnDummyClassifierOpDesc(),
+ "from sklearn.dummy import DummyClassifier",
+ "Dummy Classifier"
+ ),
+ (
+ new SklearnDecisionTreeOpDesc(),
+ "from sklearn.tree import DecisionTreeClassifier",
+ "Decision Tree"
+ ),
+ (new SklearnExtraTreeOpDesc(), "from sklearn.tree import ExtraTreeClassifier", "Extra Tree"),
+ (
+ new SklearnExtraTreesOpDesc(),
+ "from sklearn.ensemble import ExtraTreesClassifier",
+ "Extra Trees"
+ ),
+ (
+ new SklearnGaussianNaiveBayesOpDesc(),
+ "from sklearn.naive_bayes import GaussianNB",
+ "Gaussian Naive Bayes"
+ ),
+ (
+ new SklearnGradientBoostingOpDesc(),
+ "from sklearn.ensemble import GradientBoostingClassifier",
+ "Gradient Boosting"
+ ),
+ (
+ new SklearnKNNOpDesc(),
+ "from sklearn.neighbors import KNeighborsClassifier",
+ "K-nearest Neighbors"
+ ),
+ (
+ new SklearnLinearSVMOpDesc(),
+ "from sklearn.svm import LinearSVC",
+ "Linear Support Vector Machine"
+ ),
+ (
+ new SklearnLogisticRegressionCVOpDesc(),
+ "from sklearn.linear_model import LogisticRegressionCV",
+ "Logistic Regression Cross Validation"
+ ),
+ (
+ new SklearnLogisticRegressionOpDesc(),
+ "from sklearn.linear_model import LogisticRegression",
+ "Logistic Regression"
+ ),
+ (
+ new SklearnMultiLayerPerceptronOpDesc(),
+ "from sklearn.neural_network import MLPClassifier",
+ "Multi-layer Perceptron"
+ ),
+ (
+ new SklearnMultinomialNaiveBayesOpDesc(),
+ "from sklearn.naive_bayes import MultinomialNB",
+ "Multinomial Naive Bayes"
+ ),
+ (
+ new SklearnNearestCentroidOpDesc(),
+ "from sklearn.neighbors import NearestCentroid",
+ "Nearest Centroid"
+ ),
+ (
+ new SklearnPassiveAggressiveOpDesc(),
+ "from sklearn.linear_model import PassiveAggressiveClassifier",
+ "Passive Aggressive"
+ ),
+ (
+ new SklearnPerceptronOpDesc(),
+ "from sklearn.linear_model import Perceptron",
+ "Linear Perceptron"
+ ),
+ (
+ new SklearnProbabilityCalibrationOpDesc(),
+ "from sklearn.calibration import CalibratedClassifierCV",
+ "Probability Calibration"
+ ),
+ (
+ new SklearnRandomForestOpDesc(),
+ "from sklearn.ensemble import RandomForestClassifier",
+ "Random Forest"
+ ),
+ (
+ new SklearnRidgeCVOpDesc(),
+ "from sklearn.linear_model import RidgeClassifierCV",
+ "Ridge Regression Cross Validation"
+ ),
+ (
+ new SklearnRidgeOpDesc(),
+ "from sklearn.linear_model import RidgeClassifier",
+ "Ridge Regression"
+ ),
+ (
+ new SklearnSDGOpDesc(),
+ "from sklearn.linear_model import SGDClassifier",
+ "Stochastic Gradient Descent"
+ ),
+ (new SklearnSVMOpDesc(), "from sklearn.svm import SVC", "Support Vector Machine")
+ )
+
+ classifierEntries.foreach {
+ case (desc, expectedImport, expectedName) =>
+ val cls = desc.getClass.getSimpleName
+ cls should s"return import statement '$expectedImport'" in {
+ assert(desc.getImportStatements == expectedImport)
+ }
+ it should s"return user-friendly model name '$expectedName'" in {
+ assert(desc.getUserFriendlyModelName == expectedName)
+ }
+ }
+
+ "SklearnClassifierOpDesc" should "embed the import statement into generatePythonCode for a concrete subclass" in {
+ val desc = new SklearnLogisticRegressionOpDesc()
+ desc.target = "y"
+ desc.countVectorizer = false
+ // `tfidfTransformer` is a val on the base class, defaults to false.
+ val code = desc.generatePythonCode()
+ assert(code.contains("from sklearn.linear_model import LogisticRegression"))
+ // Classifier OpDescs emit a UDFTableOperator pipeline.
+ assert(code.contains("ProcessTableOperator"))
+ }
+ // NOTE: the abstract base class's empty-string defaults are NOT tested here.
+ // Instantiating `SklearnClassifierOpDesc` from this spec (e.g. via
+ // `new SklearnClassifierOpDesc {}`) creates an anonymous test-package class
+ // under `org.apache.texera.amber.operator.sklearn`, which the
+ // PythonCodeRawInvalidTextSpec classpath scan then picks up as a descriptor
+ // candidate and fails on (anonymous classes have no accessible no-arg
+ // constructor). Every concrete subclass below overrides both methods, so
+ // the base default is never observable in production anyway.
Review Comment:
The PR description / linked issue explicitly calls out testing `SklearnClassifierOpDesc` base defaults (empty strings), but this spec currently documents that those defaults are NOT tested. Either add a safe way to test the base defaults (e.g., a small concrete test subclass in a non-scanned package so it won’t be picked up by `PythonCodeRawInvalidTextSpec`) or update the PR description/issue expectations to match reality.
##########
common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/sklearn/SklearnOpDescRegistrySpec.scala:
##########
@@ -0,0 +1,346 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.texera.amber.operator.sklearn
+
+import org.apache.texera.amber.operator.sklearn.training._
+import org.scalatest.flatspec.AnyFlatSpec
+
+/**
+ * Pins the wiring (Python import statement + user-friendly model name) for
+ * every concrete `SklearnClassifierOpDesc` and `SklearnTrainingOpDesc`. A
+ * typo in either string would silently misroute downstream UI labels and
+ * breakage of the generated Python pipeline.
Review Comment:
Minor grammar: “would silently misroute downstream UI labels and breakage of the generated Python pipeline” reads ungrammatically. Consider rephrasing to “...labels and cause breakage of...” (or similar) for clarity.
--
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: notifications-unsubscribe@texera.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] test(workflow-operator): pin Sklearn OpDesc registry strings [texera]
Posted by "aglinxinyuan (via GitHub)" <gi...@apache.org>.
aglinxinyuan commented on code in PR #4827:
URL: https://github.com/apache/texera/pull/4827#discussion_r3177853914
##########
common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/sklearn/SklearnOpDescRegistrySpec.scala:
##########
@@ -0,0 +1,339 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.texera.amber.operator.sklearn
+
+import org.apache.texera.amber.operator.sklearn.training._
+import org.scalatest.flatspec.AnyFlatSpec
+
+/**
+ * Pins the wiring (Python import statement + user-friendly model name) for
+ * every concrete `SklearnClassifierOpDesc` and `SklearnTrainingOpDesc`. A
+ * typo in either string would silently misroute downstream UI labels and
+ * breakage of the generated Python pipeline.
+ */
+class SklearnOpDescRegistrySpec extends AnyFlatSpec {
+
+ // ---------------------------------------------------------------------------
+ // Classifier registry (24 concrete SklearnClassifierOpDesc subclasses)
+ // ---------------------------------------------------------------------------
+
+ private val classifierEntries: List[(SklearnClassifierOpDesc, String, String)] = List(
+ (
+ new SklearnAdaptiveBoostingOpDesc(),
+ "from sklearn.ensemble import AdaBoostClassifier",
+ "Adaptive Boosting"
+ ),
+ (new SklearnBaggingOpDesc(), "from sklearn.ensemble import BaggingClassifier", "Bagging"),
+ (
+ new SklearnBernoulliNaiveBayesOpDesc(),
Review Comment:
Done in d37d1ae5e8 — added `SklearnDummyClassifierOpDesc` to `classifierEntries` and updated the comment to reflect 25 subclasses.
##########
common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/sklearn/SklearnOpDescRegistrySpec.scala:
##########
@@ -0,0 +1,339 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.texera.amber.operator.sklearn
+
+import org.apache.texera.amber.operator.sklearn.training._
+import org.scalatest.flatspec.AnyFlatSpec
+
+/**
+ * Pins the wiring (Python import statement + user-friendly model name) for
+ * every concrete `SklearnClassifierOpDesc` and `SklearnTrainingOpDesc`. A
+ * typo in either string would silently misroute downstream UI labels and
+ * breakage of the generated Python pipeline.
+ */
+class SklearnOpDescRegistrySpec extends AnyFlatSpec {
+
+ // ---------------------------------------------------------------------------
+ // Classifier registry (24 concrete SklearnClassifierOpDesc subclasses)
+ // ---------------------------------------------------------------------------
+
+ private val classifierEntries: List[(SklearnClassifierOpDesc, String, String)] = List(
+ (
+ new SklearnAdaptiveBoostingOpDesc(),
+ "from sklearn.ensemble import AdaBoostClassifier",
+ "Adaptive Boosting"
+ ),
+ (new SklearnBaggingOpDesc(), "from sklearn.ensemble import BaggingClassifier", "Bagging"),
+ (
+ new SklearnBernoulliNaiveBayesOpDesc(),
+ "from sklearn.naive_bayes import BernoulliNB",
+ "Bernoulli Naive Bayes"
+ ),
+ (
+ new SklearnComplementNaiveBayesOpDesc(),
+ "from sklearn.naive_bayes import ComplementNB",
+ "Complement Naive Bayes"
+ ),
+ (
+ new SklearnDecisionTreeOpDesc(),
+ "from sklearn.tree import DecisionTreeClassifier",
+ "Decision Tree"
+ ),
+ (new SklearnExtraTreeOpDesc(), "from sklearn.tree import ExtraTreeClassifier", "Extra Tree"),
+ (
+ new SklearnExtraTreesOpDesc(),
+ "from sklearn.ensemble import ExtraTreesClassifier",
+ "Extra Trees"
+ ),
+ (
+ new SklearnGaussianNaiveBayesOpDesc(),
+ "from sklearn.naive_bayes import GaussianNB",
+ "Gaussian Naive Bayes"
+ ),
+ (
+ new SklearnGradientBoostingOpDesc(),
+ "from sklearn.ensemble import GradientBoostingClassifier",
+ "Gradient Boosting"
+ ),
+ (
+ new SklearnKNNOpDesc(),
+ "from sklearn.neighbors import KNeighborsClassifier",
+ "K-nearest Neighbors"
+ ),
+ (
+ new SklearnLinearSVMOpDesc(),
+ "from sklearn.svm import LinearSVC",
+ "Linear Support Vector Machine"
+ ),
+ (
+ new SklearnLogisticRegressionCVOpDesc(),
+ "from sklearn.linear_model import LogisticRegressionCV",
+ "Logistic Regression Cross Validation"
+ ),
+ (
+ new SklearnLogisticRegressionOpDesc(),
+ "from sklearn.linear_model import LogisticRegression",
+ "Logistic Regression"
+ ),
+ (
+ new SklearnMultiLayerPerceptronOpDesc(),
+ "from sklearn.neural_network import MLPClassifier",
+ "Multi-layer Perceptron"
+ ),
+ (
+ new SklearnMultinomialNaiveBayesOpDesc(),
+ "from sklearn.naive_bayes import MultinomialNB",
+ "Multinomial Naive Bayes"
+ ),
+ (
+ new SklearnNearestCentroidOpDesc(),
+ "from sklearn.neighbors import NearestCentroid",
+ "Nearest Centroid"
+ ),
+ (
+ new SklearnPassiveAggressiveOpDesc(),
+ "from sklearn.linear_model import PassiveAggressiveClassifier",
+ "Passive Aggressive"
+ ),
+ (
+ new SklearnPerceptronOpDesc(),
+ "from sklearn.linear_model import Perceptron",
+ "Linear Perceptron"
+ ),
+ (
+ new SklearnProbabilityCalibrationOpDesc(),
+ "from sklearn.calibration import CalibratedClassifierCV",
+ "Probability Calibration"
+ ),
+ (
+ new SklearnRandomForestOpDesc(),
+ "from sklearn.ensemble import RandomForestClassifier",
+ "Random Forest"
+ ),
+ (
+ new SklearnRidgeCVOpDesc(),
+ "from sklearn.linear_model import RidgeClassifierCV",
+ "Ridge Regression Cross Validation"
+ ),
+ (
+ new SklearnRidgeOpDesc(),
+ "from sklearn.linear_model import RidgeClassifier",
+ "Ridge Regression"
+ ),
+ (
+ new SklearnSDGOpDesc(),
+ "from sklearn.linear_model import SGDClassifier",
+ "Stochastic Gradient Descent"
+ ),
+ (new SklearnSVMOpDesc(), "from sklearn.svm import SVC", "Support Vector Machine")
+ )
+
+ classifierEntries.foreach {
+ case (desc, expectedImport, expectedName) =>
+ val cls = desc.getClass.getSimpleName
+ cls should s"return import statement '$expectedImport'" in {
+ assert(desc.getImportStatements == expectedImport)
+ }
+ it should s"return user-friendly model name '$expectedName'" in {
+ assert(desc.getUserFriendlyModelName == expectedName)
+ }
+ }
+
+ "SklearnClassifierOpDesc base class" should "default to empty strings before subclass overrides" in {
+ val anonymous = new SklearnClassifierOpDesc {}
+ assert(anonymous.getImportStatements == "")
+ assert(anonymous.getUserFriendlyModelName == "")
+ }
+
+ it should "embed the import statement into generatePythonCode for a concrete subclass" in {
+ val desc = new SklearnLogisticRegressionOpDesc()
+ desc.target = "y"
+ desc.countVectorizer = false
+ // `tfidfTransformer` is a val on the base class, defaults to false.
+ val code = desc.generatePythonCode()
+ assert(code.contains("from sklearn.linear_model import LogisticRegression"))
+ // Classifier OpDescs emit a UDFTableOperator pipeline.
+ assert(code.contains("ProcessTableOperator"))
+ }
+
+ // ---------------------------------------------------------------------------
+ // Training registry (26 concrete SklearnTrainingOpDesc subclasses)
+ // ---------------------------------------------------------------------------
+
+ private val trainingEntries: List[(SklearnTrainingOpDesc, String, String)] = List(
+ (
+ new SklearnTrainingAdaptiveBoostingOpDesc(),
+ "from sklearn.ensemble import AdaBoostClassifier",
+ "Training: Adaptive Boosting"
+ ),
+ (
+ new SklearnTrainingBaggingOpDesc(),
+ "from sklearn.ensemble import BaggingClassifier",
+ "Training: Bagging Training" // current source value (typo-style duplication preserved)
+ ),
+ (
+ new SklearnTrainingBernoulliNaiveBayesOpDesc(),
+ "from sklearn.naive_bayes import BernoulliNB",
+ "Training: Bernoulli Naive Bayes"
+ ),
+ (
+ new SklearnTrainingComplementNaiveBayesOpDesc(),
+ "from sklearn.naive_bayes import ComplementNB",
+ "Training: Complement Naive Bayes"
+ ),
+ (
+ new SklearnTrainingDecisionTreeOpDesc(),
+ "from sklearn.tree import DecisionTreeClassifier",
+ "Training: Decision Tree"
+ ),
+ (
+ new SklearnTrainingDummyClassifierOpDesc(),
+ "from sklearn.dummy import dummy", // current source value (typo preserved — should be DummyClassifier)
Review Comment:
Done in d37d1ae5e8 — corrected both `SklearnDummyClassifierOpDesc` and `SklearnTrainingDummyClassifierOpDesc` to import `DummyClassifier` (the actual sklearn symbol) and updated the spec expectations accordingly.
--
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: notifications-unsubscribe@texera.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] test(workflow-operator): pin Sklearn OpDesc registry strings [texera]
Posted by "aglinxinyuan (via GitHub)" <gi...@apache.org>.
aglinxinyuan merged PR #4827:
URL: https://github.com/apache/texera/pull/4827
--
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: notifications-unsubscribe@texera.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] test(workflow-operator): pin Sklearn OpDesc registry strings [texera]
Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #4827:
URL: https://github.com/apache/texera/pull/4827#issuecomment-4365366006
## [Codecov](https://app.codecov.io/gh/apache/texera/pull/4827?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
:white_check_mark: All modified and coverable lines are covered by tests.
:white_check_mark: Project coverage is 42.84%. Comparing base ([`945849c`](https://app.codecov.io/gh/apache/texera/commit/945849ce4f7ba77091e930b53b0b35440e33b994?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`c66b470`](https://app.codecov.io/gh/apache/texera/commit/c66b470b7de3ff79f87021b6ecb3ae8259d93b96?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
:warning: Report is 1 commits behind head on main.
<details><summary>Additional details and impacted files</summary>
```diff
@@ Coverage Diff @@
## main #4827 +/- ##
=========================================
Coverage 42.84% 42.84%
Complexity 2027 2027
=========================================
Files 957 957
Lines 34077 34077
Branches 3753 3753
=========================================
Hits 14600 14600
Misses 18693 18693
Partials 784 784
```
| [Flag](https://app.codecov.io/gh/apache/texera/pull/4827/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
|---|---|---|
| [config-service](https://app.codecov.io/gh/apache/texera/pull/4827/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `0.00% <ø> (ø)` | |
Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
</details>
[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/apache/texera/pull/4827?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
<details><summary> :rocket: New features to boost your workflow: </summary>
- :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
- :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
</details>
--
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: notifications-unsubscribe@texera.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] test(workflow-operator): pin Sklearn OpDesc registry strings [texera]
Posted by "aglinxinyuan (via GitHub)" <gi...@apache.org>.
aglinxinyuan commented on code in PR #4827:
URL: https://github.com/apache/texera/pull/4827#discussion_r3180318269
##########
common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/sklearn/SklearnOpDescRegistrySpec.scala:
##########
@@ -0,0 +1,346 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.texera.amber.operator.sklearn
+
+import org.apache.texera.amber.operator.sklearn.training._
+import org.scalatest.flatspec.AnyFlatSpec
+
+/**
+ * Pins the wiring (Python import statement + user-friendly model name) for
+ * every concrete `SklearnClassifierOpDesc` and `SklearnTrainingOpDesc`. A
+ * typo in either string would silently misroute downstream UI labels and
+ * breakage of the generated Python pipeline.
+ */
+class SklearnOpDescRegistrySpec extends AnyFlatSpec {
+
+ // ---------------------------------------------------------------------------
+ // Classifier registry (25 concrete SklearnClassifierOpDesc subclasses)
+ // ---------------------------------------------------------------------------
+
+ private val classifierEntries: List[(SklearnClassifierOpDesc, String, String)] = List(
+ (
+ new SklearnAdaptiveBoostingOpDesc(),
+ "from sklearn.ensemble import AdaBoostClassifier",
+ "Adaptive Boosting"
Review Comment:
Done in 95a382b177 — added two completeness assertions, one for classifierEntries and one for trainingEntries. Both reuse `PythonReflectionUtils.scanCandidates` (the same scanner PythonCodeRawInvalidTextSpec uses) so the two suites agree on what counts as 'concrete'. The new tests fail with a 'drift' diff if a concrete subclass appears on the classpath that isn't in the manual list, or vice versa. `SklearnTrainingOpDesc` itself is concrete (used as a default fallback), so it's excluded from the training-side diff.
##########
common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/sklearn/SklearnOpDescRegistrySpec.scala:
##########
@@ -0,0 +1,346 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.texera.amber.operator.sklearn
+
+import org.apache.texera.amber.operator.sklearn.training._
+import org.scalatest.flatspec.AnyFlatSpec
+
+/**
+ * Pins the wiring (Python import statement + user-friendly model name) for
+ * every concrete `SklearnClassifierOpDesc` and `SklearnTrainingOpDesc`. A
+ * typo in either string would silently misroute downstream UI labels and
+ * breakage of the generated Python pipeline.
+ */
+class SklearnOpDescRegistrySpec extends AnyFlatSpec {
+
+ // ---------------------------------------------------------------------------
+ // Classifier registry (25 concrete SklearnClassifierOpDesc subclasses)
+ // ---------------------------------------------------------------------------
+
+ private val classifierEntries: List[(SklearnClassifierOpDesc, String, String)] = List(
+ (
+ new SklearnAdaptiveBoostingOpDesc(),
+ "from sklearn.ensemble import AdaBoostClassifier",
+ "Adaptive Boosting"
+ ),
+ (new SklearnBaggingOpDesc(), "from sklearn.ensemble import BaggingClassifier", "Bagging"),
+ (
+ new SklearnBernoulliNaiveBayesOpDesc(),
+ "from sklearn.naive_bayes import BernoulliNB",
+ "Bernoulli Naive Bayes"
+ ),
+ (
+ new SklearnComplementNaiveBayesOpDesc(),
+ "from sklearn.naive_bayes import ComplementNB",
+ "Complement Naive Bayes"
+ ),
+ (
+ new SklearnDummyClassifierOpDesc(),
+ "from sklearn.dummy import DummyClassifier",
+ "Dummy Classifier"
+ ),
+ (
+ new SklearnDecisionTreeOpDesc(),
+ "from sklearn.tree import DecisionTreeClassifier",
+ "Decision Tree"
+ ),
+ (new SklearnExtraTreeOpDesc(), "from sklearn.tree import ExtraTreeClassifier", "Extra Tree"),
+ (
+ new SklearnExtraTreesOpDesc(),
+ "from sklearn.ensemble import ExtraTreesClassifier",
+ "Extra Trees"
+ ),
+ (
+ new SklearnGaussianNaiveBayesOpDesc(),
+ "from sklearn.naive_bayes import GaussianNB",
+ "Gaussian Naive Bayes"
+ ),
+ (
+ new SklearnGradientBoostingOpDesc(),
+ "from sklearn.ensemble import GradientBoostingClassifier",
+ "Gradient Boosting"
+ ),
+ (
+ new SklearnKNNOpDesc(),
+ "from sklearn.neighbors import KNeighborsClassifier",
+ "K-nearest Neighbors"
+ ),
+ (
+ new SklearnLinearSVMOpDesc(),
+ "from sklearn.svm import LinearSVC",
+ "Linear Support Vector Machine"
+ ),
+ (
+ new SklearnLogisticRegressionCVOpDesc(),
+ "from sklearn.linear_model import LogisticRegressionCV",
+ "Logistic Regression Cross Validation"
+ ),
+ (
+ new SklearnLogisticRegressionOpDesc(),
+ "from sklearn.linear_model import LogisticRegression",
+ "Logistic Regression"
+ ),
+ (
+ new SklearnMultiLayerPerceptronOpDesc(),
+ "from sklearn.neural_network import MLPClassifier",
+ "Multi-layer Perceptron"
+ ),
+ (
+ new SklearnMultinomialNaiveBayesOpDesc(),
+ "from sklearn.naive_bayes import MultinomialNB",
+ "Multinomial Naive Bayes"
+ ),
+ (
+ new SklearnNearestCentroidOpDesc(),
+ "from sklearn.neighbors import NearestCentroid",
+ "Nearest Centroid"
+ ),
+ (
+ new SklearnPassiveAggressiveOpDesc(),
+ "from sklearn.linear_model import PassiveAggressiveClassifier",
+ "Passive Aggressive"
+ ),
+ (
+ new SklearnPerceptronOpDesc(),
+ "from sklearn.linear_model import Perceptron",
+ "Linear Perceptron"
+ ),
+ (
+ new SklearnProbabilityCalibrationOpDesc(),
+ "from sklearn.calibration import CalibratedClassifierCV",
+ "Probability Calibration"
+ ),
+ (
+ new SklearnRandomForestOpDesc(),
+ "from sklearn.ensemble import RandomForestClassifier",
+ "Random Forest"
+ ),
+ (
+ new SklearnRidgeCVOpDesc(),
+ "from sklearn.linear_model import RidgeClassifierCV",
+ "Ridge Regression Cross Validation"
+ ),
+ (
+ new SklearnRidgeOpDesc(),
+ "from sklearn.linear_model import RidgeClassifier",
+ "Ridge Regression"
+ ),
+ (
+ new SklearnSDGOpDesc(),
+ "from sklearn.linear_model import SGDClassifier",
+ "Stochastic Gradient Descent"
+ ),
+ (new SklearnSVMOpDesc(), "from sklearn.svm import SVC", "Support Vector Machine")
+ )
+
+ classifierEntries.foreach {
+ case (desc, expectedImport, expectedName) =>
+ val cls = desc.getClass.getSimpleName
+ cls should s"return import statement '$expectedImport'" in {
+ assert(desc.getImportStatements == expectedImport)
+ }
+ it should s"return user-friendly model name '$expectedName'" in {
+ assert(desc.getUserFriendlyModelName == expectedName)
+ }
+ }
+
+ "SklearnClassifierOpDesc" should "embed the import statement into generatePythonCode for a concrete subclass" in {
+ val desc = new SklearnLogisticRegressionOpDesc()
+ desc.target = "y"
+ desc.countVectorizer = false
+ // `tfidfTransformer` is a val on the base class, defaults to false.
+ val code = desc.generatePythonCode()
+ assert(code.contains("from sklearn.linear_model import LogisticRegression"))
+ // Classifier OpDescs emit a UDFTableOperator pipeline.
+ assert(code.contains("ProcessTableOperator"))
+ }
+ // NOTE: the abstract base class's empty-string defaults are NOT tested here.
+ // Instantiating `SklearnClassifierOpDesc` from this spec (e.g. via
+ // `new SklearnClassifierOpDesc {}`) creates an anonymous test-package class
+ // under `org.apache.texera.amber.operator.sklearn`, which the
+ // PythonCodeRawInvalidTextSpec classpath scan then picks up as a descriptor
+ // candidate and fails on (anonymous classes have no accessible no-arg
+ // constructor). Every concrete subclass below overrides both methods, so
+ // the base default is never observable in production anyway.
Review Comment:
Took option 2 — updated the [PR description](https://github.com/apache/texera/pull/4827) and [linked issue](https://github.com/apache/texera/issues/4826) to remove the base-defaults claim and document why it's not tested (anonymous-subclass instantiation breaks the PythonCodeRawInvalidTextSpec classpath scan; base default is never observable in production because every concrete subclass overrides both methods). The earlier 95a382b177 commit's spec-level NOTE comment also documents this so a future contributor won't reflexively re-add it.
##########
common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/sklearn/SklearnOpDescRegistrySpec.scala:
##########
@@ -0,0 +1,346 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.texera.amber.operator.sklearn
+
+import org.apache.texera.amber.operator.sklearn.training._
+import org.scalatest.flatspec.AnyFlatSpec
+
+/**
+ * Pins the wiring (Python import statement + user-friendly model name) for
+ * every concrete `SklearnClassifierOpDesc` and `SklearnTrainingOpDesc`. A
+ * typo in either string would silently misroute downstream UI labels and
+ * breakage of the generated Python pipeline.
Review Comment:
Done in 95a382b177 — rephrased to '...labels and cause breakage in the generated Python pipeline'.
--
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: notifications-unsubscribe@texera.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org