From c76d7ae18f8525d3345ac6b1e6910029bc2d6d26 Mon Sep 17 00:00:00 2001 From: Victor Skvortsov Date: Fri, 19 Jun 2026 13:12:17 +0500 Subject: [PATCH] Use uv pip install ipykernel for dev environments --- .../cli/services/configurators/run.py | 10 +++++++- .../server/services/jobs/configurators/dev.py | 3 ++- .../_internal/server/routers/test_runs.py | 24 ++++++++++++------- 3 files changed, 27 insertions(+), 10 deletions(-) diff --git a/src/dstack/_internal/cli/services/configurators/run.py b/src/dstack/_internal/cli/services/configurators/run.py index 2ca8ee89ae..16b0f0a87b 100644 --- a/src/dstack/_internal/cli/services/configurators/run.py +++ b/src/dstack/_internal/cli/services/configurators/run.py @@ -208,6 +208,7 @@ def apply_configuration( # We can attach to run multiple times if it goes from running to pending (retried). while True: with MultiItemStatus(_get_apply_status(run), console=console) as live: + ready_wait_attempt = 0 while not _is_ready_to_attach(run): table = get_runs_table([run]) live.update( @@ -215,7 +216,8 @@ def apply_configuration( *_get_apply_wait_renderables(run), status=_get_apply_status(run), ) - time.sleep(5) + time.sleep(_get_ready_wait_interval(ready_wait_attempt)) + ready_wait_attempt += 1 run.refresh() console.print( @@ -724,6 +726,12 @@ def apply_args(self, conf: TaskConfiguration, args: argparse.Namespace): self.apply_commands_args(conf, args) +def _get_ready_wait_interval(attempt: int) -> float: + if attempt < 5: + return 1 + return 5 + + def _merge_ports(conf: List[PortMapping], args: List[PortMapping]) -> Dict[int, PortMapping]: _unique_ports_constraint([pm.container_port for pm in conf]) _unique_ports_constraint([pm.container_port for pm in args]) diff --git a/src/dstack/_internal/server/services/jobs/configurators/dev.py b/src/dstack/_internal/server/services/jobs/configurators/dev.py index 8bc82288d5..e4ee0a2d56 100644 --- a/src/dstack/_internal/server/services/jobs/configurators/dev.py +++ b/src/dstack/_internal/server/services/jobs/configurators/dev.py @@ -8,8 +8,9 @@ from dstack._internal.server.services.jobs.configurators.base import JobConfigurator INSTALL_IPYKERNEL = ( + "(echo 'uv pip install ipykernel...' && uv pip install -q --no-cache-dir ipykernel 2> /dev/null) || " "(echo 'pip install ipykernel...' && pip install -q --no-cache-dir ipykernel 2> /dev/null) || " - "echo 'no pip, ipykernel was not installed'" + "echo 'no uv or pip found, ipykernel was not installed'" ) diff --git a/src/tests/_internal/server/routers/test_runs.py b/src/tests/_internal/server/routers/test_runs.py index bea20a9830..456873f1e0 100644 --- a/src/tests/_internal/server/routers/test_runs.py +++ b/src/tests/_internal/server/routers/test_runs.py @@ -110,9 +110,11 @@ def get_dev_env_run_plan_dict( "-c", ( "start-dockerd" - " && (echo 'pip install ipykernel...'" + " && (echo 'uv pip install ipykernel...'" + " && uv pip install -q --no-cache-dir ipykernel 2> /dev/null)" + " || (echo 'pip install ipykernel...'" " && pip install -q --no-cache-dir ipykernel 2> /dev/null)" - " || echo 'no pip, ipykernel was not installed'" + " || echo 'no uv or pip found, ipykernel was not installed'" " && echo" " && echo 'To open in VS Code, use link below:'" " && echo" @@ -137,9 +139,11 @@ def get_dev_env_run_plan_dict( " && sudo chown $(id -u):$(id -g) $DSTACK_VENV_DIR" " && 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 'pip install ipykernel...'" + " && (echo 'uv pip install ipykernel...'" + " && uv pip install -q --no-cache-dir ipykernel 2> /dev/null)" + " || (echo 'pip install ipykernel...'" " && pip install -q --no-cache-dir ipykernel 2> /dev/null)" - " || echo 'no pip, ipykernel was not installed'" + " || echo 'no uv or pip found, ipykernel was not installed'" " && echo" " && echo 'To open in VS Code, use link below:'" " && echo" @@ -348,9 +352,11 @@ def get_dev_env_run_dict( "-c", ( "start-dockerd" - " && (echo 'pip install ipykernel...'" + " && (echo 'uv pip install ipykernel...'" + " && uv pip install -q --no-cache-dir ipykernel 2> /dev/null)" + " || (echo 'pip install ipykernel...'" " && pip install -q --no-cache-dir ipykernel 2> /dev/null)" - " || echo 'no pip, ipykernel was not installed'" + " || echo 'no uv or pip found, ipykernel was not installed'" " && echo" " && echo 'To open in VS Code, use link below:'" " && echo" @@ -375,9 +381,11 @@ def get_dev_env_run_dict( " && sudo chown $(id -u):$(id -g) $DSTACK_VENV_DIR" " && 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 'pip install ipykernel...'" + " && (echo 'uv pip install ipykernel...'" + " && uv pip install -q --no-cache-dir ipykernel 2> /dev/null)" + " || (echo 'pip install ipykernel...'" " && pip install -q --no-cache-dir ipykernel 2> /dev/null)" - " || echo 'no pip, ipykernel was not installed'" + " || echo 'no uv or pip found, ipykernel was not installed'" " && echo" " && echo 'To open in VS Code, use link below:'" " && echo"