main
py 22 lines 876 Bytes
Raw
1 # SPDX-License-Identifier: Apache-2.0
2 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project
3
4 # Description: Test the lazy import module
5 # The utility function cannot be placed in `vllm.utils`
6 # this needs to be a standalone script
7 import sys
8
9 # List of modules that should not be imported too early.
10 # Lazy import `torch._inductor.async_compile` to avoid creating
11 # too many processes before we set the number of compiler threads.
12 # Lazy import `cv2` to avoid bothering users who only use text models.
13 # `cv2` can easily mess up the environment.
14 module_names = ["torch._inductor.async_compile", "cv2"]
15
16 # set all modules in `module_names` to be None.
17 # if we import any modules during `import vllm`, there would be a
18 # hard error and nice stacktrace on the first import.
19 for module_name in module_names:
20 sys.modules[module_name] = None
21
22 import vllm # noqa