Fix empty-dict consistency in ground-truth export
Devin Review (post-merge on PR #6) flagged that the `final_result` assignment used a truthiness check (`if job_row.result`) while `build_initial_result` used an identity check (`is None`). For a job whose result is an empty dict (`{}`), the emitted `GroundTruthSample` ended up with `initial_result={}` but `final_result=None` — logically inconsistent. Switch the final-result assignment to the same `is None` check so both fields agree. Added `test_empty_dict_result_stays_consistent` to lock the invariant in, and fixed the test helper so callers can pass `{}` without the helper's `or` fallback replacing it. Co-Authored-By: adrian kuman firmansah <adriancuman@gmail.com>
This commit is contained in:
@@ -171,7 +171,10 @@ def iter_ground_truth_samples(
|
||||
reviewed_at=job_row.reviewed_at,
|
||||
created_at=job_row.created_at,
|
||||
initial_result=initial,
|
||||
final_result=copy.deepcopy(job_row.result) if job_row.result else None,
|
||||
# Use an ``is None`` check to stay consistent with
|
||||
# ``build_initial_result``; otherwise an empty-dict result
|
||||
# would produce ``initial_result={}`` but ``final_result=None``.
|
||||
final_result=(copy.deepcopy(job_row.result) if job_row.result is not None else None),
|
||||
corrections=[
|
||||
GroundTruthCorrection(
|
||||
field_path=c.field_path,
|
||||
|
||||
Reference in New Issue
Block a user