Skip to content

Commit 62e9ea4

Browse files
[Docs] Reflect the 0.20 changes related to working_dir and repo_dir
1 parent df8b20a commit 62e9ea4

2 files changed

Lines changed: 107 additions & 65 deletions

File tree

docs/docs/concepts/services.md

Lines changed: 44 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -597,15 +597,12 @@ resources:
597597

598598
### Working directory
599599

600-
If `working_dir` is not specified, it defaults to `/workflow`.
600+
If `working_dir` is not specified, it defaults to the working directory set in the Docker image. For example, the [default image](#default-image) uses `/dstack/run` as its working directory.
601601

602-
!!! info "No commands"
603-
If you’re using a custom `image` without `commands`, then `working_dir` is taken from `image`.
602+
If the Docker image does not have a working directory set, `dstack` uses `/` as the `working_dir`.
604603

605604
The `working_dir` must be an absolute path. The tilde (`~`) is supported (e.g., `~/my-working-dir`).
606605

607-
<!-- TODO: In a future version, the default working directory will be taken from `image`. -->
608-
609606
<!-- TODO: Elaborate on `entrypoint` -->
610607

611608
### Files
@@ -621,7 +618,7 @@ type: service
621618
name: llama-2-7b-service
622619
623620
files:
624-
- .:examples # Maps the directory where `.dstack.yml` to `/workflow/examples`
621+
- .:examples # Maps the directory with `.dstack.yml` to `<working dir>/examples`
625622
- ~/.ssh/id_rsa:/root/.ssh/id_rsa # Maps `~/.ssh/id_rsa` to `/root/.ssh/id_rsa`
626623

627624
python: 3.12
@@ -640,11 +637,10 @@ resources:
640637
641638
</div>
642639
643-
Each entry maps a local directory or file to a path inside the container. Both local and container paths can be relative or absolute.
644-
645-
If the local path is relative, it’s resolved relative to the configuration file. If the container path is relative, it’s resolved relative to `/workflow`.
640+
If the local path is relative, it’s resolved relative to the configuration file.
641+
If the container path is relative, it’s resolved relative to the [working directory](#working-directory).
646642
647-
The container path is optional. If not specified, it will be automatically calculated.
643+
The container path is optional. If not specified, it will be automatically calculated:
648644
649645
<!-- TODO: Add a more relevant example -->
650646
@@ -655,7 +651,7 @@ type: service
655651
name: llama-2-7b-service
656652

657653
files:
658-
- ../examples # Maps `examples` (the parent directory of `.dstack.yml`) to `/workflow/examples`
654+
- ../examples # Maps the parent directory of `.dstack.yml` to `<working dir>/../examples`
659655
- ~/.ssh/id_rsa # Maps `~/.ssh/id_rsa` to `/root/.ssh/id_rsa`
660656

661657
python: 3.12
@@ -681,9 +677,9 @@ resources:
681677

682678
### Repos
683679

684-
Sometimes, you may want to mount an entire Git repo inside the container.
680+
Sometimes, you may want to clone an entire Git repo inside the container.
685681

686-
Imagine you have a cloned Git repo containing an `examples` subdirectory with a `.dstack.yml` file:
682+
Imagine you have a Git repo (clonned locally) containing an `examples` subdirectory with a `.dstack.yml` file:
687683

688684
<!-- TODO: Add a more relevant example -->
689685

@@ -694,8 +690,7 @@ type: service
694690
name: llama-2-7b-service
695691
696692
repos:
697-
# Mounts the parent directory of `examples` (must be a Git repo)
698-
# to `/workflow` (the default working directory)
693+
# Clones the repo from the parent directory (`examples/..`) to `<working dir>`
699694
- ..
700695

701696
python: 3.12
@@ -714,12 +709,12 @@ resources:
714709
715710
</div>
716711
717-
When you run it, `dstack` fetches the repo on the instance, applies your local changes, and mounts it—so the container matches your local repo.
712+
When you run it, `dstack` clones the repo on the instance, applies your local changes, and mounts it—so the container matches your local repo.
718713

719714
The local path can be either relative to the configuration file or absolute.
720715

721716
??? info "Repo directory"
722-
By default, `dstack` mounts the repo to `/workflow` (the default working directory).
717+
By default, `dstack` clones the repo to the [working directory](#working-directory).
723718

724719
<!-- TODO: In a future version, the default working directory will come from the image, so this should be revisited. -->
725720

@@ -732,8 +727,7 @@ The local path can be either relative to the configuration file or absolute.
732727
name: llama-2-7b-service
733728
734729
repos:
735-
# Mounts the parent directory of `examples` (must be a Git repo)
736-
# to `/my-repo`
730+
# Clones the repo in the parent directory (`examples/..`) to `/my-repo`
737731
- ..:/my-repo
738732

739733
python: 3.12
@@ -752,16 +746,41 @@ The local path can be either relative to the configuration file or absolute.
752746
753747
</div>
754748
755-
If the path is relative, it is resolved against `working_dir`.
749+
> If the repo directory is relative, it is resolved against [working directory](#working-directory).
750+
751+
If the repo directory is not empty, the run will fail with a runner error.
752+
To override this behavior, you can set `if_exists` to `skip`:
753+
754+
```yaml
755+
type: service
756+
name: llama-2-7b-service
757+
758+
repos:
759+
- local_path: ..
760+
path: /my-repo
761+
if_exists: skip
762+
763+
python: 3.12
764+
765+
env:
766+
- HF_TOKEN
767+
- MODEL=NousResearch/Llama-2-7b-chat-hf
768+
commands:
769+
- uv pip install vllm
770+
- python -m vllm.entrypoints.openai.api_server --model $MODEL --port 8000
771+
port: 8000
772+
773+
resources:
774+
gpu: 24GB
775+
```
756776

757777
??? info "Repo size"
758778
The repo size is not limited. However, local changes are limited to 2MB.
759779
To avoid exceeding this limit, exclude unnecessary files using `.gitignore` or `.dstackignore`.
760780
You can increase the 2MB limit by setting the `DSTACK_SERVER_CODE_UPLOAD_LIMIT` environment variable.
761781

762782
??? info "Repo URL"
763-
764-
Sometimes you may want to mount a Git repo without cloning it locally. In this case, simply provide a URL in `repos`:
783+
Sometimes you may want to clone a Git repo within the container without cloning it locally. In this case, simply provide a URL in `repos`:
765784

766785
<!-- TODO: Add a more relevant example -->
767786

@@ -772,7 +791,7 @@ The local path can be either relative to the configuration file or absolute.
772791
name: llama-2-7b-service
773792
774793
repos:
775-
# Clone the specified repo to `/workflow` (the default working directory)
794+
# Clone the repo to `<working dir>`
776795
- https://github.com/dstackai/dstack
777796

778797
python: 3.12
@@ -795,9 +814,9 @@ The local path can be either relative to the configuration file or absolute.
795814
If a Git repo is private, `dstack` will automatically try to use your default Git credentials (from
796815
`~/.ssh/config` or `~/.config/gh/hosts.yml`).
797816

798-
If you want to use custom credentials, you can provide them with [`dstack init`](../reference/cli/dstack/init.md).
817+
> If you want to use custom credentials, you can provide them with [`dstack init`](../reference/cli/dstack/init.md).
799818

800-
> Currently, you can configure up to one repo per run configuration.
819+
Currently, you can configure up to one repo per run configuration.
801820

802821
### Retry policy
803822

0 commit comments

Comments
 (0)