forked from trustyai-explainability/guardrails-detectors
-
Notifications
You must be signed in to change notification settings - Fork 2
91 lines (82 loc) · 2.75 KB
/
test-huggingface-runtime.yaml
File metadata and controls
91 lines (82 loc) · 2.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
name: Tier 1 - Hugging Face Runtime unit tests
on:
push:
branches: [ main, incubation, stable ]
paths:
- 'detectors/huggingface/**'
- 'detectors/common/**'
- 'tests/detectors/huggingface/**'
- 'tests/dummy_models/**'
- 'tests/conftest.py'
- '.github/workflows/test-huggingface-runtime.yaml'
pull_request:
branches: [ main, incubation, stable ]
paths:
- 'detectors/huggingface/**'
- 'detectors/common/**'
- 'tests/detectors/huggingface/**'
- 'tests/dummy_models/**'
- 'tests/conftest.py'
- '.github/workflows/test-huggingface-runtime.yaml'
jobs:
test-huggingface-runtime:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.11"]
permissions:
contents: read
checks: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Common test setup
uses: ./.github/actions/test-setup
with:
component_name: 'huggingface'
requirements_files: 'detectors/common/requirements.txt detectors/common/requirements-dev.txt detectors/huggingface/requirements.txt'
precommit_paths: 'detectors/huggingface tests/detectors/huggingface detectors/common'
python_version: ${{ matrix.python-version }}
needs_system_deps: 'true'
- name: Verify dummy models are available
run: |
ls -la tests/dummy_models/
echo "Checking for required test models..."
if [ ! -d "tests/dummy_models/bert" ]; then
echo "Warning: BERT dummy models not found"
fi
if [ ! -d "tests/dummy_models/gpt2" ]; then
echo "Warning: GPT2 dummy models not found"
fi
- name: Run Hugging Face Runtime Tests
timeout-minutes: 20
env:
HF_HOME: /tmp/huggingface
TRANSFORMERS_CACHE: /tmp/transformers_cache
TOKENIZERS_PARALLELISM: false
run: |
pytest tests/detectors/huggingface/ \
--cov=detectors.huggingface \
--cov-report=term-missing \
-v \
--tb=short
- name: Test model loading capabilities
timeout-minutes: 10
env:
HF_HOME: /tmp/huggingface
TRANSFORMERS_CACHE: /tmp/transformers_cache
TOKENIZERS_PARALLELISM: false
MODEL_DIR: tests/dummy_models/bert/BertForSequenceClassification
run: |
python -c "
try:
from detectors.huggingface.detector import Detector
print('Detector import successful')
# Test basic initialization
detector = Detector()
print('Detector initialization successful')
except Exception as e:
print(f'Error testing HF detector: {e}')
exit(1)
"
echo "Model loading verification complete"