Skip to content

Commit 325bf8b

Browse files
[Docs] Added Files documentation (#2866)
* [Docs] Added `Files` to `concepts/dev-environments`, `concepts/tasks.md`, and `concepts/services.md` * [Docs] Mentioned `.gitignore` and `dstackignore` in `Files` section
1 parent a510369 commit 325bf8b

File tree

5 files changed

+268
-18
lines changed

5 files changed

+268
-18
lines changed

docs/docs/concepts/dev-environments.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,70 @@ If you don't assign a value to an environment variable (see `HF_TOKEN` above),
295295
| `DSTACK_REPO_ID` | The ID of the repo |
296296
| `DSTACK_GPUS_NUM` | The total number of GPUs in the run |
297297

298+
### Files
299+
300+
By default, `dstack` automatically mounts the [repo](repos.md) directory where you ran `dstack init` to any run configuration.
301+
302+
However, in some cases, you may not want to mount the entire directory (e.g., if it’s too large),
303+
or you might want to mount files outside of it. In such cases, you can use the [`files`](../reference/dstack.yml/dev-environment.md#files) property.
304+
305+
<div editor-title="examples/.dstack.yml">
306+
307+
```yaml
308+
type: dev-environment
309+
name: vscode
310+
311+
files:
312+
- .:examples # Maps the directory where `.dstack.yml` to `/workflow/examples`
313+
- ~/.ssh/id_rsa:/root/.ssh/id_rsa # Maps `~/.ssh/id_rsa` to `/root/.ssh/id_rsa`
314+
315+
ide: vscode
316+
```
317+
318+
</div>
319+
320+
Each entry maps a local directory or file to a path inside the container. Both local and container paths can be relative or absolute.
321+
322+
- If the local path is relative, it’s resolved relative to the configuration file.
323+
- If the container path is relative, it’s resolved relative to `/workflow`.
324+
325+
The container path is optional. If not specified, it will be automatically calculated.
326+
327+
<div editor-title="examples/.dstack.yml">
328+
329+
```yaml
330+
type: dev-environment
331+
name: vscode
332+
333+
files:
334+
- ../examples # Maps `examples` (the parent directory of `.dstack.yml`) to `/workflow/examples`
335+
- ~/.ssh/id_rsa # Maps `~/.ssh/id_rsa` to `/root/.ssh/id_rsa`
336+
337+
ide: vscode
338+
```
339+
340+
</div>
341+
342+
Note: If you want to use `files` without mounting the entire repo directory,
343+
make sure to pass `--no-repo` when running `dstack apply`:
344+
345+
<div class="termy">
346+
347+
```shell
348+
$ dstack apply -f examples/.dstack.yml --no-repo
349+
```
350+
351+
</div>
352+
353+
??? info ".gitignore and .dstackignore"
354+
`dstack` automatically excludes files and folders listed in `.gitignore` and `.dstackignore`.
355+
356+
Uploads are limited to 2MB. To avoid exceeding this limit, make sure to exclude unnecessary files.
357+
You can increase the default server limit by setting the `DSTACK_SERVER_CODE_UPLOAD_LIMIT` environment variable.
358+
359+
!!! warning "Experimental"
360+
The `files` feature is experimental. Feedback is highly appreciated.
361+
298362
### Retry policy
299363

300364
By default, if `dstack` can't find capacity or the instance is interrupted, the run will fail.

docs/docs/concepts/services.md

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,98 @@ resources:
513513

514514
<!-- TODO: Ellaborate on using environment variables in `registry_auth` -->
515515

516+
### Files
517+
518+
By default, `dstack` automatically mounts the [repo](repos.md) directory where you ran `dstack init` to any run configuration.
519+
520+
However, in some cases, you may not want to mount the entire directory (e.g., if it’s too large),
521+
or you might want to mount files outside of it. In such cases, you can use the [`files`](../reference/dstack.yml/dev-environment.md#files) property.
522+
523+
<!-- TODO: Add a more relevant example -->
524+
525+
<div editor-title="examples/.dstack.yml">
526+
527+
```yaml
528+
type: service
529+
name: llama-2-7b-service
530+
531+
files:
532+
- .:examples # Maps the directory where `.dstack.yml` to `/workflow/examples`
533+
- ~/.ssh/id_rsa:/root/.ssh/id_rsa # Maps `~/.ssh/id_rsa` to `/root/.ssh/id_rsa`
534+
535+
python: 3.12
536+
537+
env:
538+
- HF_TOKEN
539+
- MODEL=NousResearch/Llama-2-7b-chat-hf
540+
commands:
541+
- uv pip install vllm
542+
- python -m vllm.entrypoints.openai.api_server --model $MODEL --port 8000
543+
port: 8000
544+
545+
resources:
546+
gpu: 24GB
547+
```
548+
549+
</div>
550+
551+
Each entry maps a local directory or file to a path inside the container. Both local and container paths can be relative or absolute.
552+
553+
- If the local path is relative, it’s resolved relative to the configuration file.
554+
- If the container path is relative, it’s resolved relative to `/workflow`.
555+
556+
The container path is optional. If not specified, it will be automatically calculated.
557+
558+
<!-- TODO: Add a more relevant example -->
559+
560+
561+
<div editor-title="examples/.dstack.yml">
562+
563+
```yaml
564+
type: service
565+
name: llama-2-7b-service
566+
567+
files:
568+
- ../examples # Maps `examples` (the parent directory of `.dstack.yml`) to `/workflow/examples`
569+
- ~/.ssh/id_rsa # Maps `~/.ssh/id_rsa` to `/root/.ssh/id_rsa`
570+
571+
python: 3.12
572+
573+
env:
574+
- HF_TOKEN
575+
- MODEL=NousResearch/Llama-2-7b-chat-hf
576+
commands:
577+
- uv pip install vllm
578+
- python -m vllm.entrypoints.openai.api_server --model $MODEL --port 8000
579+
port: 8000
580+
581+
resources:
582+
gpu: 24GB
583+
```
584+
585+
</div>
586+
587+
Note: If you want to use `files` without mounting the entire repo directory,
588+
make sure to pass `--no-repo` when running `dstack apply`:
589+
590+
<div class="termy">
591+
592+
```shell
593+
$ dstack apply -f examples/.dstack.yml --no-repo
594+
```
595+
596+
</div>
597+
598+
??? info ".gitignore and .dstackignore"
599+
`dstack` automatically excludes files and folders listed in `.gitignore` and `.dstackignore`.
600+
601+
Uploads are limited to 2MB. To avoid exceeding this limit, make sure to exclude unnecessary files.
602+
You can increase the default server limit by setting the `DSTACK_SERVER_CODE_UPLOAD_LIMIT` environment variable.
603+
604+
605+
!!! warning "Experimental"
606+
The `files` feature is experimental. Feedback is highly appreciated.
607+
516608
### Retry policy
517609

518610
By default, if `dstack` can't find capacity, or the service exits with an error, or the instance is interrupted, the run will fail.

docs/docs/concepts/tasks.md

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,104 @@ If you don't assign a value to an environment variable (see `HF_TOKEN` above),
461461
| `DSTACK_NODES_IPS` | The list of internal IP addresses of all nodes delimited by "\n" |
462462
| `DSTACK_MPI_HOSTFILE` | The path to a pre-populated MPI hostfile |
463463

464+
### Files
465+
466+
By default, `dstack` automatically mounts the [repo](repos.md) directory where you ran `dstack init` to any run configuration.
467+
468+
However, in some cases, you may not want to mount the entire directory (e.g., if it’s too large),
469+
or you might want to mount files outside of it. In such cases, you can use the [`files`](../reference/dstack.yml/dev-environment.md#files) property.
470+
471+
<div editor-title="examples/.dstack.yml">
472+
473+
```yaml
474+
type: task
475+
name: trl-sft
476+
477+
files:
478+
- .:examples # Maps the directory where `.dstack.yml` to `/workflow/examples`
479+
- ~/.ssh/id_rsa:/root/.ssh/id_rsa # Maps `~/.ssh/id_rsa` to `/root/.ssh/id_rs
480+
481+
python: 3.12
482+
483+
env:
484+
- HF_TOKEN
485+
- HF_HUB_ENABLE_HF_TRANSFER=1
486+
- MODEL=Qwen/Qwen2.5-0.5B
487+
- DATASET=stanfordnlp/imdb
488+
489+
commands:
490+
- uv pip install trl
491+
- |
492+
trl sft \
493+
--model_name_or_path $MODEL --dataset_name $DATASET
494+
--num_processes $DSTACK_GPUS_PER_NODE
495+
496+
resources:
497+
gpu: H100:1
498+
```
499+
500+
</div>
501+
502+
Each entry maps a local directory or file to a path inside the container. Both local and container paths can be relative or absolute.
503+
504+
- If the local path is relative, it’s resolved relative to the configuration file.
505+
- If the container path is relative, it’s resolved relative to `/workflow`.
506+
507+
The container path is optional. If not specified, it will be automatically calculated.
508+
509+
<!-- TODO: Add a more elevant example -->
510+
511+
<div editor-title="examples/.dstack.yml">
512+
513+
```yaml
514+
type: task
515+
name: trl-sft
516+
517+
files:
518+
- ../examples # Maps `examples` (the parent directory of `.dstack.yml`) to `/workflow/examples`
519+
- ~/.cache/huggingface/token # Maps `~/.cache/huggingface/token` to `/root/~/.cache/huggingface/token`
520+
521+
python: 3.12
522+
523+
env:
524+
- HF_TOKEN
525+
- HF_HUB_ENABLE_HF_TRANSFER=1
526+
- MODEL=Qwen/Qwen2.5-0.5B
527+
- DATASET=stanfordnlp/imdb
528+
529+
commands:
530+
- uv pip install trl
531+
- |
532+
trl sft \
533+
--model_name_or_path $MODEL --dataset_name $DATASET
534+
--num_processes $DSTACK_GPUS_PER_NODE
535+
536+
resources:
537+
gpu: H100:1
538+
```
539+
540+
</div>
541+
542+
Note: If you want to use `files` without mounting the entire repo directory,
543+
make sure to pass `--no-repo` when running `dstack apply`:
544+
545+
<div class="termy">
546+
547+
```shell
548+
$ dstack apply -f examples/.dstack.yml --no-repo
549+
```
550+
551+
</div>
552+
553+
??? info ".gitignore and .dstackignore"
554+
`dstack` automatically excludes files and folders listed in `.gitignore` and `.dstackignore`.
555+
556+
Uploads are limited to 2MB. To avoid exceeding this limit, make sure to exclude unnecessary files.
557+
You can increase the default server limit by setting the `DSTACK_SERVER_CODE_UPLOAD_LIMIT` environment variable.
558+
559+
!!! warning "Experimental"
560+
The `files` feature is experimental. Feedback is highly appreciated.
561+
464562
### Retry policy
465563

466564
By default, if `dstack` can't find capacity, or the task exits with an error, or the instance is interrupted,

examples/.dstack.yml

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
11
type: dev-environment
2-
# The name is optional, if not specified, generated randomly
3-
name: vscode
2+
name: cursor
43

5-
#python: "3.11"
4+
python: 3.12
5+
ide: cursor
66

7-
image: un1def/dstack-base:py3.12-dev-cuda-12.1
8-
9-
ide: vscode
10-
11-
# Use either spot or on-demand instances
12-
#spot_policy: auto
7+
files:
8+
- .:examples
9+
- ~/.ssh/id_rsa:/root/.ssh/id_rsa
1310

1411
resources:
15-
cpu: x86:8..32
16-
gpu: 24GB..:1
12+
gpu: 1

mkdocs.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -124,13 +124,13 @@ plugins:
124124
'examples/fine-tuning/axolotl/index.md': 'examples/single-node-training/axolotl/index.md'
125125
'blog/efa.md': 'examples/clusters/efa/index.md'
126126
- typeset
127-
- gen-files:
128-
scripts: # always relative to mkdocs.yml
129-
- scripts/docs/gen_examples.py
130-
- scripts/docs/gen_cli_reference.py
131-
- scripts/docs/gen_openapi_reference.py
132-
- scripts/docs/gen_schema_reference.py
133-
- scripts/docs/gen_rest_plugin_spec_reference.py
127+
# - gen-files:
128+
# scripts: # always relative to mkdocs.yml
129+
# - scripts/docs/gen_examples.py
130+
# - scripts/docs/gen_cli_reference.py
131+
# - scripts/docs/gen_openapi_reference.py
132+
# - scripts/docs/gen_schema_reference.py
133+
# - scripts/docs/gen_rest_plugin_spec_reference.py
134134
- mkdocstrings:
135135
handlers:
136136
python:

0 commit comments

Comments
 (0)