| 1 | # SPDX-License-Identifier: Apache-2.0 |
| 2 | # SPDX-FileCopyrightText: Copyright contributors to the vLLM project |
| 3 | """These envs only work for a small part of the tests, fix what you need!""" |
| 4 | |
| 5 | import os |
| 6 | from collections.abc import Callable |
| 7 | from typing import TYPE_CHECKING, Any |
| 8 | |
| 9 | from vllm.envs import maybe_convert_bool |
| 10 | |
| 11 | if TYPE_CHECKING: |
| 12 | VLLM_CI_NO_SKIP: bool = False |
| 13 | VLLM_CI_DTYPE: str | None = None |
| 14 | VLLM_CI_HEAD_DTYPE: str | None = None |
| 15 | VLLM_CI_HF_DTYPE: str | None = None |
| 16 | |
| 17 | environment_variables: dict[str, Callable[[], Any]] = { |
| 18 | # A model family has many models with the same architecture. |
| 19 | # By default, a model family tests only one model. |
| 20 | # Through this flag, all models can be tested. |
| 21 | "VLLM_CI_NO_SKIP": lambda: bool(int(os.getenv("VLLM_CI_NO_SKIP", "0"))), |
| 22 | # Allow changing the dtype used by vllm in tests |
| 23 | "VLLM_CI_DTYPE": lambda: os.getenv("VLLM_CI_DTYPE", None), |
| 24 | # Allow changing the head dtype used by vllm in tests |
| 25 | "VLLM_CI_HEAD_DTYPE": lambda: os.getenv("VLLM_CI_HEAD_DTYPE", None), |
| 26 | # Allow changing the head dtype used by transformers in tests |
| 27 | "VLLM_CI_HF_DTYPE": lambda: os.getenv("VLLM_CI_HF_DTYPE", None), |
| 28 | # Allow control over whether tests use enforce_eager |
| 29 | "VLLM_CI_ENFORCE_EAGER": lambda: maybe_convert_bool( |
| 30 | os.getenv("VLLM_CI_ENFORCE_EAGER", None) |
| 31 | ), |
| 32 | } |
| 33 | |
| 34 | |
| 35 | def __getattr__(name: str): |
| 36 | # lazy evaluation of environment variables |
| 37 | if name in environment_variables: |
| 38 | return environment_variables[name]() |
| 39 | raise AttributeError(f"module {__name__!r} has no attribute {name!r}") |
| 40 | |
| 41 | |
| 42 | def __dir__(): |
| 43 | return list(environment_variables.keys()) |
| 44 | |
| 45 | |
| 46 | def is_set(name: str): |
| 47 | """Check if an environment variable is explicitly set.""" |
| 48 | if name in environment_variables: |
| 49 | return name in os.environ |
| 50 | raise AttributeError(f"module {__name__!r} has no attribute {name!r}") |