Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/dstack/_internal/server/services/jobs/configurators/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@
DSTACK_DIR = "/dstack"
DSTACK_PROFILE_PATH = f"{DSTACK_DIR}/profile"

# A directory with preinstalled Python builds in dstackai/base image
UV_PYTHON_INSTALL_DIR = "/opt/uv/python"

# A non-existent image name used to signal that the image registry must never be requested
# and some dummy defaults should be used instead.
# As a job with such an image cannot be started, this special value only makes sense
Expand Down Expand Up @@ -290,6 +293,7 @@ def _dstack_image_commands(self) -> List[str]:
or self.run_spec.configuration.entrypoint is not None
):
return []
python = self._python()
return [
f"eval $(echo 'export DSTACK_VENV_DIR={DSTACK_DIR}/venv' | sudo tee -a {DSTACK_PROFILE_PATH})",
# Make sure /dstack/venv is owned by the current user.
Expand All @@ -310,7 +314,13 @@ def _dstack_image_commands(self) -> List[str]:
# used for legacy `pip`-based configurations). `--no-active` suppresses the warning.
# Alternatively, the user can call `deactivate` once before using `uv`.
# If the user really wants to reuse dstack's venv, they must spefify `--active`.
f"uv venv -q --prompt dstack -p {self._python()} --seed $DSTACK_VENV_DIR",
# Use the preinstalled Python build if available, otherwise let `uv` download it.
# The subshell keeps the `UV_*` variables out of the user's commands.
(
f"(if UV_PYTHON_INSTALL_DIR={UV_PYTHON_INSTALL_DIR} uv python find {python} > /dev/null 2>&1;"
f" then export UV_PYTHON_INSTALL_DIR={UV_PYTHON_INSTALL_DIR} UV_PYTHON_DOWNLOADS=never; fi;"
f" uv venv -q --prompt dstack -p {python} --seed $DSTACK_VENV_DIR)"
),
f"eval $(echo '. $DSTACK_VENV_DIR/bin/activate' | sudo tee -a {DSTACK_PROFILE_PATH})",
]

Expand Down
2 changes: 1 addition & 1 deletion src/dstack/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@

__version__ = "0.0.0"
__is_release__ = False
docker_base_image = "0.15"
docker_base_image = "0.16"
docker_base_image_ubuntu_version = "24.04"
vm_base_image = "0.14"
12 changes: 8 additions & 4 deletions src/tests/_internal/server/routers/test_runs.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,9 @@ def get_dev_env_run_plan_dict(
" && sudo rm -rf $DSTACK_VENV_DIR"
" && sudo mkdir $DSTACK_VENV_DIR"
" && sudo chown $(id -u):$(id -g) $DSTACK_VENV_DIR"
" && uv venv -q --prompt dstack -p 3.13 --seed $DSTACK_VENV_DIR"
" && (if UV_PYTHON_INSTALL_DIR=/opt/uv/python uv python find 3.13 > /dev/null 2>&1;"
" then export UV_PYTHON_INSTALL_DIR=/opt/uv/python UV_PYTHON_DOWNLOADS=never; fi;"
" uv venv -q --prompt dstack -p 3.13 --seed $DSTACK_VENV_DIR)"
" && eval $(echo '. $DSTACK_VENV_DIR/bin/activate' | sudo tee -a /dstack/profile)"
" && (echo 'uv pip install ipykernel...'"
" && uv pip install -q --no-cache-dir ipykernel 2> /dev/null)"
Expand All @@ -180,7 +182,7 @@ def get_dev_env_run_plan_dict(
" && tail -f /dev/null"
),
]
image_name = "dstackai/base:0.15-base-ubuntu24.04"
image_name = "dstackai/base:0.16-base-ubuntu24.04"

run_spec = {
"configuration": {
Expand Down Expand Up @@ -409,7 +411,9 @@ def get_dev_env_run_dict(
" && sudo rm -rf $DSTACK_VENV_DIR"
" && sudo mkdir $DSTACK_VENV_DIR"
" && sudo chown $(id -u):$(id -g) $DSTACK_VENV_DIR"
" && uv venv -q --prompt dstack -p 3.13 --seed $DSTACK_VENV_DIR"
" && (if UV_PYTHON_INSTALL_DIR=/opt/uv/python uv python find 3.13 > /dev/null 2>&1;"
" then export UV_PYTHON_INSTALL_DIR=/opt/uv/python UV_PYTHON_DOWNLOADS=never; fi;"
" uv venv -q --prompt dstack -p 3.13 --seed $DSTACK_VENV_DIR)"
" && eval $(echo '. $DSTACK_VENV_DIR/bin/activate' | sudo tee -a /dstack/profile)"
" && (echo 'uv pip install ipykernel...'"
" && uv pip install -q --no-cache-dir ipykernel 2> /dev/null)"
Expand All @@ -427,7 +431,7 @@ def get_dev_env_run_dict(
" && tail -f /dev/null"
),
]
image_name = "dstackai/base:0.15-base-ubuntu24.04"
image_name = "dstackai/base:0.16-base-ubuntu24.04"

return {
"id": run_id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,9 @@ async def test_with_commands_no_image(self, shell: Optional[str], expected_shell
" && sudo rm -rf $DSTACK_VENV_DIR"
" && sudo mkdir $DSTACK_VENV_DIR"
" && sudo chown $(id -u):$(id -g) $DSTACK_VENV_DIR"
" && uv venv -q --prompt dstack -p 3.12 --seed $DSTACK_VENV_DIR"
" && (if UV_PYTHON_INSTALL_DIR=/opt/uv/python uv python find 3.12 > /dev/null 2>&1;"
" then export UV_PYTHON_INSTALL_DIR=/opt/uv/python UV_PYTHON_DOWNLOADS=never; fi;"
" uv venv -q --prompt dstack -p 3.12 --seed $DSTACK_VENV_DIR)"
" && eval $(echo '. $DSTACK_VENV_DIR/bin/activate' | sudo tee -a /dstack/profile)"
" && sleep inf"
),
Expand Down
Loading