Skip to content

Add jobs in @huggingface/hub & hfjs cli#1925

Merged
coyotte508 merged 20 commits into
mainfrom
hfjobs
Jan 22, 2026
Merged

Add jobs in @huggingface/hub & hfjs cli#1925
coyotte508 merged 20 commits into
mainfrom
hfjobs

Conversation

@coyotte508
Copy link
Copy Markdown
Member

@coyotte508 coyotte508 commented Jan 20, 2026

cf @Wauplin for viz

useful to test jobs change in hf.co (ongoing PRs)

cli only contains a few endpoints, and tries to use same syntax as python lib

diffrence with python cli:

  • add new params (name, attempts) to test them
  • user needs to add "--", eg:
hfjs jobs run -e FOO=foo -e BAR=bar python:3.12 -- python -c 'import os; print(os.environ["FOO"], os.environ["BAR"])'

(was complicated to do otherwise)


Note

Adds first-class Jobs support to the JS Hub SDK and CLI.

  • New jobs SDK: runJob, listJobs, getJob, duplicateJob, cancelJob, log/event/metric streaming, hardware listing, and full scheduled jobs lifecycle (create, list, get, run, suspend, resume, delete); exported via src/lib/jobs and new API types.
  • CLI (hfjs): new jobs subcommands—run, ps, hardware, logs—with env/secret flags, hardware flavor selection, log streaming, and namespace auto-resolve; improved --help handling and advanced arg parsing (multi-value positionals/options).
  • Types: extend SpaceHardwareFlavor set and introduce job types (ApiJob, ApiScheduledJob, etc.).
  • Docs/Build: README adds hfjs help jobs; tsconfig enables source maps.

Written by Cursor Bugbot for commit b1e9e87. This will update automatically on new commits. Configure here.

@coyotte508 coyotte508 marked this pull request as draft January 20, 2026 12:05
@HuggingFaceDocBuilderDev
Copy link
Copy Markdown

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@coyotte508 coyotte508 marked this pull request as ready for review January 20, 2026 15:32
cursor[bot]

This comment was marked as outdated.

- Add null check for envVars before iterating (matching secretVars pattern)
- Add existence check for providedPositionalTokens[i] before accessing .value

Co-authored-by: eliott <eliott@huggingface.co>
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

Comment thread packages/hub/cli.ts Outdated
Comment thread packages/hub/cli.ts Outdated
- Fix ParsedArgsResult type: multiple optional options can be undefined
- Use hf.co/ prefix to identify Space IDs, otherwise treat as Docker image
  This fixes the issue where org/image Docker images without tags were
  misidentified as HuggingFace Space IDs

Co-authored-by: eliott <eliott@huggingface.co>
Comment thread packages/hub/cli.ts Outdated
Comment on lines 802 to 811
if (firstArg.startsWith("hf.co/")) {
// hf.co/spaces/namespace/space-name or hf.co/namespace/space-name
const hfCoSpacesMatch = firstArg.match(/^hf\.co\/spaces\/(.+)$/);
if (hfCoSpacesMatch) {
spaceId = hfCoSpacesMatch[1];
} else {
// hf.co/namespace/space-name format
spaceId = firstArg.slice("hf.co/".length);
}
} else {
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@cursor just check on hf.co/spaces/* and extract the space id ("*") do not handle any other format for space id

Copy link
Copy Markdown

@cursor cursor Bot Jan 20, 2026

Choose a reason for hiding this comment

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

Simplified the Space ID detection logic:

  • Only hf.co/spaces/* format is recognized as a Space ID (extracts the * part)
  • Everything else is treated as a Docker image

This removes the ambiguity with Docker images like pytorch/pytorch or nvidia/cuda.

Open in Cursor Open in Web

cursoragent and others added 3 commits January 20, 2026 16:50
Everything else is treated as a Docker image.

Co-authored-by: eliott <eliott@huggingface.co>
@coyotte508 coyotte508 merged commit 08956cd into main Jan 22, 2026
7 checks passed
@coyotte508 coyotte508 deleted the hfjobs branch January 22, 2026 16:40
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.

3 participants