forked from vllm-project/vllm
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Bugfix]: During testing, use pytest monkeypatch for safely overridin…
…g the env var that indicates the vLLM backend (vllm-project#5210)
- Loading branch information
1 parent
d5ac5f1
commit d20a34e
Showing
2 changed files
with
32 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
"""Kernel test utils""" | ||
|
||
import pytest | ||
|
||
STR_BACKEND_ENV_VAR: str = "VLLM_ATTENTION_BACKEND" | ||
STR_FLASH_ATTN_VAL: str = "FLASH_ATTN" | ||
STR_INVALID_VAL: str = "INVALID" | ||
|
||
|
||
def override_backend_env_variable(mpatch: pytest.MonkeyPatch, | ||
backend_name: str) -> None: | ||
''' | ||
Override the environment variable indicating the vLLM backend temporarily, | ||
using pytest monkeypatch to ensure that the env vars get | ||
reset once the test context exits. | ||
Arguments: | ||
* mpatch: pytest monkeypatch instance | ||
* backend_name: attention backend name to force | ||
''' | ||
mpatch.setenv(STR_BACKEND_ENV_VAR, backend_name) |