From b5303ed8b442fb43a1fd19c9de454559b99608fa Mon Sep 17 00:00:00 2001 From: kary zheng Date: Wed, 22 Jul 2026 16:08:24 -0700 Subject: [PATCH 1/2] fix(HuggingFace): drop unused TensorFlow import in sentiment analysis codegen HuggingFaceSentimentAnalysisOpDesc.generatePythonCode imported TFAutoModelForSequenceClassification but never used it (the model loads via the PyTorch AutoModelForSequenceClassification). The TF-only symbol forces a TensorFlow backend, so in a PyTorch-only transformers install the import raises and crashes the generated script at module load. Remove the unused import. Adds a HuggingFaceSentimentAnalysisOpDescSpec regression test asserting the generated code no longer imports the TF-only symbol while still importing the PyTorch class it uses. Closes #6794 Co-Authored-By: Claude Opus 4.8 --- .../huggingFace/HuggingFaceSentimentAnalysisOpDesc.scala | 1 - .../HuggingFaceSentimentAnalysisOpDescSpec.scala | 9 +++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/common/workflow-operator/src/main/scala/org/apache/texera/amber/operator/huggingFace/HuggingFaceSentimentAnalysisOpDesc.scala b/common/workflow-operator/src/main/scala/org/apache/texera/amber/operator/huggingFace/HuggingFaceSentimentAnalysisOpDesc.scala index 1d6cc7be9c5..d60f1f33ea2 100644 --- a/common/workflow-operator/src/main/scala/org/apache/texera/amber/operator/huggingFace/HuggingFaceSentimentAnalysisOpDesc.scala +++ b/common/workflow-operator/src/main/scala/org/apache/texera/amber/operator/huggingFace/HuggingFaceSentimentAnalysisOpDesc.scala @@ -61,7 +61,6 @@ class HuggingFaceSentimentAnalysisOpDesc extends PythonOperatorDescriptor { pyb"""from pytexera import * |from transformers import pipeline |from transformers import AutoModelForSequenceClassification - |from transformers import TFAutoModelForSequenceClassification |from transformers import AutoTokenizer, AutoConfig |import numpy as np |from scipy.special import softmax diff --git a/common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/huggingFace/HuggingFaceSentimentAnalysisOpDescSpec.scala b/common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/huggingFace/HuggingFaceSentimentAnalysisOpDescSpec.scala index 7902c572cd4..565398ad62c 100644 --- a/common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/huggingFace/HuggingFaceSentimentAnalysisOpDescSpec.scala +++ b/common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/huggingFace/HuggingFaceSentimentAnalysisOpDescSpec.scala @@ -130,4 +130,13 @@ class HuggingFaceSentimentAnalysisOpDescSpec extends AnyFlatSpec with Matchers { h.resultAttributeNeutral shouldBe "neu" h.resultAttributeNegative shouldBe "neg" } + + "HuggingFaceSentimentAnalysisOpDesc.generatePythonCode" should + "not import the unused TensorFlow-only symbol" in { + // The TF-only symbol was imported but unused; it raises ImportError in a + // PyTorch-only transformers install, crashing the generated script. + val code = configured().generatePythonCode() + code should not include "TFAutoModelForSequenceClassification" + code should include("from transformers import AutoModelForSequenceClassification") + } } From 4defe25e0628dbbddecf2c75e87b6e00dff48ca9 Mon Sep 17 00:00:00 2001 From: kary zheng Date: Wed, 22 Jul 2026 17:07:23 -0700 Subject: [PATCH 2/2] test(HuggingFace): drop sentiment TF-import regression test The assertion only guards a line in generatePythonCode() that is slated for removal, so it adds little lasting value. Keep the import fix itself. Co-Authored-By: Claude Opus 4.8 (1M context) --- .../HuggingFaceSentimentAnalysisOpDescSpec.scala | 9 --------- 1 file changed, 9 deletions(-) diff --git a/common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/huggingFace/HuggingFaceSentimentAnalysisOpDescSpec.scala b/common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/huggingFace/HuggingFaceSentimentAnalysisOpDescSpec.scala index 565398ad62c..7902c572cd4 100644 --- a/common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/huggingFace/HuggingFaceSentimentAnalysisOpDescSpec.scala +++ b/common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/huggingFace/HuggingFaceSentimentAnalysisOpDescSpec.scala @@ -130,13 +130,4 @@ class HuggingFaceSentimentAnalysisOpDescSpec extends AnyFlatSpec with Matchers { h.resultAttributeNeutral shouldBe "neu" h.resultAttributeNegative shouldBe "neg" } - - "HuggingFaceSentimentAnalysisOpDesc.generatePythonCode" should - "not import the unused TensorFlow-only symbol" in { - // The TF-only symbol was imported but unused; it raises ImportError in a - // PyTorch-only transformers install, crashing the generated script. - val code = configured().generatePythonCode() - code should not include "TFAutoModelForSequenceClassification" - code should include("from transformers import AutoModelForSequenceClassification") - } }