Skip to content

Teams(jobs): mock drop-in stub for the full HF Jobs API - #69

Draft
DiTo97 with Copilot wants to merge 2 commits into
mainfrom
copilot/thread-add-api-stubs-support
Draft

Teams(jobs): mock drop-in stub for the full HF Jobs API#69
DiTo97 with Copilot wants to merge 2 commits into
mainfrom
copilot/thread-add-api-stubs-support

Conversation

Copilot AI commented Mar 31, 2026

Copy link
Copy Markdown

The hf jobs CLI is becoming a central workflow tool; without any Jobs API endpoints the Python client errors immediately. This adds a fully-shaped in-memory stub so the CLI and huggingface_hub library work against this server without requiring real compute.

Server (Rust)

  • state.rsJobsStore (Mutex<HashMap> pair for jobs + scheduled jobs) added to HubState
  • routes/jobs.rs — 13 stub handlers; auth-gated, namespace-scoped, correctly shaped JSON responses:
    • One-off: POST/GET /api/jobs/{owner}, GET /api/jobs/{owner}/{id}, POST …/cancel, GET …/logs (SSE), GET …/metrics (SSE)
    • Hardware catalogue: GET /api/jobs/hardware — returns 5 real flavor entries
    • Scheduled: full CRUD + suspend/resume under /api/scheduled-jobs/{owner}/…
  • routes/mod.rs — routes wired in; hardware route registered before {owner} to avoid collision
  • Jobs land in QUEUED stage; cancel transitions to CANCELLED; SSE endpoints return a single stub event

Tests

  • tests/integration/hf_hub/test_jobs_stub_batch7.py — 14 pytest tests using the real huggingface_hub client:
job = run_job(image="python:3.12", command=["python", "-c", "print('hello')"],
              endpoint=hf_session["endpoint"], token=hf_session["token"])
assert job.status.stage == "QUEUED"
assert job.flavor == "cpu-basic"

cancel_job(job_id=job.id, endpoint=..., token=...)
assert inspect_job(job_id=job.id, ...).status.stage == "CANCELLED"

Tracking

  • docs/hf_hub_testing_roadmap.md — batch 7 added as planned; Jobs removed from explicit non-goals
  • resources/hf_hub_compat/checklist.json — batch 7 entry; jobsjobs_full_compute in non_goals
  • docs/feature_support_matrix.md — Jobs/Compute: In Roadmap ✅, status ⚠️ (stub)

Copilot AI changed the title [WIP] Add mocked support for HF's Jobs API thread(jobs): mocked drop-in stub for the full HF Jobs API Mar 31, 2026
Copilot AI requested a review from DiTo97 March 31, 2026 07:26
@DiTo97 DiTo97 changed the title thread(jobs): mocked drop-in stub for the full HF Jobs API Teams(jobs): mock drop-in stub for the full HF Jobs API Mar 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants