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
+31Lines changed: 31 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1571,6 +1571,37 @@ Available `--flavor` options:
1571
1571
1572
1572
(updated in 07/2025 from Hugging Face [suggested_hardware docs](https://huggingface.co/docs/hub/en/spaces-config-reference))
1573
1573
1574
+
## Volumes
1575
+
1576
+
Mount a volume on the Job's disk using `-v` or `--volume`.
1577
+
1578
+
You can mount any Hugging Face Repository (model/dataset/space) or [Storage Bucket](/docs/hub/storage-buckets) using the `hf://` URL scheme. For example:
1579
+
1580
+
* mount a model repository: `-v hf://openai/gpt-oss-120b:/model`
1581
+
* mount a model repository (explicit type): `-v hf://models/openai/gpt-oss-120b:/model`
1582
+
* mount a dataset repository: `-v hf://datasets/HuggingFaceFW/fineweb:/data`
1583
+
* mount a storage bucket: `-v hf://buckets/username/my-bucket:/mnt`
1584
+
* mount a space: `-v hf://spaces/username/my-space:/app`
1585
+
* mount a subfolder inside a repo: `-v hf://datasets/org/ds/train:/data`
1586
+
1587
+
Then you can use the mounted volume as a local directory:
1588
+
1589
+
```bash
1590
+
# Docker Job with a mounted volume as input
1591
+
>>> hf jobs run -v hf://datasets/HuggingFaceFW/fineweb:/dataset \
1592
+
... duckdb/duckdb duckdb -c "SELECT * FROM '/dataset/**/*.parquet' LIMIT 5"
1593
+
1594
+
# UV Job with a mounted volume to save checkpoints when training a model
1595
+
>>> hf jobs uv run -v hf://buckets/username/my-bucket:/training-outputs \
Models, datasets and spaces are always mounted read-only. Storage buckets are read+write by default — this is especially useful for data that changes frequently, as files can be overwritten or deleted in place.
1600
+
1601
+
Use `:ro` to enable read-only:
1602
+
1603
+
* mount a storage bucket in read-only: `-v hf://buckets/username/my-bucket:/mnt:ro`
1604
+
1574
1605
### Labels
1575
1606
1576
1607
Add labels to a Job using `-l` or `--label`. Labels are a key=value pairs that applies metadata to a Job. To label a Job with two labels, repeat the label flag (`-l` or `--label`):
By default, mounted storage buckets have read+write abilities.
251
+
This is especially useful for storage buckets, which provide fast, mutable storage for data that changes frequently — files can be overwritten or deleted in place.
252
+
253
+
Use `read_only=True` to enable read-only: `Volume(type="bucket", read_only=True, ...)`.
254
+
219
255
## Configure Job Timeout
220
256
221
257
Jobs have a default timeout (30 minutes), after which they will automatically stop. This is important to know when running long-running tasks like model training.
Copy file name to clipboardExpand all lines: docs/source/en/package_reference/cli.md
+6Lines changed: 6 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2157,6 +2157,7 @@ $ hf jobs run [OPTIONS] IMAGE COMMAND...
2157
2157
*`-e, --env TEXT`: Set environment variables. E.g. --env ENV=value
2158
2158
*`-s, --secrets TEXT`: Set secret environment variables. E.g. --secrets SECRET=value or `--secrets HF_TOKEN` to pass your Hugging Face token.
2159
2159
*`-l, --label TEXT`: Set labels. E.g. --label KEY=VALUE or --label LABEL
2160
+
*`-v, --volume TEXT`: Mount a volume. Format: hf://[TYPE/]SOURCE:/MOUNT_PATH[:ro]. TYPE is one of: models, datasets, spaces, buckets. TYPE defaults to models if omitted. models, datasets and spaces are always mounted read-only. buckets are read+write by default.E.g. -v hf://gpt2:/data or -v hf://datasets/org/ds:/data or -v hf://buckets/org/b:/mnt:ro
2160
2161
*`--env-file TEXT`: Read in a file of environment variables.
2161
2162
*`--secrets-file TEXT`: Read in a file of secret environment variables.
2162
2163
*`--flavor [cpu-basic|cpu-upgrade|cpu-performance|cpu-xl|sprx8|zero-a10g|t4-small|t4-medium|l4x1|l4x4|l40sx1|l40sx4|l40sx8|a10g-small|a10g-large|a10g-largex2|a10g-largex4|a100-large|a100x4|a100x8|h200|h200x2|h200x4|h200x8|inf2x6]`: Flavor for the hardware, as in HF Spaces. Run 'hf jobs hardware' to list available flavors. Defaults to `cpu-basic`.
@@ -2170,6 +2171,7 @@ Examples
2170
2171
$ hf jobs run python:3.12 python -c 'print("Hello!")'
2171
2172
$ hf jobs run -e FOO=foo python:3.12 python script.py
2172
2173
$ hf jobs run --secrets HF_TOKEN python:3.12 python script.py
2174
+
$ hf jobs run -v hf://gpt2:/data -v hf://buckets/org/b:/mnt python:3.12 python script.py
2173
2175
2174
2176
Learn more
2175
2177
Use `hf <command> --help` for more information about a command.
@@ -2335,6 +2337,7 @@ $ hf jobs scheduled run [OPTIONS] SCHEDULE IMAGE COMMAND...
2335
2337
*`-e, --env TEXT`: Set environment variables. E.g. --env ENV=value
2336
2338
*`-s, --secrets TEXT`: Set secret environment variables. E.g. --secrets SECRET=value or `--secrets HF_TOKEN` to pass your Hugging Face token.
2337
2339
*`-l, --label TEXT`: Set labels. E.g. --label KEY=VALUE or --label LABEL
2340
+
*`-v, --volume TEXT`: Mount a volume. Format: hf://[TYPE/]SOURCE:/MOUNT_PATH[:ro]. TYPE is one of: models, datasets, spaces, buckets. TYPE defaults to models if omitted. models, datasets and spaces are always mounted read-only. buckets are read+write by default.E.g. -v hf://gpt2:/data or -v hf://datasets/org/ds:/data or -v hf://buckets/org/b:/mnt:ro
2338
2341
*`--env-file TEXT`: Read in a file of environment variables.
2339
2342
*`--secrets-file TEXT`: Read in a file of secret environment variables.
2340
2343
*`--flavor [cpu-basic|cpu-upgrade|cpu-performance|cpu-xl|sprx8|zero-a10g|t4-small|t4-medium|l4x1|l4x4|l40sx1|l40sx4|l40sx8|a10g-small|a10g-large|a10g-largex2|a10g-largex4|a100-large|a100x4|a100x8|h200|h200x2|h200x4|h200x8|inf2x6]`: Flavor for the hardware, as in HF Spaces. Run 'hf jobs hardware' to list available flavors. Defaults to `cpu-basic`.
@@ -2422,6 +2425,7 @@ $ hf jobs scheduled uv run [OPTIONS] SCHEDULE SCRIPT [SCRIPT_ARGS]...
2422
2425
*`-e, --env TEXT`: Set environment variables. E.g. --env ENV=value
2423
2426
*`-s, --secrets TEXT`: Set secret environment variables. E.g. --secrets SECRET=value or `--secrets HF_TOKEN` to pass your Hugging Face token.
2424
2427
*`-l, --label TEXT`: Set labels. E.g. --label KEY=VALUE or --label LABEL
2428
+
*`-v, --volume TEXT`: Mount a volume. Format: hf://[TYPE/]SOURCE:/MOUNT_PATH[:ro]. TYPE is one of: models, datasets, spaces, buckets. TYPE defaults to models if omitted. models, datasets and spaces are always mounted read-only. buckets are read+write by default.E.g. -v hf://gpt2:/data or -v hf://datasets/org/ds:/data or -v hf://buckets/org/b:/mnt:ro
2425
2429
*`--env-file TEXT`: Read in a file of environment variables.
2426
2430
*`--secrets-file TEXT`: Read in a file of secret environment variables.
2427
2431
*`--timeout TEXT`: Max duration: int/float with s (seconds, default), m (minutes), h (hours) or d (days).
@@ -2508,6 +2512,7 @@ $ hf jobs uv run [OPTIONS] SCRIPT [SCRIPT_ARGS]...
2508
2512
*`-e, --env TEXT`: Set environment variables. E.g. --env ENV=value
2509
2513
*`-s, --secrets TEXT`: Set secret environment variables. E.g. --secrets SECRET=value or `--secrets HF_TOKEN` to pass your Hugging Face token.
2510
2514
*`-l, --label TEXT`: Set labels. E.g. --label KEY=VALUE or --label LABEL
2515
+
*`-v, --volume TEXT`: Mount a volume. Format: hf://[TYPE/]SOURCE:/MOUNT_PATH[:ro]. TYPE is one of: models, datasets, spaces, buckets. TYPE defaults to models if omitted. models, datasets and spaces are always mounted read-only. buckets are read+write by default.E.g. -v hf://gpt2:/data or -v hf://datasets/org/ds:/data or -v hf://buckets/org/b:/mnt:ro
2511
2516
*`--env-file TEXT`: Read in a file of environment variables.
2512
2517
*`--secrets-file TEXT`: Read in a file of secret environment variables.
2513
2518
*`--timeout TEXT`: Max duration: int/float with s (seconds, default), m (minutes), h (hours) or d (days).
@@ -2522,6 +2527,7 @@ Examples
2522
2527
$ hf jobs uv run my_script.py
2523
2528
$ hf jobs uv run ml_training.py --flavor a10g-small
2524
2529
$ hf jobs uv run --with transformers train.py
2530
+
$ hf jobs uv run -v hf://gpt2:/data -v hf://buckets/org/b:/mnt script.py
2525
2531
2526
2532
Learn more
2527
2533
Use `hf <command> --help` for more information about a command.
0 commit comments