Validate labels: the user agrees with all the labels of a finished analysis, each gets review (the date)
A change of the labels afterwards (an edit in the page, the analyst after a message) removes it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
a733575d65
commit
b31371a241
4 files changed
+72
-4
No files matched your search
+35
-1
@@ -260,7 +260,41 @@ def check_analysis():
|
||||
analysis.analyses.clear()
|
||||
|
||||
|
||||
CHECKS = [check_server, check_station, check_optimization, check_analysis]
|
||||
def check_validation():
|
||||
# "Validate labels" (analysis.validate): review on all the labels of the analysis, the others untouched; an edit in
|
||||
# the page removes it from one label, and the analysis is no longer validated
|
||||
import analysis
|
||||
before = station.LABELS, analysis.FOLDER
|
||||
station.LABELS = temp_folder()
|
||||
analysis.FOLDER = station.LABELS / "auto" / "analyses"
|
||||
try:
|
||||
for name, report in (("NORDEND_a", True), ("NORDEND_b", False)):
|
||||
(analysis.FOLDER / name).mkdir(parents=True)
|
||||
(analysis.FOLDER / name / "request.json").write_text(json.dumps({"station": "NORDEND"}))
|
||||
if report:
|
||||
(analysis.FOLDER / name / "report.md").write_text("# report")
|
||||
mine = [{"id": f"NORDEND-{i}", "start": "2026-11-05T06:00Z", "end": "2026-11-05T07:00Z", "family": "Visibility",
|
||||
"description": f"fog {i}", "analysis": "NORDEND_a"} for i in (1, 2)]
|
||||
other = {"id": "NORDEND-3", "start": "2026-11-05T06:00Z", "end": "2026-11-05T07:00Z", "family": "Visibility",
|
||||
"description": "rain"}
|
||||
(station.LABELS / "auto" / "NORDEND.jsonl").write_text("".join(json.dumps(e) + "\n" for e in mine + [other]))
|
||||
assert analysis.state("NORDEND_a")["validated"] is None
|
||||
assert "finished" in refuses(analysis.validate, "NORDEND_b") # interrupted, no report
|
||||
assert analysis.validate("NORDEND_a") == {"validated": 2}
|
||||
labels = station.read("NORDEND", "auto")
|
||||
assert [bool(e.get("review")) for e in labels] == [True, True, False], labels
|
||||
assert analysis.state("NORDEND_a")["validated"] == labels[0]["review"]
|
||||
station.update({"station": "NORDEND", "before": labels[0], "family": "Visibility", "description": "fog again"})
|
||||
assert analysis.state("NORDEND_a")["validated"] is None
|
||||
(station.LABELS / "auto" / "NORDEND.jsonl").write_text(json.dumps(other) + "\n")
|
||||
assert "no label" in refuses(analysis.validate, "NORDEND_a")
|
||||
finally:
|
||||
shutil.rmtree(station.LABELS)
|
||||
station.LABELS, analysis.FOLDER = before
|
||||
analysis.analyses.clear()
|
||||
|
||||
|
||||
CHECKS = [check_server, check_station, check_optimization, check_analysis, check_validation]
|
||||
|
||||
if __name__ == "__main__":
|
||||
name = sys.argv[1] if len(sys.argv) > 1 else None
|
||||
|
||||
Reference in new issue
Block a user