From 6b3f46434a097ed2fff68f1f714aa4398a8731f7 Mon Sep 17 00:00:00 2001 From: maxime Date: Thu, 19 Nov 2026 11:13:38 +0100 Subject: [PATCH] Stations: pump the differential images into data_diff/ (pump_diff.sh through pumping.py, diff), beside the pumping of data/, each with its state and log Co-Authored-By: Claude Opus 5.5 --- app/server/check.py | 2 ++ app/server/server.py | 4 ++-- app/server/station.py | 18 +++++++++--------- app/web/src/pages/Stations.jsx | 25 +++++++++++++++---------- 4 files changed, 28 insertions(+), 21 deletions(-) diff --git a/app/server/check.py b/app/server/check.py index 23e40d6..dba6982 100644 --- a/app/server/check.py +++ b/app/server/check.py @@ -79,6 +79,8 @@ def check_station(): assert all(e["message"] and e["action"] and set(e["targets"] + e["references"]) == set(e["sensors"]) for e in ev), ev[:1] assert all(e["end"] >= "2026-10-26T00:00Z" and e["start"] < "2026-10-27T00:00Z" for e in ev), [(e["start"], e["end"]) for e in ev] refuses(station.pump, {"stations": ["A;rm"]}) # the pumping (extraction/pumping.py, checked there): a refusal + refuses(station.pump, {"stations": ["A;rm"], "diff": True}) + assert set(station.pump_state(True)) == {"running", "log"} 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 diff --git a/app/server/server.py b/app/server/server.py index b4456e5..18f65f4 100644 --- a/app/server/server.py +++ b/app/server/server.py @@ -91,8 +91,8 @@ def save_tracked(body: dict): @app.get("/api/pump") -def pump_state(): - return station.pump_state() +def pump_state(diff: bool = False): + return station.pump_state(diff) @app.post("/api/pump") diff --git a/app/server/station.py b/app/server/station.py index 3c79b47..c269b77 100644 --- a/app/server/station.py +++ b/app/server/station.py @@ -236,7 +236,7 @@ def weather(hours): # --- the tracked stations and the pumping: extraction/pumping.py of ~/aimsight-data -pump_process = None # the pumping launched by the app +pump_process = {} # the pumpings launched by the app, by diff (pump_diff.sh, into data_diff/: beside pump.sh) def save_tracked(rows): @@ -246,22 +246,22 @@ def save_tracked(rows): raise Refusal(str(e)) -def pump_state(): +def pump_state(diff=False): """{running, log}; the end of the app's pumping empties the cache of the detectors' events.""" - global pump_process - if pump_process and pump_process.poll() is not None: - pump_process = None + if (p := pump_process.get(diff)) and p.poll() is not None: + del pump_process[diff] detectors.cache_clear() - return {"running": pumping.running() or pump_process is not None, "log": pumping.log()} + return {"running": pumping.running(diff) or diff in pump_process, "log": pumping.log(diff=diff)} def pump(body): - global pump_process + diff = bool(body.get("diff")) try: - pump_process = pumping.start(body.get("stations") or [], body.get("start") or "", body.get("end") or "", body.get("images")) + pump_process[diff] = pumping.start(body.get("stations") or [], body.get("start") or "", body.get("end") or "", + body.get("images"), diff) except ValueError as e: raise Refusal(str(e)) - return pump_state() + return pump_state(diff) # --- the Data page, "Detectors" labels: the events of the journal, read-only diff --git a/app/web/src/pages/Stations.jsx b/app/web/src/pages/Stations.jsx index 8062ba6..093cfd2 100644 --- a/app/web/src/pages/Stations.jsx +++ b/app/web/src/pages/Stations.jsx @@ -1,29 +1,31 @@ import { useEffect, useState } from "react"; -import { ActionIcon, Button, Card, Checkbox, Code, Group, ScrollArea, Stack, Table, Text, TextInput, Title } from "@mantine/core"; +import { ActionIcon, Button, Card, Checkbox, Code, Group, ScrollArea, SegmentedControl, Stack, Table, Text, TextInput, Title } from "@mantine/core"; import { IconPlus, IconX } from "@tabler/icons-react"; import { call } from "../common.jsx"; const shift = (d, n) => (d ? new Date(Date.parse(d) + n * 864e5).toISOString().slice(0, 10) : ""); // The tracked stations (extraction/stations.txt of ~/aimsight-data): serial and position (for the weather of the Data page); -// the checked ones pumped (extraction/pump.sh) over a range, or without range their missing days up to now. The state of -// the pumping read every 2 s. By default, every station checked, and the range of the address (From 3 days before: the history of +// the checked ones pumped (extraction/pump.sh) over a range, or without range their missing days up to now; or their +// differential images into data_diff/ (extraction/pump_diff.sh, its own lock: beside pump.sh). The state of the chosen +// pumping read every 2 s. By default, every station checked, and the range of the address (From 3 days before: the history of // the detectors) export default function Stations({ selection }) { const [rows, setRows] = useState([]), [checked, setChecked] = useState([]); const [range, setRange] = useState({ start: shift(selection.start, -3), end: selection.end }); - const [images, setImages] = useState(true), [state, setState] = useState(null); + const [images, setImages] = useState(true), [diff, setDiff] = useState(false), [state, setState] = useState(null); useEffect(() => { call("/api/tracked").then(l => { if (l) { setRows(l); setChecked(l.map(r => r.serial)); } }); }, []); useEffect(() => { - const read = () => fetch("/api/pump").then(r => r.ok && r.json()).then(p => p && setState(p)).catch(() => {}); // silently + setState(null); + const read = () => fetch(`/api/pump?diff=${diff}`).then(r => r.ok && r.json()).then(p => p && setState(p)).catch(() => {}); // silently read(); const timer = setInterval(read, 2000); return () => clearInterval(timer); - }, []); + }, [diff]); const running = !!state?.running; const set = (i, k, v) => setRows(rows.map((r, n) => (n === i ? { ...r, [k]: v } : r))); const save = () => call("/api/tracked", "PUT", { stations: rows.filter(r => r.serial) }).then(l => l && setRows(l)); - const pump = () => call("/api/pump", "POST", { stations: checked, ...range, images }).then(p => p && setState(p)); + const pump = () => call("/api/pump", "POST", { stations: checked, ...range, images, diff }).then(p => p && setState(p)); return (
@@ -59,14 +61,17 @@ export default function Stations({ selection }) { + setDiff(v === "diff")} w="fit-content" + data={[{ value: "data", label: "Data (data/)" }, { value: "diff", label: "Differential images (data_diff/)" }]} /> setRange({ ...range, start: e.currentTarget.value })} /> setRange({ ...range, end: e.currentTarget.value })} /> - setImages(e.currentTarget.checked)} mb={8} /> + {!diff && setImages(e.currentTarget.checked)} mb={8} />} - By default From is 3 days before the range of the Data page (the history of the detectors); - without dates, the missing days of each station up to now. A long range, outside busy hours. + {diff + ? "The differential images, full size, with the metrics, the IRON images (one per hour) and the weather, into data_diff//; never data/ nor the runs. Without dates, from the last indexed day of each station up to now (a station never pumped is skipped: its history starts with a range). Heavy (~600 MB a day): a long range, outside busy hours." + : "By default From is 3 days before the range of the Data page (the history of the detectors); without dates, the missing days of each station up to now. A long range, outside busy hours."} {state?.log?.length > 0 && ( v && (v.scrollTop = v.scrollHeight)}> {state.log.join("\n")}