Skip to content

Commit 61a3187

Browse files
Update .github/workflows for pytest
1 parent 10f42ba commit 61a3187

3 files changed

Lines changed: 15 additions & 3 deletions

File tree

.github/workflows/tests.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,13 @@ jobs:
2828
- name: Install Python dependencies
2929
run: |
3030
python -m pip install --upgrade pip
31-
pip install -r requirements.txt
31+
python -m pip install --upgrade -r requirements.txt
32+
python -m pip install -e .
3233
3334
- name: Rebuild CPU kernel libraries
3435
run: |
3536
make -C kernels/bit_1/cpu clean all
3637
make -C kernels/bit_1_58/cpu clean all
3738
3839
- name: Run test suite
39-
run: pytest -q tests
40+
run: python -m pytest -q tests

conftest.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import sys
2+
import os
3+
4+
sys.path.insert(0, os.path.dirname(__file__))

integrations/hf/model_infer.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import copy
1919
import json
2020
import sys
21+
from contextlib import contextmanager
2122
from pathlib import Path
2223
from typing import Any
2324

@@ -27,9 +28,15 @@
2728
from safetensors import safe_open
2829
from safetensors.torch import load_file as safetensors_load
2930
from transformers import AutoModelForCausalLM, AutoTokenizer, TextStreamer
30-
from transformers.modeling_utils import no_init_weights
3131
from transformers.models.auto.configuration_auto import CONFIG_MAPPING
3232

33+
try:
34+
from transformers.modeling_utils import no_init_weights
35+
except ImportError:
36+
@contextmanager
37+
def no_init_weights():
38+
yield
39+
3340
_PROJECT_ROOT = Path(__file__).resolve().parent.parent.parent
3441
if str(_PROJECT_ROOT) not in sys.path:
3542
sys.path.insert(0, str(_PROJECT_ROOT))

0 commit comments

Comments
 (0)