conflict-decisions: also apply dateOfDeath (D5 death-date resolutions)
god extended conflict-decisions.json with an optional dateOfDeath (DD.MM.YYYY). apply_conflict_decisions now sets the animal's death date (normalized) as authoritative when present — clearing D5 death-date conflicts the same way genotype/farbschlag decisions are applied. No C# change (death already flows to Gerbil.DateOfDeath). test_extract covers a Flint dateOfDeath resolution. python green. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -862,6 +862,8 @@ def apply_conflict_decisions(merged, conflicts, path):
|
|||||||
if d.get("farbschlag"):
|
if d.get("farbschlag"):
|
||||||
a["farbschlag"] = d["farbschlag"]
|
a["farbschlag"] = d["farbschlag"]
|
||||||
a["farbschlagVariants"] = [d["farbschlag"]]
|
a["farbschlagVariants"] = [d["farbschlag"]]
|
||||||
|
if d.get("dateOfDeath"): # D5 death-date resolutions
|
||||||
|
a["death"] = norm_dob(d["dateOfDeath"])
|
||||||
if a.get("conflict"):
|
if a.get("conflict"):
|
||||||
a["conflict"] = False
|
a["conflict"] = False
|
||||||
conflicts[:] = [c for c in conflicts if c.get("id") != a["id"]]
|
conflicts[:] = [c for c in conflicts if c.get("id") != a["id"]]
|
||||||
|
|||||||
@@ -78,17 +78,27 @@ _json.dump({"resolutions": [
|
|||||||
{"name": "Firefly von den Kleinen Chaoten", "dob": "18.12.2019",
|
{"name": "Firefly von den Kleinen Chaoten", "dob": "18.12.2019",
|
||||||
"decision": "D-locus = D-", "genotype": "Aa c[chm]c[chm] D- Ee Gg PP Spsp",
|
"decision": "D-locus = D-", "genotype": "Aa c[chm]c[chm] D- Ee Gg PP Spsp",
|
||||||
"source": "test"},
|
"source": "test"},
|
||||||
|
{"name": "Flint von den Kleinen Chaoten", "dob": "23.12.2017",
|
||||||
|
"decision": "Todesdatum 10.05.2021 (2022 war Tippfehler)", "dateOfDeath": "10.05.2021",
|
||||||
|
"source": "test"},
|
||||||
]}, open(dec_path, "w", encoding="utf-8"))
|
]}, open(dec_path, "w", encoding="utf-8"))
|
||||||
merged = [{"id": "x1", "name": "Firefly von den Kleinen Chaoten", "dob": "18.12.2019",
|
merged = [
|
||||||
"conflict": True, "farbschlag": "",
|
{"id": "x1", "name": "Firefly von den Kleinen Chaoten", "dob": "18.12.2019",
|
||||||
"genotype": {"mapped8locus": {"D": ["D", "D"]}, "rawGenotype": "DD", "unmappedTokens": []}}]
|
"conflict": True, "farbschlag": "", "death": "",
|
||||||
conflicts = [{"id": "x1", "name": "Firefly von den Kleinen Chaoten", "dob": "18.12.2019"}]
|
"genotype": {"mapped8locus": {"D": ["D", "D"]}, "rawGenotype": "DD", "unmappedTokens": []}},
|
||||||
|
{"id": "x2", "name": "Flint von den Kleinen Chaoten", "dob": "23.12.2017",
|
||||||
|
"conflict": True, "farbschlag": "", "death": "10.05.2022",
|
||||||
|
"genotype": {"mapped8locus": {}, "rawGenotype": "", "unmappedTokens": []}},
|
||||||
|
]
|
||||||
|
conflicts = [{"id": "x1", "name": "Firefly von den Kleinen Chaoten", "dob": "18.12.2019"},
|
||||||
|
{"id": "x2", "name": "Flint von den Kleinen Chaoten", "dob": "23.12.2017"}]
|
||||||
n = e.apply_conflict_decisions(merged, conflicts, dec_path)
|
n = e.apply_conflict_decisions(merged, conflicts, dec_path)
|
||||||
check("decision un-quarantines (conflict cleared)", merged[0]["conflict"] is False)
|
check("decision un-quarantines (conflict cleared)", merged[0]["conflict"] is False)
|
||||||
check("decision marks resolvedByDecision", merged[0].get("resolvedByDecision") is True)
|
check("decision marks resolvedByDecision", merged[0].get("resolvedByDecision") is True)
|
||||||
check("decision genotype is authoritative (D- not DD)", merged[0]["genotype"]["mapped8locus"]["D"] == ["D", "?"])
|
check("decision genotype is authoritative (D- not DD)", merged[0]["genotype"]["mapped8locus"]["D"] == ["D", "?"])
|
||||||
check("decision removes entry from conflicts list", conflicts == [])
|
check("decision dateOfDeath is authoritative (D5)", merged[1]["death"] == "10.05.2021")
|
||||||
check("apply_conflict_decisions returns resolved count", n == 1)
|
check("decision removes both entries from conflicts list", conflicts == [])
|
||||||
|
check("apply_conflict_decisions returns resolved count", n == 2)
|
||||||
check("missing decisions file tolerated (returns 0)",
|
check("missing decisions file tolerated (returns 0)",
|
||||||
e.apply_conflict_decisions([], [], os.path.join(tempfile.gettempdir(), "does-not-exist.json")) == 0)
|
e.apply_conflict_decisions([], [], os.path.join(tempfile.gettempdir(), "does-not-exist.json")) == 0)
|
||||||
try: os.remove(dec_path)
|
try: os.remove(dec_path)
|
||||||
|
|||||||
Reference in New Issue
Block a user