Skip to content

Commit 661fa78

Browse files
author
Yehudit Kerido
committed
Fix skipped model directory tests
Signed-off-by: Yehudit Kerido <[email protected]>
1 parent 9d2512d commit 661fa78

File tree

4 files changed

+30
-12
lines changed

4 files changed

+30
-12
lines changed

.github/workflows/test-and-build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ jobs:
6262
with:
6363
path: |
6464
models/
65-
key: ${{ runner.os }}-models-v1-${{ hashFiles('tools/make/models.mk') }}
65+
key: ${{ runner.os }}-models-v2-${{ hashFiles('tools/make/models.mk') }}
6666
restore-keys: |
67-
${{ runner.os }}-models-v1-
67+
${{ runner.os }}-models-v2-
6868
continue-on-error: true # Don't fail the job if caching fails
6969

7070
- name: Check go mod tidy

candle-binding/src/ffi/init.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -683,6 +683,11 @@ pub extern "C" fn init_lora_unified_classifier(
683683
}
684684
};
685685

686+
// Check if already initialized - return success if so
687+
if PARALLEL_LORA_ENGINE.get().is_some() {
688+
return true;
689+
}
690+
686691
// Load labels dynamically from model configurations
687692
let _intent_labels_vec = load_labels_from_model_config(intent_path).unwrap_or_else(|e| {
688693
eprintln!(
@@ -723,7 +728,9 @@ pub extern "C" fn init_lora_unified_classifier(
723728
) {
724729
Ok(engine) => {
725730
// Store in global static variable (Arc for efficient cloning during concurrent access)
731+
// Return true even if already set (race condition)
726732
PARALLEL_LORA_ENGINE.set(Arc::new(engine)).is_ok()
733+
|| PARALLEL_LORA_ENGINE.get().is_some()
727734
}
728735
Err(e) => {
729736
eprintln!(

src/semantic-router/pkg/classification/classifier_test.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2909,13 +2909,11 @@ func createMockModelFile(t *testing.T, dir, filename string) {
29092909

29102910
func TestAutoDiscoverModels_RealModels(t *testing.T) {
29112911
// Test with real models directory
2912-
modelsDir := "../../../../../models"
2912+
modelsDir := "../../../../models"
29132913

29142914
paths, err := AutoDiscoverModels(modelsDir)
29152915
if err != nil {
2916-
// Skip this test in environments without the real models directory
2917-
t.Logf("AutoDiscoverModels() failed in real-models test: %v", err)
2918-
t.Skip("Skipping real-models discovery test because models directory is unavailable")
2916+
t.Fatalf("AutoDiscoverModels() failed: %v (models directory should exist at %s)", err, modelsDir)
29192917
}
29202918

29212919
t.Logf("Discovered paths:")
@@ -2964,10 +2962,9 @@ func TestAutoDiscoverModels_RealModels(t *testing.T) {
29642962
// TestAutoInitializeUnifiedClassifier tests the full initialization process
29652963
func TestAutoInitializeUnifiedClassifier(t *testing.T) {
29662964
// Test with real models directory
2967-
classifier, err := AutoInitializeUnifiedClassifier("../../../../../models")
2965+
classifier, err := AutoInitializeUnifiedClassifier("../../../../models")
29682966
if err != nil {
2969-
t.Logf("AutoInitializeUnifiedClassifier() failed in real-models test: %v", err)
2970-
t.Skip("Skipping unified classifier init test because real models are unavailable")
2967+
t.Fatalf("AutoInitializeUnifiedClassifier() failed: %v (models directory should exist at ../../../../models)", err)
29712968
}
29722969

29732970
if classifier == nil {
@@ -3305,7 +3302,7 @@ var (
33053302
// getTestClassifier returns a shared classifier instance for all integration tests
33063303
func getTestClassifier(t *testing.T) *UnifiedClassifier {
33073304
globalTestClassifierOnce.Do(func() {
3308-
classifier, err := AutoInitializeUnifiedClassifier("../../../../../models")
3305+
classifier, err := AutoInitializeUnifiedClassifier("../../../../models")
33093306
if err != nil {
33103307
t.Logf("Failed to initialize classifier: %v", err)
33113308
return
@@ -3323,8 +3320,11 @@ func TestUnifiedClassifier_Integration(t *testing.T) {
33233320
// Get shared classifier instance
33243321
classifier := getTestClassifier(t)
33253322
if classifier == nil {
3326-
t.Skip("Skipping integration tests - classifier not available")
3327-
return
3323+
t.Fatal("Classifier initialization failed")
3324+
}
3325+
3326+
if !classifier.useLoRA {
3327+
t.Fatal("LoRA models not detected")
33283328
}
33293329

33303330
t.Run("RealBatchClassification", func(t *testing.T) {

tools/make/models.mk

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ download-models: ## Download models (full or minimal set depending on CI_MINIMAL
2424
# - PII token classifier (ModernBERT Presidio)
2525
# - Jailbreak classifier (ModernBERT)
2626
# - Optional plain PII classifier mapping (small)
27+
# - LoRA models (BERT architecture) for unified classifier tests
2728

2829
download-models-minimal:
2930
download-models-minimal: ## Pre-download minimal set of models for CI tests
@@ -47,6 +48,16 @@ download-models-minimal: ## Pre-download minimal set of models for CI tests
4748
@if [ ! -f "models/pii_classifier_modernbert-base_model/.downloaded" ] || [ ! -d "models/pii_classifier_modernbert-base_model" ]; then \
4849
hf download LLM-Semantic-Router/pii_classifier_modernbert-base_model --local-dir models/pii_classifier_modernbert-base_model && printf '%s\n' "$$(date -u +%Y-%m-%dT%H:%M:%SZ)" > models/pii_classifier_modernbert-base_model/.downloaded; \
4950
fi
51+
# Download LoRA models for unified classifier integration tests
52+
@if [ ! -f "models/lora_intent_classifier_bert-base-uncased_model/.downloaded" ] || [ ! -d "models/lora_intent_classifier_bert-base-uncased_model" ]; then \
53+
hf download LLM-Semantic-Router/lora_intent_classifier_bert-base-uncased_model --local-dir models/lora_intent_classifier_bert-base-uncased_model && printf '%s\n' "$$(date -u +%Y-%m-%dT%H:%M:%SZ)" > models/lora_intent_classifier_bert-base-uncased_model/.downloaded; \
54+
fi
55+
@if [ ! -f "models/lora_pii_detector_bert-base-uncased_model/.downloaded" ] || [ ! -d "models/lora_pii_detector_bert-base-uncased_model" ]; then \
56+
hf download LLM-Semantic-Router/lora_pii_detector_bert-base-uncased_model --local-dir models/lora_pii_detector_bert-base-uncased_model && printf '%s\n' "$$(date -u +%Y-%m-%dT%H:%M:%SZ)" > models/lora_pii_detector_bert-base-uncased_model/.downloaded; \
57+
fi
58+
@if [ ! -f "models/lora_jailbreak_classifier_bert-base-uncased_model/.downloaded" ] || [ ! -d "models/lora_jailbreak_classifier_bert-base-uncased_model" ]; then \
59+
hf download LLM-Semantic-Router/lora_jailbreak_classifier_bert-base-uncased_model --local-dir models/lora_jailbreak_classifier_bert-base-uncased_model && printf '%s\n' "$$(date -u +%Y-%m-%dT%H:%M:%SZ)" > models/lora_jailbreak_classifier_bert-base-uncased_model/.downloaded; \
60+
fi
5061

5162
# Full model set for local development and docs
5263

0 commit comments

Comments
 (0)