Skip to content

feat(frontend): add HuggingFace task selector and model browser component#5566

Open
ELin2025 wants to merge 18 commits into
apache:mainfrom
ELin2025:hf/06a-frontend-selector
Open

feat(frontend): add HuggingFace task selector and model browser component#5566
ELin2025 wants to merge 18 commits into
apache:mainfrom
ELin2025:hf/06a-frontend-selector

Conversation

@ELin2025

@ELin2025 ELin2025 commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

⚠️ This PR is stacked on #5574. Until that lands, the diff below may also include PR 5's QA/ranking task changes depending on which base GitHub is showing. The new code in this PR is the HuggingFaceComponent (task selector + model browser) under frontend/src/app/workspace/component/hugging-face/, plus the formly registration in formly-config.ts and the declaration in app.module.ts. Once PR #5574 merges and this PR is retargeted to main, the diff should auto-clean to the PR 6a frontend selector changes only.

What changes were proposed in this PR?

Add HuggingFaceComponent, a custom formly field type (huggingface) that provides:

  • A task dropdown listing all supported HuggingFace inference tasks (fetched from the Texera backend's /huggingface/tasks endpoint, with a static fallback list)
  • A paginated model list with client-side search, fetched from the Texera backend's /huggingface/models endpoint (which proxies HuggingFace Hub)
  • Per-task field state preservation — when switching tasks, previously entered values (modelId, promptColumn, etc.) are saved and restored

This PR registers the component in formly-config.ts and declares it in AppModule. The component is not yet wired into the HuggingFace operator's property editor; the jsonSchemaMapIntercept mapping that routes the modelId field to this component is added in the follow-up property-editor PR (PR 7).

Any related issues, documentation, discussions?

How was this PR tested?

7 unit tests added in hugging-face.component.spec.ts covering:

  • Static task list is non-empty and contains expected tasks (text-generation, image tasks, audio tasks, QA/ranking tasks)
  • Task tags are unique
  • Cache invalidation does not throw

Run with ng test.

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

Co-authored with Claude Opus 4.7

@codecov-commenter

codecov-commenter commented Jun 8, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 12.70983% with 364 lines in your changes missing coverage. Please review.
✅ Project coverage is 53.68%. Comparing base (439ea72) to head (c5f75b9).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
...e/component/hugging-face/hugging-face.component.ts 7.26% 267 Missing and 1 partial ⚠️
...component/hugging-face/hugging-face.component.html 0.00% 96 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #5566      +/-   ##
============================================
- Coverage     54.09%   53.68%   -0.41%     
- Complexity     2817     2822       +5     
============================================
  Files          1103     1106       +3     
  Lines         42650    43065     +415     
  Branches       4588     4654      +66     
============================================
+ Hits          23070    23120      +50     
- Misses        18236    18600     +364     
- Partials       1344     1345       +1     
Flag Coverage Δ *Carryforward flag
access-control-service 70.44% <ø> (ø)
agent-service 34.36% <ø> (ø) Carriedforward from cb2bd44
amber 55.69% <100.00%> (+0.07%) ⬆️
computing-unit-managing-service 1.65% <ø> (ø)
config-service 57.35% <ø> (ø)
file-service 58.59% <ø> (ø)
frontend 47.17% <5.69%> (-0.93%) ⬇️
pyamber 90.20% <ø> (ø) Carriedforward from cb2bd44
python 90.76% <ø> (ø) Carriedforward from cb2bd44
workflow-compiling-service 58.69% <ø> (ø)

*This pull request uses carry forward flags. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ELin2025

ELin2025 commented Jun 8, 2026

Copy link
Copy Markdown
Contributor Author

/request-review @Ma77Ball

1 similar comment
@ELin2025

ELin2025 commented Jun 8, 2026

Copy link
Copy Markdown
Contributor Author

/request-review @Ma77Ball

@ELin2025 ELin2025 marked this pull request as draft June 8, 2026 22:15
@ELin2025 ELin2025 marked this pull request as ready for review June 8, 2026 22:30

@Ma77Ball Ma77Ball left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left comments, please ignore if implemented later or push those changes here.

Comment thread frontend/src/app/workspace/component/hugging-face/hugging-face.component.ts Outdated
Comment thread frontend/src/app/workspace/component/hugging-face/hugging-face.component.ts Outdated
@github-actions

github-actions Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

⚠️ Benchmark changes need a look

🟢 2 better · 🔴 5 worse · ⚪ 8 noise (<±5%) · 0 without baseline

Compared against main 8803d08 benchmarked on this same runner, so the delta is largely free of cross-runner hardware noise. The "7d avg" column still reflects the gh-pages dashboard. Treat <±5% as noise unless repeated.

Dashboard · Run

config throughput MB/s latency max Δ latest / 7d
🔴 bs=10 sw=10 sl=64 417 0.255 24,069/30,842/30,842 us 🔴 +21.2% / 🟢 -11.8%
🔴 bs=100 sw=10 sl=64 930 0.567 105,804/137,787/137,787 us 🔴 +6.0% / 🟢 -5.8%
bs=1000 sw=10 sl=64 1,081 0.66 930,922/961,076/961,076 us ⚪ within ±5% / 🟢 -6.1%
Baseline details

Latest main 8803d08 from same runner

config metric PR latest main 7d avg Δ latest Δ 7d
bs=10 sw=10 sl=64 throughput 417 tuples/sec 446 tuples/sec 410.82 tuples/sec -6.5% +1.5%
bs=10 sw=10 sl=64 MB/s 0.255 MB/s 0.272 MB/s 0.251 MB/s -6.3% +1.7%
bs=10 sw=10 sl=64 p50 24,069 us 19,866 us 23,785 us +21.2% +1.2%
bs=10 sw=10 sl=64 p95 30,842 us 39,152 us 34,980 us -21.2% -11.8%
bs=10 sw=10 sl=64 p99 30,842 us 39,152 us 34,980 us -21.2% -11.8%
bs=100 sw=10 sl=64 throughput 930 tuples/sec 942 tuples/sec 891.94 tuples/sec -1.3% +4.3%
bs=100 sw=10 sl=64 MB/s 0.567 MB/s 0.575 MB/s 0.544 MB/s -1.4% +4.2%
bs=100 sw=10 sl=64 p50 105,804 us 105,060 us 112,277 us +0.7% -5.8%
bs=100 sw=10 sl=64 p95 137,787 us 129,991 us 139,802 us +6.0% -1.4%
bs=100 sw=10 sl=64 p99 137,787 us 129,991 us 139,802 us +6.0% -1.4%
bs=1000 sw=10 sl=64 throughput 1,081 tuples/sec 1,110 tuples/sec 1,041 tuples/sec -2.6% +3.8%
bs=1000 sw=10 sl=64 MB/s 0.66 MB/s 0.678 MB/s 0.635 MB/s -2.7% +3.9%
bs=1000 sw=10 sl=64 p50 930,922 us 899,720 us 972,714 us +3.5% -4.3%
bs=1000 sw=10 sl=64 p95 961,076 us 954,094 us 1,023,057 us +0.7% -6.1%
bs=1000 sw=10 sl=64 p99 961,076 us 954,094 us 1,023,057 us +0.7% -6.1%
Raw CSV
config_idx,batch_size,schema_width,string_len,num_batches,total_ms,total_tuples,total_bytes,tuples_per_sec,mb_per_sec,lat_p50_us,lat_p95_us,lat_p99_us
0,10,10,64,20,479.06,200,128000,417,0.255,24068.70,30842.45,30842.45
1,100,10,64,20,2151.52,2000,1280000,930,0.567,105804.39,137787.10,137787.10
2,1000,10,64,20,18493.68,20000,12800000,1081,0.660,930921.52,961075.61,961075.61

@ELin2025 ELin2025 requested a review from Ma77Ball June 12, 2026 00:17

@Ma77Ball Ma77Ball left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved since the last round:

  • interval/timeout handles tracked and cleared in ngOnDestroy
  • dead TASK_TAG_MAP/TASK_NAMES removed
  • truncation header read via observe: response, server-side search wired
  • inFlightByTag now used for dedup
  • tasks fetch resets its guard on cancellation via finalize

One item left, inline (suggestion). Static review only, not built or run.
@xuang7, can you review?

Comment thread frontend/src/app/workspace/component/hugging-face/hugging-face.component.ts Outdated
@ELin2025 ELin2025 force-pushed the hf/06a-frontend-selector branch from b132cde to 775f26c Compare June 16, 2026 18:07
@github-actions github-actions Bot added engine dependencies Pull requests that update a dependency file pyamber ci changes related to CI docs Changes related to documentations dev platform Non-amber Scala service paths agent-service labels Jun 16, 2026
@ELin2025 ELin2025 force-pushed the hf/06a-frontend-selector branch from 775f26c to b132cde Compare June 16, 2026 18:14
@github-actions github-actions Bot removed engine dependencies Pull requests that update a dependency file pyamber ci changes related to CI docs Changes related to documentations dev platform Non-amber Scala service paths labels Jun 16, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new Angular Formly field for configuring HuggingFace inference (task selection + model browsing) and expands the HuggingFace operator backend codegen/task coverage (image/audio/media-gen + QA/ranking), including updated Scala tests.

Changes:

  • Frontend: introduce HuggingFaceComponent (task dropdown + model list/search/pagination + per-task state preservation) and HuggingFaceImageUploadComponent, and register them as Formly field types.
  • Backend: extend HuggingFace codegen dispatcher and Python template to support additional task families (image/audio/media-gen/QA+ranking) plus new operator properties for those tasks.
  • Tests: add/extend unit tests for both the frontend components and backend operator descriptor/codegen.

Reviewed changes

Copilot reviewed 18 out of 20 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
frontend/src/app/workspace/component/hugging-face/hugging-face.component.ts New Formly field component that fetches HF tasks/models, caches results, supports search/pagination, and preserves task-scoped form state.
frontend/src/app/workspace/component/hugging-face/hugging-face.component.html Template for task selector, model browser, search, and pagination UI.
frontend/src/app/workspace/component/hugging-face/hugging-face.component.scss Styles for the HuggingFace selector/model list UI.
frontend/src/app/workspace/component/hugging-face/hugging-face.component.spec.ts Unit tests covering the static task list and cache invalidation helper.
frontend/src/app/workspace/component/hugging-face-image-upload/hugging-face-image-upload.component.ts New image upload Formly field with client-side compression and data-url storage.
frontend/src/app/workspace/component/hugging-face-image-upload/hugging-face-image-upload.component.html Template for image upload + preview + clear UX.
frontend/src/app/workspace/component/hugging-face-image-upload/hugging-face-image-upload.component.scss Styles for the image upload component.
frontend/src/app/workspace/component/hugging-face-image-upload/hugging-face-image-upload.component.spec.ts Unit tests for derived state, invalid file handling, and clear behavior.
frontend/src/app/common/formly/formly-config.ts Registers new Formly field types: huggingface and huggingface-image-upload.
frontend/src/app/app.module.ts Declares the new HuggingFace components.
common/workflow-operator/src/main/scala/.../HuggingFaceInferenceOpDesc.scala Adds new operator properties and registers multiple task-family codegens in the dispatcher.
common/workflow-operator/src/main/scala/.../codegen/TaskCodegen.scala Extends CodegenContext and introduces a multi-task tasks API for codegens.
common/workflow-operator/src/main/scala/.../codegen/PythonCodegenBase.scala Expands generated Python with provider routing + image/audio/media helpers and new runtime validation logic.
common/workflow-operator/src/main/scala/.../codegen/QaRankingCodegen.scala New QA/ranking task codegen (payload + response parsing).
common/workflow-operator/src/main/scala/.../codegen/ImageTaskCodegen.scala New image task-family codegen handling raw-binary and image+prompt payloads.
common/workflow-operator/src/main/scala/.../codegen/AudioTaskCodegen.scala New audio task-family codegen supporting raw-binary audio and TTS parsing.
common/workflow-operator/src/main/scala/.../codegen/MediaGenCodegen.scala New prompt-driven media generation codegen with URL/b64 normalization.
common/workflow-operator/src/test/scala/.../HuggingFaceInferenceOpDescSpec.scala Adds extensive task-family coverage assertions for generated Python code.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread frontend/src/app/workspace/component/hugging-face/hugging-face.component.spec.ts Outdated
anishshiva7 and others added 18 commits June 22, 2026 21:58
…nent

Register the huggingface formly field type and declare HuggingFaceComponent
in AppModule. Provides a task dropdown, paginated model list with client-side
search, and per-task field state preservation when switching tasks.
The rxjs/no-implicit-any-catch ESLint rule requires explicit type
annotations on error callbacks in .subscribe() calls.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…mponent

Satisfies the rxjs-angular/prefer-takeuntil lint rule.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…mponent

Fix setInterval/setTimeout leaks by tracking timer IDs and clearing them
in ngOnDestroy. Remove takeUntil(destroy$) from shared module-level task
fetch to prevent cache poisoning when the initiating component is destroyed.
Remove unused TASK_TAG_MAP and TASK_NAMES exports.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…FaceComponent

inFlightByTag was written but never read, so multiple component instances
mounting for the same uncached task would each fire a full backend request.
Add an in-flight guard that polls for the existing request's completion,
matching the pattern already used for task fetches.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
… in HuggingFaceComponent

Read X-Texera-Truncated header via { observe: "response" } to detect
when the backend's model list is incomplete. Show a notice prompting
users to search. When truncated, search queries are sent to the backend
search endpoint with debounce; otherwise local filtering is used.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…r lint rule

Add back destroy$ and takeUntil(this.destroy$) on all subscribe calls.
For the shared task fetch, add finalize() to reset tasksFetchSubscription
when takeUntil fires before next/error, preventing the stale-guard bug
the reviewer originally flagged.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…anup

Mirror the defensive pattern from the tasks fetch so that when
takeUntil(destroy$) cancels mid-flight, inFlightByTag is cleared
and subsequent component instances can re-fetch instead of polling
forever.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Elliot Lin <36275109+ELin2025@users.noreply.github.com>
- Fix model polling indefinite loop by detecting cancelled in-flight fetch
- Fix CSS class mismatch: hf-tasks-error → hf-error to match SCSS
- Remove unused imports in spec file

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Catch HTTP errors inside switchMap so search stream survives failures
- Use empty string instead of null when clearing model selection

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@ELin2025 ELin2025 force-pushed the hf/06a-frontend-selector branch from 7889a13 to c5f75b9 Compare June 23, 2026 16:33
@github-actions github-actions Bot removed the engine label Jun 23, 2026
@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: @anishshiva7, @Ma77Ball, @PG1204
    You can notify them by mentioning @anishshiva7, @Ma77Ball, @PG1204 in a comment.

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

Labels

common frontend Changes related to the frontend GUI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add HuggingFace task selector, model browser, and audio upload components

5 participants