Skip to content

Commit ee32a39

Browse files
fix(attempt): omit reverse_translation_outputs from report when not used
Fixes #1201 `Attempt.as_dict()` unconditionally included a `reverse_translation_outputs` key in the serialized dict, even when no translation was configured. This polluted every `report.jsonl` entry with a spurious empty list. The field is now only emitted when `self.reverse_translation_outputs` is non-empty, keeping reports clean for the common non-translation case. Signed-off-by: Varun Nuthalapati <nuthalapativarun@gmail.com>
1 parent 2e9b3f5 commit ee32a39

2 files changed

Lines changed: 10 additions & 5 deletions

File tree

garak/attempt.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -288,10 +288,16 @@ def as_dict(self) -> dict:
288288
"conversations": [
289289
asdict(conversation) for conversation in self.conversations
290290
],
291-
"reverse_translation_outputs": [
292-
asdict(output) if output else None
293-
for output in self.reverse_translation_outputs
294-
],
291+
**(
292+
{
293+
"reverse_translation_outputs": [
294+
asdict(output) if output else None
295+
for output in self.reverse_translation_outputs
296+
]
297+
}
298+
if self.reverse_translation_outputs
299+
else {}
300+
),
295301
}
296302

297303
@property

tests/test_attempt.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,6 @@ def test_json_serialize():
557557
"notes": {},
558558
},
559559
],
560-
"reverse_translation_outputs": [],
561560
}
562561

563562
json_serialised = json.dumps(att_dict, ensure_ascii=False)

0 commit comments

Comments
 (0)