Data: the runs of data_diff/ as stations <SERIAL>@<run>, with the labels of <SERIAL>; refused by the analyst and the support
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
8e1aecc6cf
commit
d4d2e6b7b1
5 files changed
+37
-12
No files matched your search
@@ -5,7 +5,7 @@ aimsight-app: the control station of the AIMsight diagnostic (`README.md`): the
|
||||
- **The processes**: the Analysis tab launches `agents:analyst` (plugin `agents/`) on a range, with `instructions/analyst.md` and `DETECTORS: no` (labels and report in `labeling/auto/analyses/<STATION>_<start>_<end>/`, submitted to `labeling/auto/<STATION>.jsonl`); "Optimize the detectors" launches `/optimize` in `optimizer/` on the analysis (its request in `app/server/analysis.py`, its summary in `optimizer/sessions/<analysis>_<time>/summary.md`), which commits the detectors in `detectors/` and the reading tools in `tools/`; the Support tab launches `agents:support` on a range with a question and `instructions/support.md` (its answer in `labeling/auto/support/<STATION>_<start>_<end>/answer.md`; it may launch the analyst itself; nothing submitted); the Conversations page launches `libredesk/conversations/pomper.sh` (read-only on LibreDesk, its key in `~/aimsight-libredesk/.env`), each conversation in `labeling/auto/conversations/<reference>/` (`transcript.md`, `messages.json`, `attachments/`).
|
||||
- **The links** (ignored by git, one copy of each repository on the workstation): `data/`, `labeling/`, `detectors/`, `tools/`, `agents/`, `optimizer/`, `models/` (the pilot of learned detectors), `libredesk/` (the LibreDesk conversations); each thing is committed in its own repository, never here. This repository carries no agent, no reading tool, no workflow.
|
||||
- **The truth**: the labels of `labeling/auto/`; the labeling knowledge is in `labeling/`.
|
||||
- **The contracts**: the app calls the methods of the other repositories and holds no domain logic: with the detectors, `detectors/CLAUDE.md` (`categories.window`, `bench/score.py`); with the labels, `labeling/CLAUDE.md` (`scripts/validate.py` `check`, `scripts/ids.py` `assign`, `scripts/client.py`); with the data, `~/aimsight-data` (`extraction/pumping.py`; the weather is pumped into `data/<STATION>/weather/`); with the agents, `agents/README.md` (the requests of the analyst and of the support); with Optimizer, `optimizer/README.md` (the request of `/optimize`); with LibreDesk, `libredesk/conversations/pompage.py` (`start`, `running`, `log`). A renaming over there requires the change here. One reader of the measurements, `tools/scripts/data.py`, for the Data page, the tools and the detectors (benchmark and Optimizer included): a reading fix there changes the benchmark.
|
||||
- **The contracts**: the app calls the methods of the other repositories and holds no domain logic: with the detectors, `detectors/CLAUDE.md` (`categories.window`, `bench/score.py`); with the labels, `labeling/CLAUDE.md` (`scripts/validate.py` `check`, `scripts/ids.py` `assign`, `scripts/client.py`); with the data, `~/aimsight-data` (`extraction/pumping.py`; the weather is pumped into `data/<STATION>/weather/`; the runs of `data_diff/<SERIAL>/runs/<run>/` are stations `<SERIAL>@<run>` of the Data page, with the labels of `<SERIAL>`, not for the agents); with the agents, `agents/README.md` (the requests of the analyst and of the support); with Optimizer, `optimizer/README.md` (the request of `/optimize`); with LibreDesk, `libredesk/conversations/pompage.py` (`start`, `running`, `log`). A renaming over there requires the change here. One reader of the measurements, `tools/scripts/data.py`, for the Data page, the tools and the detectors (benchmark and Optimizer included): a reading fix there changes the benchmark.
|
||||
- **The benchmark**: `python3 detectors/bench/regression.py --labels labeling/auto --data data` (~1 min); the score of a range: `python3 detectors/bench/score.py data/<STATION> --labels labeling/auto/<STATION>.jsonl --from YYYY-MM-DD --to YYYY-MM-DD` (`--to` excluded).
|
||||
- **The pumping**: in `~/aimsight-data` (`extraction/pump.sh`, VS Code tasks **pump**, **pump a range**), read-only on the platform; user guide `~/aimsight-data/extraction/README.md`. Claude may launch it on small ranges; a long range or a history, outside busy hours.
|
||||
- **Check a change of the app**: `.venv/bin/python app/server/check.py`, then `cd app/web && npm run build` and launch the server. The labels: `python3 labeling/validate.py`.
|
||||
|
||||
@@ -58,7 +58,7 @@ def _optimizing():
|
||||
def launch(body):
|
||||
st, start, end = body.get("station"), body.get("start"), body.get("end")
|
||||
station.checked_range(start, end)
|
||||
station.folder(st)
|
||||
station.pumped(st)
|
||||
if not (AGENTS / ".claude-plugin" / "plugin.json").exists():
|
||||
raise station.Refusal("no agents in agents/ (the link: README.md)")
|
||||
name = f"{st}_{start[:16].replace(':', '')}_{end[:16].replace(':', '')}"
|
||||
|
||||
@@ -81,6 +81,11 @@ def check_station():
|
||||
refuses(station.pump, {"stations": ["A;rm"]}) # the pumping (extraction/pumping.py, checked there): a refusal
|
||||
assert not any("SIM_CCID" in t or t.startswith("System: ip") for t in titles)
|
||||
assert all(len(c["T"][tr["t"]]) == len(tr["y"]) for p in c["plots"] for tr in p["traces"])
|
||||
if run := next((s for s in station.stations() if station.RUN in s), None): # a run of data_diff/, read as a station
|
||||
c = station.curves(run, "", "")
|
||||
assert c["plots"] and station.images(run, c["A"], c["B"])["images"], run
|
||||
assert station.label_file(run, "auto").name == station.serial(run) + ".jsonl"
|
||||
assert "data_diff" in refuses(station.pumped, run)
|
||||
before, station.LABELS = station.LABELS, temp_folder()
|
||||
try:
|
||||
e = station.add({"station": "NIEDERHORN", "folder": "auto", "start": "2026-09-25T01:00Z",
|
||||
|
||||
+29
-9
@@ -5,6 +5,9 @@ events are those of detectors/scripts/categories.py (window); the rules of the l
|
||||
labeling/scripts (validate, ids, client). Read-only on data/, filled only by pump.sh; writes only in
|
||||
labeling/auto/. What brings data in (the pumping, the list of the tracked stations) is in ~/aimsight-data, called as it
|
||||
is (extraction/pumping.py); the weather is pumped with the data, data/<STATION>/weather/ (data.load_weather).
|
||||
The runs of the differential data (data_diff/<SERIAL>/runs/<run>/ of ~/aimsight-data) are stations too, <SERIAL>@<run>:
|
||||
read by the same reader (data.shared: their images, metrics and weather in data_diff/<SERIAL>/); their labels are those of
|
||||
<SERIAL>.
|
||||
"""
|
||||
import bisect
|
||||
import functools
|
||||
@@ -34,6 +37,8 @@ import validate # noqa: E402 (labeling: the rules of a label)
|
||||
# data/ and labeling/ are links to ~/aimsight-data/data and ~/aimsight-labeling: no resolve(), the agents see data/ and labeling/
|
||||
DATA = Path(os.environ.get("AIMSIGHT_DATA", ROOT / "data")).absolute()
|
||||
LABELS = Path(os.environ.get("AIMSIGHT_LABELS", ROOT / "labeling")).absolute()
|
||||
DATA_DIFF = DATA_REPOSITORY / "data_diff" # the runs, data_diff/<SERIAL>/runs/<run>/: out of git, filled by ~/aimsight-data
|
||||
RUN = "@" # <SERIAL>@<run>: a run of data_diff/ in the list of the stations
|
||||
TOOLS = ROOT / "tools" # the reading harness (~/aimsight-tools), read by the analyst and written by the upgrader (Optimizer)
|
||||
|
||||
|
||||
@@ -61,13 +66,27 @@ class Refusal(ValueError):
|
||||
|
||||
|
||||
def stations():
|
||||
return sorted(d.name for d in DATA.iterdir() if d.is_dir())
|
||||
runs = sorted(f"{d.parent.parent.name}{RUN}{d.name}" for d in DATA_DIFF.glob("*/runs/*") if d.is_dir())
|
||||
return sorted(d.name for d in DATA.iterdir() if d.is_dir()) + runs
|
||||
|
||||
|
||||
def serial(station):
|
||||
"""The station of a run, <SERIAL>@<run> -> <SERIAL> (its labels); a station of data/ -> itself."""
|
||||
return station.partition(RUN)[0]
|
||||
|
||||
|
||||
def folder(station):
|
||||
if station not in stations(): # the name becomes a path: a folder of data/, nothing else
|
||||
if station not in stations(): # the name becomes a path: a folder of data/ or a run of data_diff/, nothing else
|
||||
raise Refusal(f"unknown station: {station}")
|
||||
return DATA / station
|
||||
s, _, run = station.partition(RUN)
|
||||
return DATA_DIFF / s / "runs" / run if run else DATA / station
|
||||
|
||||
|
||||
def pumped(station):
|
||||
"""A station of data/ (the agents read data/ only): a run of data_diff/ refused."""
|
||||
folder(station)
|
||||
if RUN in station:
|
||||
raise Refusal(f"{station} is a run of data_diff/: the agents read the stations of data/ only")
|
||||
|
||||
|
||||
def bounds(start, end):
|
||||
@@ -94,7 +113,7 @@ def images(station, start, end):
|
||||
"""The images of [start, end), the median positions of the sensors, the references, and for each circled sensor its
|
||||
corr_x, corr_y at the time of each image: the nearest valid measurement, within 30 min, otherwise 0."""
|
||||
d, (a, b) = folder(station), bounds(start, end)
|
||||
views = [(t, im) for im in sorted(glob.glob(str(d / "images" / "*"))) if (t := data.image_time(im)) and a <= t < b]
|
||||
views = [(t, im) for im in sorted(glob.glob(str(Path(data.shared(d)) / "images" / "*"))) if (t := data.image_time(im)) and a <= t < b]
|
||||
if not views:
|
||||
raise Refusal(f"no image of {station} in this range")
|
||||
measurements = data.load(d)
|
||||
@@ -114,8 +133,9 @@ def images(station, start, end):
|
||||
|
||||
|
||||
def image(station, name):
|
||||
f = (folder(station) / "images" / name).resolve()
|
||||
if f.parent != (DATA / station / "images").resolve() or not f.is_file():
|
||||
images = Path(data.shared(folder(station))) / "images"
|
||||
f = (images / name).resolve()
|
||||
if f.parent != images.resolve() or not f.is_file():
|
||||
raise Refusal("unknown image")
|
||||
return f
|
||||
|
||||
@@ -184,7 +204,7 @@ def curves(station, start, end):
|
||||
T.update(times)
|
||||
out += plots
|
||||
result["weather"] = label
|
||||
elif pumping.tracked().get(station):
|
||||
elif pumping.tracked().get(serial(station)):
|
||||
result["weather"] = "none pumped in this range (see the pumping log)"
|
||||
return result
|
||||
|
||||
@@ -294,7 +314,7 @@ def label_file(station, source):
|
||||
if source not in FOLDERS:
|
||||
raise Refusal("unknown label folder")
|
||||
folder(station)
|
||||
return LABELS / source / f"{station}.jsonl"
|
||||
return LABELS / source / f"{serial(station)}.jsonl"
|
||||
|
||||
|
||||
CORE = ("start", "end", "family", "description") # what a label says; the rest (id, review, analysis) is about it
|
||||
@@ -339,7 +359,7 @@ def add(body):
|
||||
label = {"start": body.get("start"), "end": body.get("end"), "family": body.get("family"),
|
||||
"description": (body.get("description") or "").strip()}
|
||||
checked(label)
|
||||
ids.assign(station, read(station, source) + [label]) # a stable id, the next of its station (D-131)
|
||||
ids.assign(serial(station), read(station, source) + [label]) # a stable id, the next of its station (D-131)
|
||||
f.parent.mkdir(parents=True, exist_ok=True)
|
||||
before = f.read_bytes() if f.exists() else b"" # a line removed by hand may leave the file without a final newline
|
||||
with open(f, "ab") as out:
|
||||
|
||||
@@ -28,7 +28,7 @@ def launch(body):
|
||||
st, start, end = body.get("station"), body.get("start"), body.get("end")
|
||||
question = (body.get("question") or "").strip()
|
||||
station.checked_range(start, end)
|
||||
station.folder(st)
|
||||
station.pumped(st)
|
||||
if not question:
|
||||
raise station.Refusal("no question for the support")
|
||||
if not (analysis.AGENTS / "agents" / "support.md").exists():
|
||||
|
||||
Reference in new issue
Block a user