kz930 opened a new issue, #6794:
URL: https://github.com/apache/texera/issues/6794

   ### What happened?
   
   `HuggingFaceSentimentAnalysisOpDesc.generatePythonCode` emits an import for 
`TFAutoModelForSequenceClassification` that is never used:
   
   
`common/workflow-operator/src/main/scala/org/apache/texera/amber/operator/huggingFace/HuggingFaceSentimentAnalysisOpDesc.scala`
   
   ```python
   from transformers import pipeline
   from transformers import AutoModelForSequenceClassification
   from transformers import TFAutoModelForSequenceClassification   # <-- never 
used
   from transformers import AutoTokenizer, AutoConfig
   ```
   
   The generated body loads the model with the PyTorch 
`AutoModelForSequenceClassification` (`self.model = 
AutoModelForSequenceClassification.from_pretrained(...)`) and uses `pipeline`; 
`TFAutoModelForSequenceClassification` is not referenced anywhere in the 
generated code.
   
   The `TF*` classes belong to `transformers`' TensorFlow backend, so importing 
this symbol forces a TensorFlow dependency. In a PyTorch-only environment 
(which is what the operator actually uses), `from transformers import 
TFAutoModelForSequenceClassification` raises an ImportError/RuntimeError at 
module load, **crashing the whole generated script** before any inference runs.
   
   **Expected:** the generated code does not import unused TensorFlow-only 
symbols.
   
   ### How to reproduce?
   
   **A — user-facing:** Run a **Hugging Face Sentiment Analysis** operator in 
an environment where `transformers` is installed with the PyTorch backend but 
without TensorFlow. The generated script fails at import on the 
`TFAutoModelForSequenceClassification` line.
   
   **B — confirmed against `main`:** in `main`'s `generatePythonCode`, 
`TFAutoModelForSequenceClassification` appears only on the import line (line 
64) and is never referenced in the body (the model is loaded via 
`AutoModelForSequenceClassification`, line 75).
   
   **Proposed fix:** remove the unused import:
   
   ```
    from transformers import pipeline
    from transformers import AutoModelForSequenceClassification
   -from transformers import TFAutoModelForSequenceClassification
    from transformers import AutoTokenizer, AutoConfig
   ```
   
   ### Version/Branch
   
   1.3.0-incubating-SNAPSHOT (main)
   
   ### Commit Hash (Optional)
   
   _No response_
   
   ### What browsers are you seeing the problem on?
   
   _No response_
   
   ### Relevant log output
   
   ```shell
   
   ```
   


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to