"tests/frontend/vscode:/vscode.git/clone" did not exist on "4d9e64a2c1f0250523a2c7b71e1f058ae97b445d"
Unverified Commit 07cf0744 authored by Keiven C's avatar Keiven C Committed by GitHub
Browse files

refactor: remove hardcoded /workspace paths across tests (#3888)


Signed-off-by: default avatarKeiven Chang <keivenchang@users.noreply.github.com>
parent 0757ecf1
...@@ -23,6 +23,7 @@ import yaml ...@@ -23,6 +23,7 @@ import yaml
from pydantic import BaseModel from pydantic import BaseModel
from benchmarks.profiler.utils.planner_utils import build_planner_args_from_namespace from benchmarks.profiler.utils.planner_utils import build_planner_args_from_namespace
from dynamo.common.utils.paths import get_workspace_dir
from dynamo.planner.defaults import WORKER_COMPONENT_NAMES, SubComponentType from dynamo.planner.defaults import WORKER_COMPONENT_NAMES, SubComponentType
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
...@@ -107,7 +108,7 @@ class DgdPlannerServiceConfig(BaseModel): ...@@ -107,7 +108,7 @@ class DgdPlannerServiceConfig(BaseModel):
extraPodSpec: PodSpec = PodSpec( extraPodSpec: PodSpec = PodSpec(
mainContainer=Container( mainContainer=Container(
image="my-registry/dynamo-runtime:my-tag", # placeholder image="my-registry/dynamo-runtime:my-tag", # placeholder
workingDir="/workspace/components/src/dynamo/planner", workingDir=f"{get_workspace_dir()}/components/src/dynamo/planner",
command=["python3", "-m", "planner_sla"], command=["python3", "-m", "planner_sla"],
args=[], args=[],
) )
......
...@@ -8,9 +8,10 @@ This module contains shared utility functions used across multiple ...@@ -8,9 +8,10 @@ This module contains shared utility functions used across multiple
Dynamo backends and components. Dynamo backends and components.
Submodules: Submodules:
- paths: Workspace directory detection and path utilities
- prometheus: Prometheus metrics collection and logging utilities - prometheus: Prometheus metrics collection and logging utilities
""" """
from dynamo.common.utils import prometheus from dynamo.common.utils import paths, prometheus
__all__ = ["prometheus"] __all__ = ["paths", "prometheus"]
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
"""
Path utilities for Dynamo workspace detection.
This module provides utilities for determining the workspace directory
across different environments (development, container, CI).
"""
import os
def get_workspace_dir() -> str:
"""
Determine the Dynamo workspace directory.
Returns the workspace directory with the following precedence:
1. Current working directory if it contains Cargo.toml (running from repo root)
2. WORKSPACE_DIR environment variable (user-provided override)
3. /workspace (default container path)
4. Current working directory (fallback)
Returns:
str: Absolute path to the workspace directory
Examples:
>>> # Running from repo root
>>> get_workspace_dir()
'/home/ubuntu/dynamo'
>>> # With environment variable override
>>> os.environ['WORKSPACE_DIR'] = '/custom/path'
>>> get_workspace_dir()
'/custom/path'
>>> # In container default
>>> get_workspace_dir()
'/workspace'
"""
# Check if running from repo root (contains Cargo.toml)
if os.path.exists(os.path.join(os.getcwd(), "Cargo.toml")):
return os.getcwd()
# Check environment variable
workspace_dir = os.environ.get("WORKSPACE_DIR")
if workspace_dir:
return workspace_dir
# Check container default
if os.path.exists("/workspace"):
return "/workspace"
# Fallback to current directory
return os.getcwd()
# Global constant for convenience
WORKSPACE_DIR = get_workspace_dir()
__all__ = ["get_workspace_dir", "WORKSPACE_DIR"]
...@@ -10,23 +10,12 @@ from typing import Any, Dict, Optional ...@@ -10,23 +10,12 @@ from typing import Any, Dict, Optional
import pytest import pytest
from dynamo.common.utils.paths import WORKSPACE_DIR
from tests.utils.client import send_request from tests.utils.client import send_request
from tests.utils.engine_process import EngineConfig, EngineProcess from tests.utils.engine_process import EngineConfig, EngineProcess
DEFAULT_TIMEOUT = 10 DEFAULT_TIMEOUT = 10
# Determine WORKSPACE_DIR with precedence: current path -> env WORKSPACE_DIR -> /workspace
if os.path.exists(os.path.join(os.getcwd(), "Cargo.toml")):
WORKSPACE_DIR = os.getcwd()
else:
_workspace_dir = os.environ.get("WORKSPACE_DIR")
if _workspace_dir:
WORKSPACE_DIR = _workspace_dir
elif os.path.exists("/workspace"):
WORKSPACE_DIR = "/workspace"
else:
WORKSPACE_DIR = os.getcwd()
SERVE_TEST_DIR = os.path.join(WORKSPACE_DIR, "tests/serve") SERVE_TEST_DIR = os.path.join(WORKSPACE_DIR, "tests/serve")
......
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0 # SPDX-License-Identifier: Apache-2.0
import os
import sys import sys
from pathlib import Path from pathlib import Path
import uvloop import uvloop
from transformers import AutoTokenizer from transformers import AutoTokenizer
from dynamo.common.utils.paths import WORKSPACE_DIR
from dynamo.llm import ModelInput, ModelType, register_llm from dynamo.llm import ModelInput, ModelType, register_llm
from dynamo.runtime import DistributedRuntime, dynamo_worker from dynamo.runtime import DistributedRuntime, dynamo_worker
SERVE_TEST_DIR = "/workspace/tests/serve" # do not import from tests.serve.common because on CI, PYTHONPATH is not set and it'll fail SERVE_TEST_DIR = os.path.join(WORKSPACE_DIR, "tests/serve")
class TemplateVerificationHandler: class TemplateVerificationHandler:
......
...@@ -9,6 +9,7 @@ import pytest ...@@ -9,6 +9,7 @@ import pytest
from tests.serve.common import ( from tests.serve.common import (
SERVE_TEST_DIR, SERVE_TEST_DIR,
WORKSPACE_DIR,
params_with_model_mark, params_with_model_mark,
run_serve_deployment, run_serve_deployment,
) )
...@@ -32,7 +33,9 @@ class SGLangConfig(EngineConfig): ...@@ -32,7 +33,9 @@ class SGLangConfig(EngineConfig):
stragglers: list[str] = field(default_factory=lambda: ["SGLANG:EngineCore"]) stragglers: list[str] = field(default_factory=lambda: ["SGLANG:EngineCore"])
sglang_dir = os.environ.get("SGLANG_DIR", "/workspace/components/backends/sglang") sglang_dir = os.environ.get("SGLANG_DIR") or os.path.join(
WORKSPACE_DIR, "components/backends/sglang"
)
sglang_configs = { sglang_configs = {
"aggregated": SGLangConfig( "aggregated": SGLangConfig(
......
...@@ -30,7 +30,7 @@ class TRTLLMConfig(EngineConfig): ...@@ -30,7 +30,7 @@ class TRTLLMConfig(EngineConfig):
trtllm_dir = os.environ.get("TRTLLM_DIR") or os.path.join( trtllm_dir = os.environ.get("TRTLLM_DIR") or os.path.join(
WORKSPACE_DIR, "components", "backends", "trtllm" WORKSPACE_DIR, "components/backends/trtllm"
) )
# trtllm test configurations # trtllm test configurations
......
...@@ -31,7 +31,7 @@ class VLLMConfig(EngineConfig): ...@@ -31,7 +31,7 @@ class VLLMConfig(EngineConfig):
vllm_dir = os.environ.get("VLLM_DIR") or os.path.join( vllm_dir = os.environ.get("VLLM_DIR") or os.path.join(
WORKSPACE_DIR, "components", "backends", "vllm" WORKSPACE_DIR, "components/backends/vllm"
) )
# vLLM test configurations # vLLM test configurations
...@@ -106,7 +106,7 @@ vllm_configs = { ...@@ -106,7 +106,7 @@ vllm_configs = {
), ),
"multimodal_agg_llava": VLLMConfig( "multimodal_agg_llava": VLLMConfig(
name="multimodal_agg_llava", name="multimodal_agg_llava",
directory=os.path.join(WORKSPACE_DIR, "examples", "multimodal"), directory=os.path.join(WORKSPACE_DIR, "examples/multimodal"),
script_name="agg.sh", script_name="agg.sh",
marks=[pytest.mark.gpu_2], marks=[pytest.mark.gpu_2],
model="llava-hf/llava-1.5-7b-hf", model="llava-hf/llava-1.5-7b-hf",
...@@ -130,7 +130,7 @@ vllm_configs = { ...@@ -130,7 +130,7 @@ vllm_configs = {
), ),
"multimodal_agg_qwen": VLLMConfig( "multimodal_agg_qwen": VLLMConfig(
name="multimodal_agg_qwen", name="multimodal_agg_qwen",
directory=os.path.join(WORKSPACE_DIR, "examples", "multimodal"), directory=os.path.join(WORKSPACE_DIR, "examples/multimodal"),
script_name="agg.sh", script_name="agg.sh",
marks=[pytest.mark.gpu_2], marks=[pytest.mark.gpu_2],
model="Qwen/Qwen2.5-VL-7B-Instruct", model="Qwen/Qwen2.5-VL-7B-Instruct",
...@@ -155,7 +155,7 @@ vllm_configs = { ...@@ -155,7 +155,7 @@ vllm_configs = {
), ),
"multimodal_video_agg": VLLMConfig( "multimodal_video_agg": VLLMConfig(
name="multimodal_video_agg", name="multimodal_video_agg",
directory=os.path.join(WORKSPACE_DIR, "examples", "multimodal"), directory=os.path.join(WORKSPACE_DIR, "examples/multimodal"),
script_name="video_agg.sh", script_name="video_agg.sh",
marks=[pytest.mark.gpu_2], marks=[pytest.mark.gpu_2],
model="llava-hf/LLaVA-NeXT-Video-7B-hf", model="llava-hf/LLaVA-NeXT-Video-7B-hf",
...@@ -182,7 +182,7 @@ vllm_configs = { ...@@ -182,7 +182,7 @@ vllm_configs = {
# TODO: Enable this test case when we have 4 GPUs runners. # TODO: Enable this test case when we have 4 GPUs runners.
# "multimodal_disagg": VLLMConfig( # "multimodal_disagg": VLLMConfig(
# name="multimodal_disagg", # name="multimodal_disagg",
# directory="/workspace/examples/multimodal", # directory=os.path.join(WORKSPACE_DIR, "examples/multimodal"),
# script_name="disagg.sh", # script_name="disagg.sh",
# marks=[pytest.mark.gpu_4, pytest.mark.vllm], # marks=[pytest.mark.gpu_4, pytest.mark.vllm],
# model="llava-hf/llava-1.5-7b-hf", # model="llava-hf/llava-1.5-7b-hf",
......
...@@ -18,6 +18,8 @@ from kr8s.objects import Pod as kr8s_Pod ...@@ -18,6 +18,8 @@ from kr8s.objects import Pod as kr8s_Pod
from kr8s.objects import Service as kr8s_Service from kr8s.objects import Service as kr8s_Service
from kubernetes_asyncio import client, config from kubernetes_asyncio import client, config
from dynamo.common.utils.paths import get_workspace_dir
class ServiceSpec: class ServiceSpec:
"""Wrapper around a single service in the deployment spec.""" """Wrapper around a single service in the deployment spec."""
...@@ -822,8 +824,11 @@ async def main(): ...@@ -822,8 +824,11 @@ async def main():
datefmt=DATE_FORMAT, # ISO 8601 UTC format datefmt=DATE_FORMAT, # ISO 8601 UTC format
) )
# Get workspace directory using centralized logic
workspace_dir = get_workspace_dir()
deployment_spec = DeploymentSpec( deployment_spec = DeploymentSpec(
"/workspace/components/backends/vllm/deploy/agg.yaml" os.path.join(workspace_dir, "components/backends/vllm/deploy/agg.yaml")
) )
deployment_spec.disable_grove() deployment_spec.disable_grove()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment