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 <noreply@anthropic.com>
This commit is contained in:
maximeandClaude Opus 5.5 committed 2026-11-19 11:13:38 +01:00
1 parent cce6b850c6
commit 6b3f46434a
4 files changed
+28 -21

No files matched your search

+2
View File
@@ -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
+2 -2
View File
@@ -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")
+9 -9
View File
@@ -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
+15 -10
View File
@@ -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 (
<Stack gap="lg" maw={1000}>
<div>
@@ -59,14 +61,17 @@ export default function Stations({ selection }) {
</Card>
<Card shadow="sm" withBorder>
<Stack gap="md">
<SegmentedControl value={diff ? "diff" : "data"} onChange={v => setDiff(v === "diff")} w="fit-content"
data={[{ value: "data", label: "Data (data/)" }, { value: "diff", label: "Differential images (data_diff/)" }]} />
<Group align="flex-end" gap="md">
<TextInput label="From (UTC)" type="date" value={range.start} onChange={e => setRange({ ...range, start: e.currentTarget.value })} />
<TextInput label="To (excluded)" type="date" value={range.end} onChange={e => setRange({ ...range, end: e.currentTarget.value })} />
<Checkbox label="Images" checked={images} onChange={e => setImages(e.currentTarget.checked)} mb={8} />
{!diff && <Checkbox label="Images" checked={images} onChange={e => setImages(e.currentTarget.checked)} mb={8} />}
<Button onClick={pump} loading={running} disabled={!checked.length}>Pump {checked.length || ""}</Button>
</Group>
<Text size="xs" c="dimmed">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.</Text>
<Text size="xs" c="dimmed">{diff
? "The differential images, full size, with the metrics, the IRON images (one per hour) and the weather, into data_diff/<SERIAL>/; 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."}</Text>
{state?.log?.length > 0 && (
<ScrollArea h={320} viewportRef={v => v && (v.scrollTop = v.scrollHeight)}>
<Code block>{state.log.join("\n")}</Code>