Skip to content

Commit aeb9b4b

Browse files
committed
Rename connector enrich terminology to normalize
1 parent 10d140f commit aeb9b4b

8 files changed

Lines changed: 61 additions & 61 deletions

File tree

avidtools/connectors/base.py

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,40 @@
1-
"""Generic enrich helpers for AVID report JSON and JSONL files."""
1+
"""Generic normalize helpers for AVID report JSON and JSONL files."""
22

33
import json
44
from pathlib import Path
55

6-
from .utils import apply_enrich_normalizations
6+
from .utils import apply_normalizations
77

88

9-
def _enrich_report(report: dict) -> None:
10-
"""Apply generic enrich normalizations to a single report dict."""
9+
def _normalize_report(report: dict) -> None:
10+
"""Apply generic normalizations to a single report dict."""
1111

12-
apply_enrich_normalizations(report)
12+
apply_normalizations(report)
1313

1414

1515
def process_json_file(
1616
input_path: Path,
1717
dry_run: bool,
1818
) -> int:
19-
"""Enrich a JSON file containing one report object or a list of reports."""
19+
"""Normalize a JSON file containing one report object or a list of reports."""
2020

2121
with input_path.open("r", encoding="utf-8") as file_obj:
2222
payload = json.load(file_obj)
2323

24-
reports_enriched = 0
24+
reports_normalized = 0
2525

2626
if isinstance(payload, dict):
27-
_enrich_report(payload)
28-
reports_enriched += 1
27+
_normalize_report(payload)
28+
reports_normalized += 1
2929
elif isinstance(payload, list):
3030
for index, report in enumerate(payload, 1):
3131
if not isinstance(report, dict):
3232
raise ValueError(
3333
"Invalid item at index "
3434
f"{index} in JSON list: expected object"
3535
)
36-
_enrich_report(report)
37-
reports_enriched += 1
36+
_normalize_report(report)
37+
reports_normalized += 1
3838
else:
3939
raise ValueError("Unsupported JSON structure: expected object or list")
4040

