[CLI] Use out singleton in jobs labels commands#4265
Conversation
| "JobAccelerator", | ||
| "JobDurations", | ||
| "JobHardware", | ||
| "JobHardwareInfo", |
There was a problem hiding this comment.
Missing __init__.py exports for new API functions
High Severity
update_job_labels and update_scheduled_job_labels are aliased in hf_api.py and documented as importable from the top-level package (from huggingface_hub import update_job_labels), but they were never added to _SUBMOD_ATTRS["hf_api"], __all__, or the TYPE_CHECKING static imports in __init__.py. The lazy-loading __getattr__ will raise AttributeError for these names. The PR description explicitly says it restores these exports, but the change was not applied.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 7278df8. Configure here.
…labels` Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
7278df8 to
ccca14e
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
There are 2 total unresolved issues (including 1 from previous review).
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 931568e. Configure here.
| scheduled_job_id=scheduled_job_id, labels=labels, namespace=namespace | ||
| ) | ||
| print(json.dumps(asdict(scheduled_job), indent=4, default=str)) | ||
| out.dict(job) |
There was a problem hiding this comment.
Wrong variable name used in scheduled labels output
High Severity
out.dict(job) references an undefined variable job in this function scope. The API result is stored in scheduled_job (line 1034), so this will raise a NameError at runtime whenever hf jobs scheduled labels is invoked. It needs to be out.dict(scheduled_job).
Reviewed by Cursor Bugbot for commit 931568e. Configure here.
343779b
into
cli-migrate-jobs-out-singleton
| scheduled_job_id=scheduled_job_id, labels=labels, namespace=namespace | ||
| ) | ||
| print(json.dumps(asdict(scheduled_job), indent=4, default=str)) | ||
| out.result("Labels updated", id=job.id) |
There was a problem hiding this comment.
| out.result("Labels updated", id=job.id) | |
| out.result("Labels updated", id=scheduled_job_id.id) |
|
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. |
* migrate jobs * revert unnecessary changes * migrate jobs ps * headers * [CLI] Use out singleton in jobs labels commands (#4265) * Update src/huggingface_hub/cli/jobs.py * Update src/huggingface_hub/cli/jobs.py * Apply suggestion from @Wauplin * Apply suggestion from @Wauplin * Update src/huggingface_hub/cli/jobs.py * Update src/huggingface_hub/cli/jobs.py --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> * fix * review suggestion * fixes --------- Co-authored-by: Lucain <lucain@huggingface.co> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> Co-authored-by: Lucain Pouget <lucainp@gmail.com>


Summary
hf jobs labelsandhf jobs scheduled labelsto use theoutsingleton instead ofprint(json.dumps(...)), following the same pattern as other mutation commands (cancel,delete,suspend, etc.).update_job_labels/update_scheduled_job_labelsexports in__init__.pyand regenerate CLI reference docs.Addresses #4252 (review).
Example output after the change:
🤖 Generated with Claude Code
Note
Medium Risk
Scheduled labels likely fails at runtime due to undefined
job; the regular jobs labels path is a straightforward output change only.Overview
hf jobs labelsandhf jobs scheduled labelsno longer dump the full API object as indented JSON; they now use the sharedout.resulthelper with a short “Labels updated” message and the resource id, matching other mutation commands likecancelandscheduled delete.In
scheduled_labels, the new success line usesid=job.id, but that handler only definesscheduled_job—this looks like a copy-paste bug and would break the scheduled labels command at runtime.Reviewed by Cursor Bugbot for commit 1bf8424. Bugbot is set up for automated code reviews on this repo. Configure here.