vllm.envs ¶
__getattr__ ¶
__getattr__(name: str)
Gets environment variables lazily.
NOTE: After enable_envs_cache() invocation (which triggered after service initialization), all environment variables will be cached.
Source code in vllm/envs.py
compile_factors ¶
Return env vars used for torch.compile cache keys.
Start with every known vLLM env var; drop entries in ignored_factors; hash everything else. This keeps the cache key aligned across workers.
Source code in vllm/envs.py
1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 | |
disable_envs_cache ¶
Resets the environment variables cache. It could be used to isolate environments between unit tests.
Source code in vllm/envs.py
enable_envs_cache ¶
Enables caching of environment variables. This is useful for performance reasons, as it avoids the need to re-evaluate environment variables on every call.
NOTE: Currently, it's invoked after service initialization to reduce runtime overhead. This also means that environment variables should NOT be updated after the service is initialized.
Source code in vllm/envs.py
env_list_with_choices ¶
env_list_with_choices(
env_name: str,
default: list[str],
choices: list[str] | Callable[[], list[str]],
case_sensitive: bool = True,
) -> Callable[[], list[str]]
Create a lambda that validates environment variable containing comma-separated values against allowed choices
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
env_name | str | Name of the environment variable | required |
default | list[str] | Default list of values if not set | required |
choices | list[str] | Callable[[], list[str]] | List of valid string options or callable that returns list | required |
case_sensitive | bool | Whether validation should be case sensitive | True |
Returns:
| Type | Description |
|---|---|
Callable[[], list[str]] | Lambda function for environment_variables |
Callable[[], list[str]] | dict that returns list of strings |
Source code in vllm/envs.py
env_set_with_choices ¶
env_set_with_choices(
env_name: str,
default: list[str],
choices: list[str] | Callable[[], list[str]],
case_sensitive: bool = True,
) -> Callable[[], set[str]]
Creates a lambda which that validates environment variable containing comma-separated values against allowed choices which returns choices as a set.
Source code in vllm/envs.py
env_with_choices ¶
env_with_choices(
env_name: str,
default: str | None,
choices: list[str] | Callable[[], list[str]],
case_sensitive: bool = True,
) -> Callable[[], str | None]
Create a lambda that validates environment variable against allowed choices
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
env_name | str | Name of the environment variable | required |
default | str | None | Default value if not set (can be None) | required |
choices | list[str] | Callable[[], list[str]] | List of valid string options or callable that returns list | required |
case_sensitive | bool | Whether validation should be case sensitive | True |
Returns:
| Type | Description |
|---|---|
Callable[[], str | None] | Lambda function for environment_variables dict |
Source code in vllm/envs.py
get_env_or_set_default ¶
Create a lambda that returns an environment variable value if set, or generates and sets a default value using the provided factory function.
Source code in vllm/envs.py
get_vllm_port ¶
get_vllm_port() -> int | None
Get the port from VLLM_PORT environment variable.
Returns:
| Type | Description |
|---|---|
int | None | The port number as an integer if VLLM_PORT is set, None otherwise. |
Raises:
| Type | Description |
|---|---|
ValueError | If VLLM_PORT is a URI, suggest k8s service discovery issue. |