Skip to content

[pull] main from trustyai-explainability:main #10

[pull] main from trustyai-explainability:main

[pull] main from trustyai-explainability:main #10

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"