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
+25
-2
@@ -4,7 +4,8 @@ by `claude -p`, non-interactive, on a range chosen in the page, with the user's
|
||||
labeling/auto/analyses/<STATION>_<start>_<end>/ its labels (labels.jsonl) and a diagnostic report (report.md, its figures
|
||||
next to it); at the end, the server submits its labels to labeling/auto/<STATION>.jsonl, marked with their analysis (field
|
||||
`analysis`). Then the user can write to it: the same session resumes (`claude -p --resume`), and its labels, if they
|
||||
change, replace those it had submitted.
|
||||
change, replace those it had submitted. "Validate labels": the user agrees with all the labels of the analysis, each gets
|
||||
`review`, the date (labeling/README.md); labels the analyst changes afterwards are submitted again without it.
|
||||
On a finished analysis, "Optimize" launches `/optimize` in Optimizer (optimizer/, the skill that, from the analysis, improves
|
||||
the detectors on its range, its labels as truth, then brings the analyst's scripts into the reading tools, tools/); one
|
||||
optimization at a time, no analysis or message meanwhile; the summary of the session
|
||||
@@ -186,11 +187,33 @@ def state(name):
|
||||
analyses[name] = {"state": "done" if (out / "report.md").exists() else "interrupted", "lines": lines,
|
||||
"submitted": None, "station": request["station"], "request": request}
|
||||
a, r = analyses[name], out / "report.md"
|
||||
return {"name": name, "state": a["state"], "lines": a["lines"], "submitted": a["submitted"],
|
||||
labels = [e for e in station.read(a["station"], "auto") if e.get("analysis") == name]
|
||||
validated = max(e["review"] for e in labels) if labels and all(e.get("review") for e in labels) else None
|
||||
return {"name": name, "state": a["state"], "lines": a["lines"], "submitted": a["submitted"], "validated": validated,
|
||||
"report": int(r.stat().st_mtime) if r.exists() else None,
|
||||
"dialogue": (out / "work" / "session").exists(), "request": a["request"], "optimization": optimization(name)}
|
||||
|
||||
|
||||
def validate(name):
|
||||
"""The "Validate labels" button: the user agrees with all the labels of the finished analysis -> their number."""
|
||||
a = state(name)
|
||||
if a["state"] != "done":
|
||||
raise station.Refusal("only a finished analysis can be validated")
|
||||
today = datetime.now(timezone.utc).strftime("%Y-%m-%d")
|
||||
with lock:
|
||||
f = station.label_file(a["request"]["station"], "auto") # the other lines stay as they are
|
||||
lines, n = f.read_text(encoding="utf-8").split("\n") if f.exists() else [], 0
|
||||
for i, l in enumerate(lines):
|
||||
if l.strip() and (e := json.loads(l)).get("analysis") == name:
|
||||
lines[i], n = json.dumps(e | {"review": today}, ensure_ascii=False), n + 1
|
||||
if not n:
|
||||
raise station.Refusal(f"no label of this analysis in labeling/auto/{f.name}")
|
||||
temp = f.with_name(f.name + ".tmp")
|
||||
temp.write_text("\n".join(lines), encoding="utf-8")
|
||||
os.replace(temp, f)
|
||||
return {"validated": n}
|
||||
|
||||
|
||||
def list_analyses():
|
||||
"""The history of the analyses (the sidebar), the most recent first: those of the server with their state, the others
|
||||
read on disk (done with a report, otherwise interrupted: an analysis stops with the server)."""
|
||||
|
||||
Reference in new issue
Block a user