fix(HuggingFace, v1.2): drop unused TensorFlow import in sentiment analysis codegen - #7315
Open
github-actions[bot] wants to merge 2 commits into
Open
Conversation
… codegen (#6809) ### What changes were proposed in this PR? `HuggingFaceSentimentAnalysisOpDesc.generatePythonCode` emitted an import for `TFAutoModelForSequenceClassification` that the generated body never uses — the model is loaded through the PyTorch `AutoModelForSequenceClassification`. The symbol does not exist in the pinned `transformers`: the library dropped its TensorFlow backend in 5.0, and `amber/operator-requirements.txt` has been on 5.x since #5016 (5.5.0 today). So the import is not dead weight — it raises `ImportError` at module load and takes the whole generated script down before any inference runs, on every environment that installs the pinned requirements. Fix — remove the unused import: ```diff from transformers import pipeline from transformers import AutoModelForSequenceClassification -from transformers import TFAutoModelForSequenceClassification from transformers import AutoTokenizer, AutoConfig ``` ### Any related issues, documentation, discussions? Closes #6794 ### How was this PR tested? Manually, per @Yicong-Huang's request: the existing spec asserts on the emitted text and `py_compile` only parses it, so neither executes the template. The template was dumped from `generatePythonCode` (columns `text` → `pos`/`neu`/`neg`) and run against the `pytexera` in `amber/src/main/python`, in a virtualenv with the pinned `transformers` 5.5.0 and `numpy` 2.1.0. main's stops at line 4 with `ImportError: cannot import name 'TFAutoModelForSequenceClassification' from 'transformers'`, before the class body is defined; this PR's loads `cardiffnlp/twitter-roberta-base-sentiment-latest` and classifies all three rows, each row's three columns summing to 1: | text | pos | neu | neg | | --- | --- | --- | --- | | I love this new feature, it works beautifully! | 0.9884 | 0.007 | 0.0046 | | The meeting is scheduled for 3pm in room 204. | 0.0433 | 0.9438 | 0.0129 | | This is the worst release we have ever shipped. | 0.0066 | 0.0423 | 0.951 | ### Was this PR authored or co-authored using generative AI tooling? Generated-by: Claude Code (Claude Opus 4.8) --------- (backported from commit 2ae9a97) Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com> Co-authored-by: carloea2 <carloea2@uci.edu> Co-authored-by: Yicong Huang <17627829+Yicong-Huang@users.noreply.github.com> Co-authored-by: Xuan Gu <162244362+xuang7@users.noreply.github.com>
Contributor
Author
|
The cherry-pick applied cleanly but the backported tree failed its pre-merge build. Fix the build on this branch, then mark this PR ready for review. |
xuang7
approved these changes
Aug 5, 2026
…-import-in-sentime-v1.2
xuang7
enabled auto-merge
August 5, 2026 06:30
Contributor
Author
Automated Reviewer SuggestionsBased on the
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this PR?
Automated backport of #6809 to
release/v1.2.Source: 2ae9a97 · automation run
Any related issues, documentation, discussions?
Backport of #6809. Originally linked #6794.
How was this PR tested?
Release-branch CI runs on this branch once the build is fixed and this PR is marked ready for review.
Was this PR authored or co-authored using generative AI tooling?
No.