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

+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>