Skip to content

Commit a4a1a15

Browse files
committed
🚧 added unit tests for the detector along with dummy models
1 parent 6389030 commit a4a1a15

39 files changed

+16323
-1
lines changed

.gitignore

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,19 @@ __pycache__/
1212
.python-version
1313

1414
# secrets
15-
.env
15+
.env
16+
17+
# pytest cache
18+
.pytest_cache/
19+
20+
# .tox
21+
.tox/
22+
23+
# pycache
24+
__pycache__/
25+
26+
# coverage
27+
.coverage
28+
29+
# .vscode
30+
.vscode/

tests/conftest.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import os
2+
import sys
3+
import pytest
4+
5+
6+
@pytest.fixture(autouse=True)
7+
def setup_imports():
8+
"""Setup Python path for imports"""
9+
project_root = os.path.dirname(os.path.dirname(__file__))
10+
detectors_path = os.path.join(project_root, "detectors")
11+
huggingface_path = os.path.join(detectors_path, "huggingface")
12+
paths = [
13+
huggingface_path,
14+
detectors_path,
15+
project_root,
16+
]
17+
18+
for path in paths:
19+
if path not in sys.path:
20+
sys.path.insert(0, path)
21+
print(f"Added to sys.path: {path}")
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"_name_or_path": "../trusty-ai-explainability/guardrails-detectors/bert/BertForSequenceClassification",
3+
"architectures": [
4+
"BertForSequenceClassification"
5+
],
6+
"attention_probs_dropout_prob": 0.1,
7+
"classifier_dropout": null,
8+
"hidden_act": "gelu",
9+
"hidden_dropout_prob": 0.1,
10+
"hidden_size": 32,
11+
"initializer_range": 0.02,
12+
"intermediate_size": 37,
13+
"layer_norm_eps": 1e-12,
14+
"max_position_embeddings": 512,
15+
"model_type": "bert",
16+
"num_attention_heads": 4,
17+
"num_hidden_layers": 2,
18+
"pad_token_id": 0,
19+
"position_embedding_type": "absolute",
20+
"torch_dtype": "float32",
21+
"transformers_version": "4.49.0.dev0",
22+
"type_vocab_size": 16,
23+
"use_cache": true,
24+
"vocab_size": 1124
25+
}
Binary file not shown.
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"cls_token": {
3+
"content": "[CLS]",
4+
"lstrip": false,
5+
"normalized": false,
6+
"rstrip": false,
7+
"single_word": false
8+
},
9+
"mask_token": {
10+
"content": "[MASK]",
11+
"lstrip": false,
12+
"normalized": false,
13+
"rstrip": false,
14+
"single_word": false
15+
},
16+
"pad_token": {
17+
"content": "[PAD]",
18+
"lstrip": false,
19+
"normalized": false,
20+
"rstrip": false,
21+
"single_word": false
22+
},
23+
"sep_token": {
24+
"content": "[SEP]",
25+
"lstrip": false,
26+
"normalized": false,
27+
"rstrip": false,
28+
"single_word": false
29+
},
30+
"unk_token": {
31+
"content": "[UNK]",
32+
"lstrip": false,
33+
"normalized": false,
34+
"rstrip": false,
35+
"single_word": false
36+
}
37+
}
Binary file not shown.

0 commit comments

Comments
 (0)