Skip to content

fix(workflow-operator): route HF text generation via router - #9729

Open
dragonknightk wants to merge 1 commit into
apache:mainfrom
dragonknightk:fix-hf-text-generation-router
Open

dragonknightk wants to merge 1 commit into
apache:mainfrom
dragonknightk:fix-hf-text-generation-router

Conversation

@dragonknightk

Copy link
Copy Markdown

What changes were proposed in this PR?

The Hub now returns an empty provider mapping for models that are still served, and the operator's fallback for that case, hf-inference, no longer serves any text-generation model.

This PR changes only that fallback, and only for the text-generation task:

Case Before After
Text generation, lookup fails or is empty router.huggingface.co/hf-inference/models/{id}/v1/chat/completions router.huggingface.co/v1/chat/completions, model = Hub ID
Text generation, Hub lists live providers provider route, providerId unchanged
Any other task, lookup fails or is empty hf-inference unchanged

The router's generic chat route picks a live provider for the Hub model ID by itself, so the operator no longer needs the Hub mapping to reach one. image-text-to-text shares the chat branch but keeps the hf-inference fallback, because the issue only covers text generation.

Any related issues, documentation, discussions?

Closes #9723

How was this PR tested?

Added HuggingFaceProviderRouteBehaviorSpec. Like the existing parse behavior spec, it runs the generated provider lookup and request loop with only requests stubbed, so nothing reaches the network. It covers:

  • an empty Hub mapping (the reply quoted in the issue), a Hub error status and an unreachable Hub: text generation posts to the router's generic chat route with the Hub model ID. These cases fail on the old code, which posts to the hf-inference route.
  • a live provider in the Hub mapping: text generation still posts to that provider's route with its own model name.
  • image-text-to-text and a pipeline task with an empty mapping: both still post to hf-inference.

AMBER_TEST_FILTER=skip-integration sbt "WorkflowOperator/testOnly org.apache.texera.amber.operator.huggingFace.*"

Was this PR authored or co-authored using generative AI tooling?

Generated-by: Grok Bot. Human-led contribution; all code, tests, and description were reviewed by dragonknightk before submission.

### What changes were proposed in this PR?

The Hub now returns an empty provider mapping for models that are still served, and the operator's fallback for that case, `hf-inference`, no longer serves any text-generation model.

This PR changes only that fallback, and only for the `text-generation` task:

| Case | Before | After |
| --- | --- | --- |
| Text generation, lookup fails or is empty | `router.huggingface.co/hf-inference/models/{id}/v1/chat/completions` | `router.huggingface.co/v1/chat/completions`, model = Hub ID |
| Text generation, Hub lists live providers | provider route, `providerId` | unchanged |
| Any other task, lookup fails or is empty | `hf-inference` | unchanged |

The router's generic chat route picks a live provider for the Hub model ID by itself, so the operator no longer needs the Hub mapping to reach one. `image-text-to-text` shares the chat branch but keeps the `hf-inference` fallback, because the issue only covers text generation.

### Any related issues, documentation, discussions?

Closes issue 9723

### How was this PR tested?

Added `HuggingFaceProviderRouteBehaviorSpec`. Like the existing parse behavior spec, it runs the generated provider lookup and request loop with only `requests` stubbed, so nothing reaches the network. It covers:

- an empty Hub mapping (the reply quoted in the issue), a Hub error status and an unreachable Hub: text generation posts to the router's generic chat route with the Hub model ID. These cases fail on the old code, which posts to the `hf-inference` route.
- a live provider in the Hub mapping: text generation still posts to that provider's route with its own model name.
- `image-text-to-text` and a pipeline task with an empty mapping: both still post to `hf-inference`.

`AMBER_TEST_FILTER=skip-integration sbt "WorkflowOperator/testOnly org.apache.texera.amber.operator.huggingFace.*"`

### Was this PR authored or co-authored using generative AI tooling?

Signed-off-by: dragonknightk <37928252+dragonknightk@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown
Contributor

👋 Thanks for your first contribution to Texera, @dragonknightk!

If you're looking for a good place to start, browse issues labeled starter-task; they're scoped to be approachable for newcomers.

You can drive common housekeeping yourself by commenting one of these commands on its own line:

  • Issues. Comment /take to assign an open issue to yourself, or /untake to release it. You can find unclaimed work with the search filter is:issue is:open no:assignee.
  • Sub-issues. To link issues into a parent/child hierarchy, comment /sub-issue #5166 #5222 on the parent to attach those children (or /unsub-issue #5166 #5222 to detach them). From a child issue, comment /parent-issue #5166 to set its parent, or /unparent-issue to clear it (the current parent is detected automatically). References may be written as #5166 or as a bare 5166; cross-repository references are not supported.
  • Pull requests (author only). Comment /request-review @user to request a review from someone, or /unrequest-review @user to withdraw that request.

Each command must match exactly: /take this will not work, only /take does. For the full contribution flow, see CONTRIBUTING.md.

@Yicong-Huang Yicong-Huang added the release/v1.3 back porting to release/v1.3 label Nov 27, 2026
@github-actions
github-actions Bot requested a review from mengw15 November 27, 2026 05:34
@github-actions

Copy link
Copy Markdown
Contributor

Backport auto-label report

This fix: PR was checked against each actively-supported release branch. A release/* label nominates a backport target; the branch's release manager approving this PR is what sends the fix there. The required Backport Approvals check stays red until every label below is approved, so each manager either approves or removes their own label — which is why the labels left on a merged PR are exactly the branches it reached.

Release branch Analysis
✅ release/v1.3 Change detected on this branch — label added; this fix is queued to backport here. @mengw15 decides: approving sends the fix here, removing this label declines it. The merge waits on one or the other. Review requested.
⚠️ release/v1.2 Not labeled automatically — none of the files this PR modifies exist on this branch (common/workflow-operator/src/main/scala/org/apache/texera/amber/operator/huggingFace/codegen/HuggingFaceCodegenBase.scala). The fix may target code that isn't on this release, or the files were moved/renamed after the branch was cut. Please check and add release/v1.2 by hand if this fix should be backported here — its release manager then has to approve before this PR can merge.

Auto-label run.

@github-actions

Copy link
Copy Markdown
Contributor

Automated Reviewer Suggestions

Based on the git blame history of the changed files, we recommend the following reviewers:

  • Contributors with relevant context: @aglinxinyuan
    You can notify them by mentioning @aglinxinyuan in a comment.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

common fix release/v1.3 back porting to release/v1.3

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Hugging Face text generation fails for every model: provider lookup returns no providers

2 participants