You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/source/en/guides/cli.md
+64-2Lines changed: 64 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -611,7 +611,7 @@ Run compute jobs on Hugging Face infrastructure with a familiar Docker-like inte
611
611
612
612
```bash
613
613
# Directly run Python code
614
-
>>> hf 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!")'
615
615
616
616
# Use GPUs without any setup
617
617
>>> hf jobs run --flavor a10g-small pytorch/pytorch:2.6.0-cuda12.4-cudnn9-devel \
@@ -636,6 +636,12 @@ Run compute jobs on Hugging Face infrastructure with a familiar Docker-like inte
636
636
- 📊 **Live Monitoring**: Stream logs in real-time, just like running locally
637
637
- 💰 **Pay-as-you-go**: Only pay for the seconds you use
638
638
639
+
<Tip>
640
+
641
+
**Hugging Face Jobs** are available only to [Pro users](https://huggingface.co/pro) and [Team or Enterprise organizations](https://huggingface.co/enterprise). Upgrade your plan to get started!
642
+
643
+
</Tip>
644
+
639
645
### Quick Start
640
646
641
647
#### 1. Run your first job
@@ -714,6 +720,14 @@ You can pass environment variables to your job using
714
720
>>> hf jobs run --secrets-file .env.secrets python:3.12 python -c "import os; print(os.environ['MY_SECRET'])"
715
721
```
716
722
723
+
<Tip>
724
+
725
+
Use `--secrets HF_TOKEN` to pass your local Hugging Face token implicitly.
726
+
With this syntax, the secret is retrieved from the environment variable.
727
+
For `HF_TOKEN`, it may read the token file located in the Hugging Face home folder if the environment variable is unset.
728
+
729
+
</Tip>
730
+
717
731
### Hardware
718
732
719
733
Available `--flavor` options:
@@ -739,10 +753,58 @@ Run UV scripts (Python scripts with inline dependencies) on HF infrastructure:
739
753
>>> hf jobs uv run ml_training.py --flavor gpu-t4-small
740
754
741
755
# Pass arguments to script
742
-
>>> hf jobs uv run process.py input.csv output.parquet --repo data-scripts
756
+
>>> hf jobs uv run process.py input.csv output.parquet
757
+
758
+
# Add dependencies
759
+
>>> hf jobs uv run --with transformers --with torch train.py
743
760
744
761
# Run a script directly from a URL
745
762
>>> hf jobs uv run https://huggingface.co/datasets/username/scripts/resolve/main/example.py
763
+
764
+
# Run a command
765
+
>>> hf jobs uv run --with lighteval python -c "import lighteval"
746
766
```
747
767
748
768
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/).
769
+
770
+
### Scheduled Jobs
771
+
772
+
Schedule and manage jobs that will run on HF infrastructure.
773
+
774
+
The schedule should be one of `@annually`, `@yearly`, `@monthly`, `@weekly`, `@daily`, `@hourly`, or a CRON schedule expression (e.g., `"0 9 * * 1"`for 9 AM every Monday).
775
+
776
+
```bash
777
+
# Schedule a job that runs every hour
778
+
>>> hf jobs scheduled run @hourly python:3.12 python -c 'print("This runs every hour!")'
779
+
780
+
# Use the CRON syntax
781
+
>>> hf jobs scheduled run "*/5 * * * *" python:3.12 python -c 'print("This runs every 5 minutes!")'
782
+
783
+
# Schedule with GPU
784
+
>>> hf jobs scheduled run @hourly --flavor a10g-small pytorch/pytorch:2.6.0-cuda12.4-cudnn9-devel \
785
+
... python -c "import torch; print(f"This code ran with the following GPU: {torch.cuda.get_device_name()}")"
786
+
787
+
# Schedule a UV script
788
+
>>> hf jobs scheduled uv run @hourly my_script.py
789
+
```
790
+
791
+
Use the same parameters as `hf jobs run` to pass environment variables, secrets, timeout, etc.
0 commit comments