[Jobs] Add update_job_labels and update_scheduled_job_labels#4252
Conversation
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
| 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)) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ 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.
|
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
left a comment
There was a problem hiding this comment.
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)
Yes I'm fine wih that :) |
|
This PR has been shipped as part of the v1.17.0 release. |

Summary
Client-side support for label update endpoints added in https://github.com/huggingface-internal/moon-landing/pull/17932.
HfApi.update_job_labels()andHfApi.update_scheduled_job_labels()(PUT /api/jobs/:ns/:id/labelsandPUT /api/scheduled-jobs/:ns/:id/labels)hf jobs labelsandhf jobs scheduled labelswith--clearflag to prevent accidental label deletion🤖 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
--clearand argument validation.Overview
Adds client support to replace (or clear) user labels on existing Jobs and Scheduled Jobs via new
HfApi.update_job_labelsandHfApi.update_scheduled_job_labels(PUT to/labelsendpoints), and exports them at the package top-level.Extends the CLI with
hf jobs labelsandhf jobs scheduled labels, including validation to require--labelor--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.