Accept namespace/job_id format in jobs CLI commands (#3811)
* Accept `namespace/job_id` format in jobs CLI commands
The Hub UI displays job IDs as `namespace/job_id` (e.g. `davanstrien/699044a...`)
but the CLI only accepted bare job IDs. Users who copy-paste from the UI had to
manually strip the namespace prefix.
This adds parsing of the `namespace/job_id` format in all job CLI commands
(logs, stats, inspect, cancel, and scheduled job variants). If the namespace
is also provided explicitly via `--namespace` and conflicts, a clear error
is raised. Bare job IDs continue to work as before.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Fix multi-ID commands silently using wrong namespace
Parse job IDs sequentially so the namespace accumulates across IDs.
This catches conflicts like `hf jobs inspect alice/job1 bob/job2`
instead of silently applying the first namespace to all IDs.
Also fix unused imports and add test for mixed-namespace error.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Harden job ID parser with shape validation
Validate job ID format before parsing: reject empty IDs, multiple
slashes, and missing namespace or ID components. Matches the
validate_repo_id style of shape-checking first.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Update generated CLI reference docs
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Update src/huggingface_hub/cli/jobs.py
Co-authored-by: Lucain <lucain@huggingface.co>
* Update src/huggingface_hub/cli/jobs.py
Co-authored-by: Lucain <lucain@huggingface.co>
* Update src/huggingface_hub/cli/jobs.py
Co-authored-by: Lucain <lucain@huggingface.co>
* Refactor tests to unit test _parse_namespace_from_job_id directly
Per review feedback, test the parser function directly instead of
going through CLI commands with mocks. Simpler and easier to read.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Fix leftover `jid` reference in jobs_stats after variable rename
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Fix ruff formatting: remove extra blank line
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Consolidate tests into parametrized form with top-level imports
Per review: move imports to top level, group success and error cases
into two parametrized tests for readability.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: Lucain <lucain@huggingface.co>