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
34 changes: 34 additions & 0 deletions components/src/dynamo/vllm/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,35 @@
framework is not installed in the current container.
"""

import importlib
import importlib.util
import sys

import pytest

# Cached result of attempting to import the omni handler module.
# `None` = not yet attempted, `True` = succeeded, `False` = raised.
_omni_importable: bool | None = None


def _can_import_omni() -> bool:
"""Try to import dynamo.vllm.omni.base_handler once and cache the result.

Catches any exception, not just ImportError — vllm_omni's import chain
can raise NotImplementedError (and other types) when vllm._C / libcuda
aren't available on a CPU-only runner. importlib.util.find_spec is
insufficient because it only resolves the top-level package, not the
transitive imports that actually fail.
"""
global _omni_importable
if _omni_importable is None:
try:
importlib.import_module("dynamo.vllm.omni.base_handler")
_omni_importable = True
except Exception:
_omni_importable = False
return _omni_importable


def pytest_ignore_collect(collection_path, config):
"""Skip collecting vllm test files if vllm module isn't installed.
Expand All @@ -20,6 +44,16 @@ def pytest_ignore_collect(collection_path, config):
if filename.startswith("test_vllm_"):
if importlib.util.find_spec("vllm") is None:
return True # vllm not available, skip this file
# Omni tests import dynamo.vllm.omni.* which transitively imports
# vllm_omni at module load. On CPU-only sample-runtime runners the
# import chain reaches vllm._C and raises (NotImplementedError when
# libcuda.so.1 is missing). Each file's local try/except ImportError
# doesn't catch this, so skip collection up-front if the canonical
# omni module isn't importable.
parts = collection_path.parts
if "omni" in parts and filename.startswith("test_"):
if not _can_import_omni():
return True
return None


Expand Down
1 change: 0 additions & 1 deletion lib/llm/src/preprocessor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1578,7 +1578,6 @@ impl OpenAIPreprocessor {
choice.delta.refusal = None;
choice.delta.reasoning_content = None;
choice.finish_reason = None;
choice.stop_reason = None;
choice.logprobs = None;
true
} else {
Expand Down
1 change: 0 additions & 1 deletion lib/llm/tests/postprocessor_parsing_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,6 @@ fn mock_multi_choice_content_chunk(
reasoning_content: None,
},
finish_reason: None,
stop_reason: None,
logprobs: None,
})
.collect();
Expand Down
5 changes: 4 additions & 1 deletion tests/serve/test_vllm_omni.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@

try:
from dynamo.vllm.omni.args import OmniConfig # noqa: F401
except ImportError:
except Exception:
# vllm_omni's import chain can raise NotImplementedError (and other
# non-ImportError types) on platforms it doesn't support — e.g. a
# CPU-only runner where vllm._C can't load libcuda.so.1.
pytest.skip("vLLM omni dependencies not available", allow_module_level=True)

from tests.serve.common import (
Expand Down
Loading