Skip to content

[Jobs] Add update_job_labels and update_scheduled_job_labels#4252

Merged
Wauplin merged 2 commits into
mainfrom
jobs-update-labels
May 26, 2026
Merged

[Jobs] Add update_job_labels and update_scheduled_job_labels#4252
Wauplin merged 2 commits into
mainfrom
jobs-update-labels

Conversation

@Wauplin

@Wauplin Wauplin commented May 22, 2026

Copy link
Copy Markdown
Collaborator

Summary

Client-side support for label update endpoints added in https://github.com/huggingface-internal/moon-landing/pull/17932.

  • Add HfApi.update_job_labels() and HfApi.update_scheduled_job_labels() (PUT /api/jobs/:ns/:id/labels and PUT /api/scheduled-jobs/:ns/:id/labels)
  • Add CLI commands hf jobs labels and hf jobs scheduled labels with --clear flag to prevent accidental label deletion
  • Docs + tests
>>> hf jobs labels <job_id> --label env=prod --label team=ml
>>> hf jobs labels <job_id> --clear
>>> hf jobs scheduled labels <id> --label env=staging

🤖 Generated with Claude Code


Note

Low Risk
Low risk: adds new Jobs/Scheduled Jobs label update endpoints and CLI wiring without changing existing job execution logic; main risk is accidental label replacement/clearing, mitigated by explicit --clear and argument validation.

Overview
Adds client support to replace (or clear) user labels on existing Jobs and Scheduled Jobs via new HfApi.update_job_labels and HfApi.update_scheduled_job_labels (PUT to /labels endpoints), and exports them at the package top-level.

Extends the CLI with hf jobs labels and hf jobs scheduled labels, including validation to require --label or --clear (but not both), and updates docs/CLI reference plus tests covering the new command behavior.

Reviewed by Cursor Bugbot for commit e2ef6ef. Bugbot is set up for automated code reviews on this repo. Configure here.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Wauplin Wauplin requested a review from hanouticelina May 22, 2026 14:53
labels = _parse_labels_map(label) or {}
api = get_hf_api(token=token)
job = api.update_job_labels(job_id=job_id, labels=labels, namespace=namespace)
print(json.dumps(asdict(job), indent=4, default=str))

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I realized while opening this PR that Jobs CLI do not use out yet. I can address that in another PR if it's not already in your list @hanouticelina

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

on it right now

@cursor cursor Bot left a comment

Copy link
Copy Markdown

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 using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit fefd1f7. Configure here.

Comment thread src/huggingface_hub/hf_api.py Outdated
@bot-ci-comment

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.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

@hanouticelina hanouticelina left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks good to me! thank you
not super important but maybe let's merge #4254 first (opening a follow-up PR to migrate these two commands is okay too)

@Wauplin

Wauplin commented May 26, 2026

Copy link
Copy Markdown
Collaborator Author

not super important but maybe let's merge #4254 first

Yes I'm fine wih that :)

@Wauplin

Wauplin commented May 26, 2026

Copy link
Copy Markdown
Collaborator Author

not super important but maybe let's merge #4254 first

Since this one is ready and #4256 not yet, I'll merge this one first instead.

@Wauplin Wauplin merged commit 112027d into main May 26, 2026
34 of 37 checks passed
@Wauplin Wauplin deleted the jobs-update-labels branch May 26, 2026 13:36
@huggingface-hub-bot

Copy link
Copy Markdown
Contributor

This PR has been shipped as part of the v1.17.0 release.

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