Skip to content

Commit e06eac3

Browse files
authored
Rename huggingface-cli jobs to hf jobs (#3250)
1 parent e981dea commit e06eac3

File tree

7 files changed

+44
-32
lines changed

7 files changed

+44
-32
lines changed

docs/source/en/guides/cli.md

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -603,28 +603,28 @@ Copy-and-paste the text below in your GitHub issue.
603603
- HF_HUB_DOWNLOAD_TIMEOUT: 10
604604
```
605605
606-
## huggingface-cli jobs
606+
## hf jobs
607607
608608
Run compute jobs on Hugging Face infrastructure with a familiar Docker-like interface.
609609
610-
`huggingface-cli jobs` is a command-line tool that lets you run anything on Hugging Face's infrastructure (including GPUs and TPUs!) with simple commands. Think `docker run`, but for running code on A100s.
610+
`hf jobs` is a command-line tool that lets you run anything on Hugging Face's infrastructure (including GPUs and TPUs!) with simple commands. Think `docker run`, but for running code on A100s.
611611
612612
```bash
613613
# Directly run Python code
614-
>>> huggingface-cli jobs run python:3.12 python -c "print('Hello from the cloud!')"
614+
>>> hf jobs run python:3.12 python -c "print('Hello from the cloud!')"
615615

616616
# Use GPUs without any setup
617-
>>> huggingface-cli jobs run --flavor a10g-small pytorch/pytorch:2.6.0-cuda12.4-cudnn9-devel \
617+
>>> hf jobs run --flavor a10g-small pytorch/pytorch:2.6.0-cuda12.4-cudnn9-devel \
618618
... python -c "import torch; print(torch.cuda.get_device_name())"
619619

620620
# Run in an organization account
621-
>>> huggingface-cli jobs run --namespace my-org-name python:3.12 python -c "print('Running in an org account')"
621+
>>> hf jobs run --namespace my-org-name python:3.12 python -c "print('Running in an org account')"
622622

623623
# Run from Hugging Face Spaces
624-
>>> huggingface-cli jobs run hf.co/spaces/lhoestq/duckdb duckdb -c "select 'hello world'"
624+
>>> hf jobs run hf.co/spaces/lhoestq/duckdb duckdb -c "select 'hello world'"
625625

626626
# Run a Python script with `uv` (experimental)
627-
>>> huggingface-cli jobs uv run my_script.py
627+
>>> hf jobs uv run my_script.py
628628
```
629629
630630
### ✨ Key Features
@@ -642,7 +642,7 @@ Run compute jobs on Hugging Face infrastructure with a familiar Docker-like inte
642642
643643
```bash
644644
# Run a simple Python script
645-
>>> huggingface-cli jobs run python:3.12 python -c "print('Hello from HF compute!')"
645+
>>> hf jobs run python:3.12 python -c "print('Hello from HF compute!')"
646646
```
647647
648648
This command runs the job and shows the logs. You can pass `--detach` to run the Job in the background and only print the Job ID.
@@ -651,16 +651,16 @@ This command runs the job and shows the logs. You can pass `--detach` to run the
651651
652652
```bash
653653
# List your running jobs
654-
>>> huggingface-cli jobs ps
654+
>>> hf jobs ps
655655

656656
# Inspect the status of a job
657-
>>> huggingface-cli jobs inspect <job_id>
657+
>>> hf jobs inspect <job_id>
658658

659659
# View logs from a job
660-
>>> huggingface-cli jobs logs <job_id>
660+
>>> hf jobs logs <job_id>
661661

662662
# Cancel a job
663-
>>> huggingface-cli jobs cancel <job_id>
663+
>>> hf jobs cancel <job_id>
664664
```
665665
666666
#### 3. Run on GPU
@@ -669,7 +669,7 @@ You can also run jobs on GPUs or TPUs with the `--flavor` option. For example, t
669669
670670
```bash
671671
# Use an A10G GPU to check PyTorch CUDA
672-
>>> huggingface-cli jobs run --flavor a10g-small pytorch/pytorch:2.6.0-cuda12.4-cudnn9-devel \
672+
>>> hf jobs run --flavor a10g-small pytorch/pytorch:2.6.0-cuda12.4-cudnn9-devel \
673673
... python -c "import torch; print(f"This code ran with the following GPU: {torch.cuda.get_device_name()}")"
674674
```
675675
@@ -696,22 +696,22 @@ You can pass environment variables to your job using
696696
697697
```bash
698698
# Pass environment variables
699-
>>> huggingface-cli jobs run -e FOO=foo -e BAR=bar python:3.12 python -c "import os; print(os.environ['FOO'], os.environ['BAR'])"
699+
>>> hf jobs run -e FOO=foo -e BAR=bar python:3.12 python -c "import os; print(os.environ['FOO'], os.environ['BAR'])"
700700
```
701701
702702
```bash
703703
# Pass an environment from a local .env file
704-
>>> huggingface-cli jobs run --env-file .env python:3.12 python -c "import os; print(os.environ['FOO'], os.environ['BAR'])"
704+
>>> hf jobs run --env-file .env python:3.12 python -c "import os; print(os.environ['FOO'], os.environ['BAR'])"
705705
```
706706
707707
```bash
708708
# Pass secrets - they will be encrypted server side
709-
>>> huggingface-cli jobs run -s MY_SECRET=psswrd python:3.12 python -c "import os; print(os.environ['MY_SECRET'])"
709+
>>> hf jobs run -s MY_SECRET=psswrd python:3.12 python -c "import os; print(os.environ['MY_SECRET'])"
710710
```
711711
712712
```bash
713713
# Pass secrets from a local .env.secrets file - they will be encrypted server side
714-
>>> huggingface-cli jobs run --secrets-file .env.secrets python:3.12 python -c "import os; print(os.environ['MY_SECRET'])"
714+
>>> hf jobs run --secrets-file .env.secrets python:3.12 python -c "import os; print(os.environ['MY_SECRET'])"
715715
```
716716
717717
### Hardware
@@ -730,19 +730,19 @@ Run UV scripts (Python scripts with inline dependencies) on HF infrastructure:
730730
731731
```bash
732732
# Run a UV script (creates temporary repo)
733-
>>> huggingface-cli jobs uv run my_script.py
733+
>>> hf jobs uv run my_script.py
734734
735735
# Run with persistent repo
736-
>>> huggingface-cli jobs uv run my_script.py --repo my-uv-scripts
736+
>>> hf jobs uv run my_script.py --repo my-uv-scripts
737737
738738
# Run with GPU
739-
>>> huggingface-cli jobs uv run ml_training.py --flavor gpu-t4-small
739+
>>> hf jobs uv run ml_training.py --flavor gpu-t4-small
740740
741741
# Pass arguments to script
742-
>>> huggingface-cli jobs uv run process.py input.csv output.parquet --repo data-scripts
742+
>>> hf jobs uv run process.py input.csv output.parquet --repo data-scripts
743743
744744
# Run a script directly from a URL
745-
>>> huggingface-cli jobs uv run https://huggingface.co/datasets/username/scripts/resolve/main/example.py
745+
>>> hf jobs uv run https://huggingface.co/datasets/username/scripts/resolve/main/example.py
746746
```
747747
748748
UV scripts are Python scripts that include their dependencies directly in the file using a special comment syntax. This makes them perfect for self-contained tasks that don't require complex project setups. Learn more about UV scripts in the [UV documentation](https://docs.astral.sh/uv/guides/scripts/).

docs/source/en/guides/jobs.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ This feature is pay-as-you-go: you only pay for the seconds you use.
5959

6060
<Tip>
6161

62-
Use [huggingface-cli jobs](./cli#huggingface-cli-jobs) to run jobs in the command line.
62+
Use [hf jobs](./cli#hf-jobs) to run jobs in the command line.
6363

6464
</Tip>
6565

src/huggingface_hub/cli/hf.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
from huggingface_hub.cli.auth import AuthCommands
1818
from huggingface_hub.cli.cache import CacheCommand
1919
from huggingface_hub.cli.download import DownloadCommand
20+
from huggingface_hub.cli.jobs import JobsCommands
2021
from huggingface_hub.cli.lfs import LfsCommands
2122
from huggingface_hub.cli.repo import RepoCommands
2223
from huggingface_hub.cli.repo_files import RepoFilesCommand
@@ -33,6 +34,7 @@ def main():
3334
AuthCommands.register_subcommand(commands_parser)
3435
CacheCommand.register_subcommand(commands_parser)
3536
DownloadCommand.register_subcommand(commands_parser)
37+
JobsCommands.register_subcommand(commands_parser)
3638
RepoCommands.register_subcommand(commands_parser)
3739
RepoFilesCommand.register_subcommand(commands_parser)
3840
UploadCommand.register_subcommand(commands_parser)

src/huggingface_hub/commands/jobs.py renamed to src/huggingface_hub/cli/jobs.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,19 @@
1515
1616
Usage:
1717
# run a job
18-
huggingface-cli jobs run image command
18+
hf jobs run <image> <command>
19+
20+
# List running or completed jobs
21+
hf jobs ps [-a] [-f key=value] [--format TEMPLATE]
22+
23+
# Stream logs from a job
24+
hf jobs logs <job-id>
25+
26+
# Inspect detailed information about a job
27+
hf jobs inspect <job-id>
28+
29+
# Cancel a running job
30+
hf jobs cancel <job-id>
1931
"""
2032

2133
import json
@@ -43,7 +55,7 @@
4355
class JobsCommands(BaseHuggingfaceCLICommand):
4456
@staticmethod
4557
def register_subcommand(parser: _SubParsersAction):
46-
jobs_parser = parser.add_parser("jobs", help="Commands to interact with your huggingface.co jobs.")
58+
jobs_parser = parser.add_parser("jobs", help="Run and manage Jobs on the Hub.")
4759
jobs_subparsers = jobs_parser.add_subparsers(help="huggingface.co jobs related commands")
4860

4961
# Register commands

src/huggingface_hub/commands/huggingface_cli.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
from huggingface_hub.commands.delete_cache import DeleteCacheCommand
1919
from huggingface_hub.commands.download import DownloadCommand
2020
from huggingface_hub.commands.env import EnvironmentCommand
21-
from huggingface_hub.commands.jobs import JobsCommands
2221
from huggingface_hub.commands.lfs import LfsCommands
2322
from huggingface_hub.commands.repo import RepoCommands
2423
from huggingface_hub.commands.repo_files import RepoFilesCommand
@@ -46,7 +45,6 @@ def main():
4645
DeleteCacheCommand.register_subcommand(commands_parser)
4746
TagCommands.register_subcommand(commands_parser)
4847
VersionCommand.register_subcommand(commands_parser)
49-
JobsCommands.register_subcommand(commands_parser)
5048

5149
# Experimental
5250
UploadLargeFolderCommand.register_subcommand(commands_parser)

src/huggingface_hub/hf_api.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10390,16 +10390,16 @@ def run_uv_job(
1039010390
1039110391
# UV Script: {filename}
1039210392
10393-
Executed via `huggingface-cli jobs uv run` on {timestamp}
10393+
Executed via `hf jobs uv run` on {timestamp}
1039410394
1039510395
## Run this script
1039610396
1039710397
```bash
10398-
huggingface-cli jobs uv run {filename}
10398+
hf jobs uv run {filename}
1039910399
```
1040010400
1040110401
---
10402-
*Created with [huggingface-cli jobs](https://github.com/huggingface/huggingface-cli jobs)*
10402+
*Created with [hf jobs](https://huggingface.co/docs/huggingface_hub/main/en/guides/jobs)*
1040310403
"""
1040410404
)
1040510405
self.upload_file(

tests/test_cli.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99

1010
from huggingface_hub.cli.cache import CacheCommand
1111
from huggingface_hub.cli.download import DownloadCommand
12+
from huggingface_hub.cli.jobs import JobsCommands, RunCommand
1213
from huggingface_hub.cli.repo import RepoCommands
1314
from huggingface_hub.cli.repo_files import DeleteFilesSubCommand, RepoFilesCommand
1415
from huggingface_hub.cli.upload import UploadCommand
15-
from huggingface_hub.commands.jobs import JobsCommands, RunCommand
1616
from huggingface_hub.errors import RevisionNotFoundError
1717
from huggingface_hub.utils import SoftTemporaryDirectory, capture_output
1818

@@ -844,7 +844,7 @@ def setUp(self) -> None:
844844
"""
845845
Set up CLI as in `src/huggingface_hub/commands/huggingface_cli.py`.
846846
"""
847-
self.parser = ArgumentParser("huggingface-cli", usage="huggingface-cli <command> [<args>]")
847+
self.parser = ArgumentParser("hf", usage="hf <command> [<args>]")
848848
commands_parser = self.parser.add_subparsers()
849849
JobsCommands.register_subcommand(commands_parser)
850850

0 commit comments

Comments
 (0)