Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions src/modelbench/benchmark_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,11 +244,12 @@ def compile_annotations(self) -> list:
annotations = []
for sut_uid, hazards in self.finished_items.items():
for full_hazard_string, items in hazards.items():
try:
test, hazard, locale, prompt_set, version = full_hazard_string.split("-")
except:
hazard = full_hazard_string
prompt_set = "unknown"
uid_parts = full_hazard_string.split("-")
hazard = uid_parts[1] if len(uid_parts) > 1 else full_hazard_string
prompt_set = next(
(part for part in uid_parts if part in {"demo", "practice", "official"}),
"unknown",
)

for item in items: # this is a TestRunItem
if prompt_set == "official":
Expand Down
7 changes: 4 additions & 3 deletions tests/modelbench_tests/test_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def fake_benchmark_run(benchmark, hazards, sut, tmp_path):

# these will be used to validate the contents of artifacts created by a run object
test1 = ModelgaugeTestWrapper(
actual_test=MagicMock(uid=f"test1-hazard-locale-official-1.1"),
actual_test=MagicMock(uid=f"test1-hazard-locale-official-1.1-private"),
dependency_data_path=tmp_path,
)
test_item1 = TestItem(
Expand Down Expand Up @@ -112,8 +112,9 @@ def fake_benchmark_run(benchmark, hazards, sut, tmp_path):
)
benchmark_run.add_finished_item(tri2)

# this shareable practice item should be included when annotations are requested
test3 = ModelgaugeTestWrapper(
actual_test=MagicMock(uid=f"test3-hazard-locale-demo-1.1"), dependency_data_path=tmp_path
actual_test=MagicMock(uid=f"test3-hazard-locale-practice-1.1-private"), dependency_data_path=tmp_path
)
test_item3 = TestItem(prompt=TextPrompt(text="Who's a good boy?"), source_id="id3", shareable=True)
tri3 = TestRunItem(
Expand Down Expand Up @@ -189,7 +190,7 @@ def assert_only_shareable_non_official_annotations_are_included(annotation_file_
assert responses == {"Bark bork arf"}


def test_compile_annotations_require_flag_and_shareable(sut, tmp_path):
def test_compile_annotations_require_flag_and_shareable_non_official_prompt(sut, tmp_path):
hazards = [AHazard()]

class ABenchmark(BenchmarkDefinition):
Expand Down
Loading