fix(attempt): omit reverse_translation_outputs from report when not used#1826
fix(attempt): omit reverse_translation_outputs from report when not used#1826nuthalapativarun wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
A serialized object should not omit a key that was empty. The issue this references did not fully describe what was considered to be the bug, the example entry was meant to offer more context. When no translation is active during a run the reverse_translation_outputs should always be empty, in the example in the issue it was found to have been set when it was not expected to.
Note that #1254 may have actually address this issue, the bug needs to be reproduced to determine if the run logic is still placing values in reverse_translation_outputs when no translation is being used in the run.
…chema Fixes NVIDIA#1201 The original issue reported `reverse_translation_outputs` appearing with unexpected values when no translation was active. Investigation confirms that `_postprocess_attempt()` already gates population behind `this_attempt.lang != self.lang`, so the field is correctly empty (`[]`) in non-translation runs. `as_dict()` always serializes the key (even when empty) to give consumers a stable schema. These two tests make that contract explicit: - `test_asdict_always_includes_reverse_translation_outputs`: the key is always present in the serialized dict, never absent. - `test_asdict_reverse_translation_outputs_empty_when_no_translation`: the value is `[]` when no translation is configured. Signed-off-by: Varun Nuthalapati <nuthalapativarun@gmail.com>
ee32a39 to
5e53b65
Compare
|
Thanks for the review, @jmartin-tech. After investigating:
Happy to close this in favor of a documentation note if you'd prefer, or adjust the test coverage in any direction. |
Fixes #1201
Problem
Attempt.as_dict()unconditionally included areverse_translation_outputskey in every serialized attempt entry inreport.jsonl, even when no translation was configured. This polluted reports with a spurious empty list (or in some cases actual output values) for all non-translation runs.Fix
The key is now only emitted when
self.reverse_translation_outputsis non-empty, using conditional dict unpacking:This keeps reports clean for the common non-translation case, while preserving full output for translation runs where the field is actually populated.
Verification
python -m pytest tests/test_attempt.py -x -q— all 23 tests passtest_json_serializeto not expect the key in non-translation serialization