@@ -43,17 +43,17 @@ def process_json_file(
4343
json.dump(payload, file_obj, indent=2)
4444
file_obj.write("\n")
4545

46-
return reports_enriched
46+
return reports_normalized
4747

4848

4949
def process_jsonl_file(
5050
input_path: Path,
5151
dry_run: bool,
5252
) -> int:
53-
"""Enrich each report object in a JSONL file."""
53+
"""Normalize each report object in a JSONL file."""
5454

55-
reports_enriched = 0
56-
enriched_lines = []
55+
reports_normalized = 0
56+
normalized_lines = []
5757

5858
with input_path.open("r", encoding="utf-8") as file_obj:
5959
for line_num, line in enumerate(file_obj, 1):
@@ -73,20 +73,20 @@ def process_jsonl_file(
7373
f"Invalid JSON object on line {line_num}: expected object"
7474
)
7575

76-
_enrich_report(report)
77-
reports_enriched += 1
78-
enriched_lines.append(json.dumps(report, ensure_ascii=False))
76+
_normalize_report(report)
77+
reports_normalized += 1
78+
normalized_lines.append(json.dumps(report, ensure_ascii=False))
7979

8080
if not dry_run:
8181
with input_path.open("w", encoding="utf-8") as file_obj:
82-
if enriched_lines:
83-
file_obj.write("\n".join(enriched_lines) + "\n")
82+
if normalized_lines:
83+
file_obj.write("\n".join(normalized_lines) + "\n")
8484

85-
return reports_enriched
85+
return reports_normalized
8686

8787

88-
def enrich_file(input_path: Path, dry_run: bool = False) -> int:
89-
"""Dispatch enrich processing based on input file extension."""
88+
def normalize_file(input_path: Path, dry_run: bool = False) -> int:
89+
"""Dispatch normalize processing based on input file extension."""
9090

9191
if input_path.suffix == ".json":
9292
return process_json_file(input_path, dry_run)

avidtools/connectors/garak.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Garak-specific enrich helpers for AVID report JSON and JSONL files."""
1+
"""Garak-specific normalize helpers for AVID report JSON and JSONL files."""
22

33
import asyncio
44
import json
@@ -11,7 +11,7 @@
1111
from urllib.request import Request, urlopen
1212

1313
from .utils import (
14-
apply_enrich_normalizations,
14+
apply_normalizations,
1515
choose_model_subject_label,
1616
to_list,
1717
)
@@ -252,7 +252,7 @@ def _fetch_probe_reference_text(probe_name: str) -> Optional[str]:
252252
_, reference_url = _probe_urls(probe_name)
253253
request = Request(
254254
reference_url,
255-
headers={"User-Agent": "avid-db-garak-enrich/1.0"},
255+
headers={"User-Agent": "avid-db-garak-normalize/1.0"},
256256
)
257257
try:
258258
with urlopen(request, timeout=30) as response:
@@ -763,16 +763,16 @@ def _extract_primary_model_developer_and_deployer(report: dict):
763763
return model_name, developer_name, deployer_name
764764

765765

766-
def _enrich_report(
766+
def _normalize_report(
767767
report: dict,
768768
probe_summaries: Dict[str, str],
769769
module_behaviors: Dict[str, str],
770770
):
771-
"""Apply Garak-specific enrich transforms to a single report."""
771+
"""Apply Garak-specific normalize transforms to a single report."""
772772

773773
preferred_model_name = _shorten_artifact_model_names(report)
774774
_apply_litellm_deployer_mapping(report)
775-
apply_enrich_normalizations(
775+
apply_normalizations(
776776
report,
777777
preferred_model_name=preferred_model_name,
778778
)
@@ -887,12 +887,12 @@ def _save_reports(input_path: Path, reports, shape: str):
887887
raise ValueError(f"Unknown shape: {shape}")
888888

889889

890-
def enrich_file(
890+
def normalize_file(
891891
input_path: Path,
892892
dry_run: bool = False,
893893
cache_path: Path = CACHE_PATH,
894894
) -> int:
895-
"""Enrich a Garak JSON/JSONL input file and optionally rewrite in place."""
895+
"""Normalize a Garak JSON/JSONL input file and optionally rewrite in place."""
896896

897897
reports, shape = _load_reports(input_path)
898898

@@ -907,7 +907,7 @@ def enrich_file(
907907
)
908908

909909
for report in reports:
910-
_enrich_report(report, probe_summaries, module_behaviors)
910+
_normalize_report(report, probe_summaries, module_behaviors)
911911

912912
if not dry_run:
913913
_save_reports(input_path, reports, shape)

avidtools/connectors/inspect.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Connector helpers for converting and enriching Inspect evaluation reports."""
1+
"""Connector helpers for converting and normalizing Inspect evaluation reports."""
22

33
import json
44
import re
@@ -78,15 +78,15 @@ def import_eval_log(file_path: str) -> Any:
7878
return read_eval_log(file_path)
7979

8080

81-
def convert_eval_log(file_path: str, enrich: bool = False) -> List[Report]:
81+
def convert_eval_log(file_path: str, normalize: bool = False) -> List[Report]:
8282
"""Convert an Inspect evaluation log into a list of AVID Report objects.
8383
8484
Parameters
8585
----------
8686
file_path : str
8787
Path to the evaluation log file (.eval or .json).
88-
enrich : bool
89-
If True, run enrich steps that fetch benchmark overview/scoring
88+
normalize : bool
89+
If True, run normalize steps that fetch benchmark overview/scoring
9090
and apply report normalizations.
9191
9292
Returns
@@ -166,13 +166,13 @@ def convert_eval_log(file_path: str, enrich: bool = False) -> List[Report]:
166166
)
167167
report.description = LangValue(lang="eng", value=full_description)
168168

169-
if enrich:
169+
if normalize:
170170
report_payload = (
171171
report.model_dump()
172172
if hasattr(report, "model_dump")
173173
else report.dict()
174174
)
175-
enrich_report_data(report_payload)
175+
normalize_report_data(report_payload)
176176
report = Report(**report_payload)
177177

178178
reports.append(report)
@@ -321,7 +321,7 @@ def _build_new_description(
321321
overview: str,
322322
scoring: str,
323323
) -> str:
324-
"""Build standardized enriched report description text."""
324+
"""Build standardized normalized report description text."""
325325

326326
return (
327327
f"{overview}\n\n"
@@ -341,8 +341,8 @@ def _first_line(text: str) -> str:
341341
return ""
342342

343343

344-
def enrich_report_data(report: dict):
345-
"""Apply Inspect enrich transformations to a report dictionary."""
344+
def normalize_report_data(report: dict):
345+
"""Apply Inspect normalize transformations to a report dictionary."""
346346

347347
problem_desc = (
348348
report.get("problemtype", {})
@@ -375,12 +375,12 @@ def enrich_report_data(report: dict):
375375

376376

377377
def process_report(file_path: Path):
378-
"""Load, enrich, and rewrite a single Inspect report file."""
378+
"""Load, normalize, and rewrite a single Inspect report file."""
379379

380380
with file_path.open("r", encoding="utf-8") as file_obj:
381381
report = json.load(file_obj)
382382

383-
enrich_report_data(report)
383+
normalize_report_data(report)
384384

385385
with file_path.open("w", encoding="utf-8") as file_obj:
386386
json.dump(report, file_obj, indent=2)

avidtools/connectors/utils.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,11 +196,11 @@ def apply_openai_system_artifact_type(
196196
return updated
197197

198198

199-
def apply_enrich_normalizations(
199+
def apply_normalizations(
200200
report: dict,
201201
preferred_model_name: Optional[str] = None,
202202
) -> bool:
203-
"""Apply the default enrich normalization suite to a report."""
203+
"""Apply the default normalization suite to a report."""
204204

205205
model_names = extract_model_names(
206206
report,
@@ -221,9 +221,9 @@ def apply_review_normalizations(
221221
report: dict,
222222
preferred_model_name: Optional[str] = None,
223223
) -> bool:
224-
"""Backward-compatible alias for enrich normalizations."""
224+
"""Backward-compatible alias for default normalizations."""
225225

226-
return apply_enrich_normalizations(
226+
return apply_normalizations(
227227
report,
228228
preferred_model_name=preferred_model_name,
229229
)

scripts/odin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ def extract_odin_metadata_from_html(html_content: str, page_text: str) -> dict:
160160
page_text: Text content from the page
161161
162162
Returns:
163-
Dictionary with extracted 0DIN metadata for report enrichment.
163+
Dictionary with extracted 0DIN metadata for report normalization.
164164
"""
165165
print(f"Extracting 0DIN metadata from scraped content...")
166166

tests/unit/connectors/test_garak.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Unit tests for Garak connector enrich helpers."""
1+
"""Unit tests for Garak connector normalize helpers."""
22

33
from avidtools.connectors.garak import _normalize_metric_results
44

tests/unit/connectors/test_inspect.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -225,21 +225,21 @@ def test_convert_eval_log_different_model(self, mock_import):
225225
assert report.affects.deployer == ["anthropic/claude-3"]
226226
assert report.affects.artifacts[0].name == "claude-3"
227227

228-
@patch('avidtools.connectors.inspect.enrich_report_data')
228+
@patch('avidtools.connectors.inspect.normalize_report_data')
229229
@patch('avidtools.connectors.inspect.import_eval_log')
230-
def test_convert_eval_log_with_enrich_enabled(
230+
def test_convert_eval_log_with_normalize_enabled(
231231
self,
232232
mock_import,
233-
mock_enrich,
233+
mock_normalize,
234234
):
235-
"""Enrich mode should call enrich_report_data for each sample."""
235+
"""Normalize mode should call normalize_report_data for each sample."""
236236
mock_eval_log = MockEvalLog()
237237
mock_import.return_value = mock_eval_log
238238

239-
reports = convert_eval_log("/path/to/eval.json", enrich=True)
239+
reports = convert_eval_log("/path/to/eval.json", normalize=True)
240240

241241
assert len(reports) == 1
242-
assert mock_enrich.call_count == 1
242+
assert mock_normalize.call_count == 1
243243

244244
@patch('avidtools.connectors.inspect.urlopen')
245245
def test_fetch_sections_raises_on_unresolved_benchmark(self, mock_urlopen):

tests/unit/connectors/test_enrich_utils.py renamed to tests/unit/connectors/test_normalize_utils.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
"""Unit tests for enrich normalization utilities."""
1+
"""Unit tests for normalization utilities."""
22

3-
from avidtools.connectors.utils import apply_enrich_normalizations
3+
from avidtools.connectors.utils import apply_normalizations
44

55

6-
def test_apply_enrich_normalizations_sets_openai_deployer_for_gpt_model():
6+
def test_apply_normalizations_sets_openai_deployer_for_gpt_model():
77
"""GPT model artifacts should normalize deployer to OpenAI."""
88
report = {
99
"affects": {
@@ -14,14 +14,14 @@ def test_apply_enrich_normalizations_sets_openai_deployer_for_gpt_model():
1414
"problemtype": {"description": {"value": ""}},
1515
}
1616

17-
updated = apply_enrich_normalizations(report)
17+
updated = apply_normalizations(report)
1818

1919
assert updated is True
2020
assert report["affects"]["deployer"] == ["OpenAI"]
2121
assert report["affects"]["artifacts"][0]["type"] == "System"
2222

2323

24-
def test_apply_enrich_normalizations_sets_together_ai_deployer():
24+
def test_apply_normalizations_sets_together_ai_deployer():
2525
"""Together-prefixed deployers should normalize to Together AI."""
2626
report = {
2727
"affects": {
@@ -32,7 +32,7 @@ def test_apply_enrich_normalizations_sets_together_ai_deployer():
3232
"problemtype": {"description": {"value": ""}},
3333
}
3434

35-
updated = apply_enrich_normalizations(report)
35+
updated = apply_normalizations(report)
3636

3737
assert updated is True
3838
assert report["affects"]["deployer"] == ["Together AI"]

0 commit comments

Comments
 (0)