Adds parquet files.
Browse files- CLAUDE.md +294 -27
- README.md +37 -9
- data/ticks/001.parquet +3 -0
- data/ticks/{1.parquet → 002.parquet} +2 -2
- data/ticks/012.parquet +3 -0
- data/ticks/{14.parquet → 013.parquet} +2 -2
- data/ticks/{16.parquet → 014.parquet} +2 -2
- data/ticks/{13.parquet → 016.parquet} +2 -2
- data/ticks/{17.parquet → 017.parquet} +2 -2
- data/ticks/{12.parquet → 025.parquet} +2 -2
- data/ticks/026.parquet +3 -0
- data/ticks/028.parquet +3 -0
- data/ticks/2.parquet +0 -3
- data/ticks/25.parquet +0 -3
- data/ticks/26.parquet +0 -3
- data/ticks/28.parquet +0 -3
- scripts/_lib.py +2 -36
- scripts/ticks/01_extract.py +80 -14
CLAUDE.md
CHANGED
|
@@ -1,49 +1,295 @@
|
|
| 1 |
# CLAUDE.md
|
| 2 |
|
| 3 |
-
Context for continuing work on this dataset. Captures the design decisions and
|
| 4 |
|
| 5 |
## What this dataset is
|
| 6 |
|
| 7 |
-
`Inova-Mk1-Telemetry` is the **tick-anchored printer-state dataset**: one row per 10 Hz recorder tick, with the full sensor snapshot (~64 columns: temperatures, position, power, lights) on every row, the nearest camera frame
|
| 8 |
|
| 9 |
It is the **third leaf** in the Inova Mk1 dataset ecosystem alongside `Inova-Mk1-Database` (canonical printer entities) and `Inova-Mk1-ASTM` (mechanical-test specimens).
|
| 10 |
|
| 11 |
-
Unlike the other two, this dataset has **no local `source/` directory** — its raw inputs are the flat exports written by
|
| 12 |
|
| 13 |
-
##
|
| 14 |
|
| 15 |
-
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
## Architectural decisions
|
| 21 |
|
| 22 |
- **One config, not four.** Early iteration had separate `builds`, `telemetry`, `position_hf`, and `frames` configs. Replaced with a single `ticks` config because ML consumers almost always want the joined view: state + frame + position at one moment in time. The four-silo version pushed the join cost onto every downstream user.
|
| 23 |
-
- **Anchor on the 10 Hz telemetry tick, not strict outer join.** The recorder's `/state/snapshot` poll fires at 10 Hz and emits a deterministic ~64-row burst into the `telemetry` table — so a tick already represents a full state snapshot. Anchoring on ticks gives every row densely populated columns; frames and `position_hf` attach to the tick they're closest to. A strict outer join across all stream timestamps gave ~3M mostly-sparse rows for less ML value.
|
| 24 |
- **Wide format, dotted column names matching upstream.** Sensor columns are named exactly `{sensor_id}.{kind}` — e.g. `powderBed.temp.current`, `laser.power`, `positions.position.x`. This matches the upstream `sensors.csv` glossary 1:1 so unit annotations land where consumers will look. ~64 sensor columns + build context + frame paths + position burst = 78 columns total.
|
| 25 |
-
- **Frames attach by nearest-before-tick within a 100 ms window
|
|
|
|
| 26 |
- **`position_hf` preserved as per-tick bursts.** The firmware emits `PositionChangedHighFrequency` event-driven, not at fixed 1 kHz — so it bursts during motion and is empty during heating. We keep the full burst inside each tick's window as `position_hf_burst: list<struct<ts_offset_ms, x, y, z1, z2, r, has_homed>>`. Empty list when no motion. Lossless within the 100 ms window; the raw `position_hf/{build_id}.parquet` upstream is the fallback if you need motion data between ticks.
|
| 27 |
-
- **Build context denormalized into every row.** `build_id`, `job_name`, `started_at`, `ended_at`, `phase`, `
|
| 28 |
-
- **
|
|
|
|
| 29 |
- **Polars for the pivot + asof joins.** ~22 M telemetry rows (build 26) pivot to ~355 K ticks in seconds. Polars' `pivot` and `join_asof(tolerance=100ms)` do the heavy lifting; the position_hf burst is a manual sorted-merge.
|
|
|
|
| 30 |
|
| 31 |
## Directory layout
|
| 32 |
|
| 33 |
```
|
| 34 |
.python-version # 3.13
|
| 35 |
pyproject.toml # pyarrow, polars
|
|
|
|
| 36 |
|
| 37 |
scripts/
|
| 38 |
_lib.py # sibling-repo paths, FK resolver
|
| 39 |
-
ticks/01_extract.py # the single ETL — wide-pivot + asof + burst
|
| 40 |
|
| 41 |
data/
|
| 42 |
-
ticks/{build_id}.parquet
|
| 43 |
```
|
| 44 |
|
| 45 |
There is no `source/` (raw data lives in the sibling recorder repo's `data/exports/`).
|
| 46 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
## Row shape
|
| 48 |
|
| 49 |
```python
|
|
@@ -55,7 +301,6 @@ There is no `source/` (raw data lives in the sibling recorder repo's `data/expor
|
|
| 55 |
"job_name": "D790 and D638 and Benchy 2026_06_02",
|
| 56 |
"started_at": "...", "ended_at": "...",
|
| 57 |
"phase": "Heating",
|
| 58 |
-
"print_profile_id": "feafe2b0-...",
|
| 59 |
"print_profile_name": "2026_05_30 20mJ/mm Formlabs PA12 GF",
|
| 60 |
"inova_session_id": None, # filled when upstream CSV is curated
|
| 61 |
|
|
@@ -81,9 +326,9 @@ There is no `source/` (raw data lives in the sibling recorder repo's `data/expor
|
|
| 81 |
"quadrant1.temp.current": ..., "surfaceAvg.temp.average": ...,
|
| 82 |
...
|
| 83 |
|
| 84 |
-
# Frames
|
| 85 |
-
"frame_chamber": "26/1780265532038_chamber.jpg",
|
| 86 |
-
"frame_galvo": "26/1780265532040_galvo.png",
|
| 87 |
"frame_thermal": None, # nothing in window
|
| 88 |
|
| 89 |
# 1 kHz position-stream burst within (tick_ts - 100ms, tick_ts]
|
|
@@ -94,31 +339,53 @@ There is no `source/` (raw data lives in the sibling recorder repo's `data/expor
|
|
| 94 |
}
|
| 95 |
```
|
| 96 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 97 |
## Important gotchas
|
| 98 |
|
| 99 |
-
- **`frame_*`
|
| 100 |
- **`positions.position.*` columns are 10 Hz**, not 1 kHz. They come from the snapshot's `position` field. For 1 kHz fidelity during motion, read `position_hf_burst`.
|
| 101 |
-
- **`inova_session_id` is always null** until someone curates `build_to_inova_session.csv` in the recorder repo.
|
| 102 |
- **`build_id` is a Postgres BIGSERIAL**, not a UUID. One Database `PrintSession` may have many `build_id`s (one per recorder restart / attempt). That's why session-id mapping must be hand-authored.
|
| 103 |
- **Sensor units are firmware-convention, not labeled in this dataset.** `*.temp.*` are °C, `*.power*` are W, `positions.position.*` are **microns** (firmware native; divide by 1000 for mm). Authoritative annotations live in the upstream `sensors.csv` glossary; when it's filled in, the dataset card will be updated.
|
| 104 |
- **Builds without `telemetry/{build_id}.parquet` produce no file here.** `data/ticks/` will have gaps for failed-heating runs (typically 12–38 s with zero recorded telemetry).
|
| 105 |
- **The 100 ms window is the recorder's tick interval.** Frame attachment is "the most recent frame within the prior tick interval"; this is a design choice (could be wider or interpolated). If a frame is more than 100 ms stale at tick time, it's null even if it's the closest existing frame. Consider widening the window if frame_kind null rates feel too high.
|
|
|
|
|
|
|
|
|
|
| 106 |
|
| 107 |
## Current state
|
| 108 |
|
| 109 |
-
- `ticks` config: implemented
|
| 110 |
-
-
|
| 111 |
-
- `events` and `plotter_commands`
|
|
|
|
|
|
|
| 112 |
|
| 113 |
## Adding a build — recipe
|
| 114 |
|
| 115 |
1. New build runs in the recorder, produces telemetry / frames / position_hf in Postgres + on disk.
|
| 116 |
-
2. Run `scripts/export.py` in the recorder repo to refresh `data/exports/`.
|
| 117 |
-
3.
|
| 118 |
-
4.
|
|
|
|
| 119 |
|
| 120 |
-
## Regenerate
|
| 121 |
|
| 122 |
```sh
|
|
|
|
| 123 |
uv run scripts/ticks/01_extract.py
|
| 124 |
```
|
|
|
|
|
|
|
|
|
| 1 |
# CLAUDE.md
|
| 2 |
|
| 3 |
+
Context for continuing work on this dataset. Captures the design decisions, conventions, and operational details worked out so far. Read this before touching the ETL or schema.
|
| 4 |
|
| 5 |
## What this dataset is
|
| 6 |
|
| 7 |
+
`Inova-Mk1-Telemetry` is the **tick-anchored printer-state dataset**: one row per 10 Hz recorder tick, with the full sensor snapshot (~64 columns: temperatures, position, power, lights) on every row, the nearest camera frame bytes embedded inline when one fell in the prior 100 ms window, and 1 kHz `position_hf` events from that window collected as a per-tick list.
|
| 8 |
|
| 9 |
It is the **third leaf** in the Inova Mk1 dataset ecosystem alongside `Inova-Mk1-Database` (canonical printer entities) and `Inova-Mk1-ASTM` (mechanical-test specimens).
|
| 10 |
|
| 11 |
+
Unlike the other two, this dataset has **no local `source/` directory** — its raw inputs are the flat exports written by a sibling Git repo (`Agentic-Additive-Manufacturing-Process-Optimization`, "the recorder"). The ETL here reshapes those flat exports into one parquet file per build.
|
| 12 |
|
| 13 |
+
## Data lineage — printer to row
|
| 14 |
|
| 15 |
+
End-to-end, before this dataset's ETL touches anything:
|
| 16 |
+
|
| 17 |
+
```
|
| 18 |
+
┌────────────────────────────┐
|
| 19 |
+
│ Inova Mk1 SLS printer │ firmware events: position, temp, power, lights;
|
| 20 |
+
│ (SLS4All.Compact) │ camera frames (chamber, galvo, thermal);
|
| 21 |
+
│ on 192.168.1.146 │ high-rate position events (~1 kHz, native).
|
| 22 |
+
└──────────────┬─────────────┘
|
| 23 |
+
│ HTTP (port 5001) + WebSocket
|
| 24 |
+
▼
|
| 25 |
+
┌────────────────────────────┐
|
| 26 |
+
│ Inova-API-Plugin │ C# plugin running inside the printer firmware.
|
| 27 |
+
│ (sls4all/Inova-API-Plugin)│ Authoritative source for sensor semantics:
|
| 28 |
+
│ │ • InovaApiPlugin.cs → defines /state/snapshot
|
| 29 |
+
│ │ • exposes /movement/position/stream (~1 kHz WS)
|
| 30 |
+
│ │ • exposes /temperature/bedmatrix/stream (~2 Hz WS)
|
| 31 |
+
│ │ • exposes /plotter/commands/stream (per slicer cmd)
|
| 32 |
+
└──────────────┬─────────────┘
|
| 33 |
+
│ REST polling + WS streams
|
| 34 |
+
▼
|
| 35 |
+
┌────────────────────────────┐
|
| 36 |
+
│ Recorder repo │ TypeScript/Fastify server runs as a long-lived
|
| 37 |
+
│ (Agentic-Additive-…-Opt) │ background process; writes to Postgres + image
|
| 38 |
+
│ │ files on disk.
|
| 39 |
+
│ │ server/src/recorder/telemetry.ts
|
| 40 |
+
│ │ • polls /state/snapshot @ 10 Hz
|
| 41 |
+
│ │ • expand() explodes each frame into the
|
| 42 |
+
│ │ deterministic ~64 (sensor_id, kind) rows
|
| 43 |
+
│ │ of the `telemetry` table
|
| 44 |
+
│ │ server/src/recorder/positionStream.ts
|
| 45 |
+
│ │ • subscribes WS /movement/position/stream
|
| 46 |
+
│ │ • writes `position_hf` rows on motion events
|
| 47 |
+
│ │ server/src/recorder/camera.ts
|
| 48 |
+
│ │ • polls firmware HTTP frame endpoints
|
| 49 |
+
│ │ • writes JPG/PNG/GIF to data/frames/{build}/
|
| 50 |
+
│ │ • writes one row per file in `frames` table
|
| 51 |
+
└──────────────┬─────────────┘
|
| 52 |
+
│ scripts/export.py (in the recorder repo)
|
| 53 |
+
▼
|
| 54 |
+
┌────────────────────────────┐
|
| 55 |
+
│ Flat exports │ Idempotent dumps of the live Postgres + frame
|
| 56 |
+
│ data/exports/ │ files. Contract surface between the recorder
|
| 57 |
+
│ in the recorder repo │ repo and this dataset.
|
| 58 |
+
│ │ builds.jsonl — 30 builds
|
| 59 |
+
│ │ events.jsonl — sparse
|
| 60 |
+
│ │ frames.jsonl — ~1.27 M
|
| 61 |
+
│ │ plotter_commands.jsonl — 0 rows
|
| 62 |
+
│ │ telemetry/{build_id}.parquet — ~10 files
|
| 63 |
+
│ │ position_hf/{build_id}.parquet — sparse
|
| 64 |
+
│ │ build_to_inova_session.csv — sidecar
|
| 65 |
+
│ │ sensors.csv — sidecar
|
| 66 |
+
└──────────────┬─────────────┘
|
| 67 |
+
│ scripts/ticks/01_extract.py (here)
|
| 68 |
+
▼
|
| 69 |
+
┌────────────────────────────┐
|
| 70 |
+
│ This dataset │ Per-build wide parquet, one row per 10 Hz tick.
|
| 71 |
+
│ data/ticks/{NNN}.parquet │ Embedded image bytes, denormalized build
|
| 72 |
+
│ │ context, ~78 columns including position burst.
|
| 73 |
+
└────────────────────────────┘
|
| 74 |
+
```
|
| 75 |
+
|
| 76 |
+
The two **sidecar CSVs** at the recorder layer (`build_to_inova_session.csv`, `sensors.csv`) are hand-annotated by a human, not generated. They're checked into the recorder repo and read by this dataset's ETL via the sibling-folder path.
|
| 77 |
+
|
| 78 |
+
## How the data is captured
|
| 79 |
+
|
| 80 |
+
### The repos
|
| 81 |
+
|
| 82 |
+
Two GitHub repos own the upstream data path. Both belong to the same user; neither is a fork.
|
| 83 |
+
|
| 84 |
+
| Repo | URL | What it is |
|
| 85 |
+
|---|---|---|
|
| 86 |
+
| Recorder | https://github.com/ppak10/Agentic-Additive-Manufacturing-Process-Optimization | TypeScript/Fastify server + dockerized Postgres + Python tooling. Owns the live DB, the image files, and `scripts/export.py`. This dataset's ETL depends on its `data/exports/` tree. |
|
| 87 |
+
| Inova plugin | https://github.com/ppak10/Inova-API-Plugin | C# plugin loaded by the SLS4All firmware on the printer. Exposes the REST + WebSocket endpoints the recorder polls. **Authoritative source for sensor semantics** (`InovaApiPlugin.cs`). |
|
| 88 |
+
|
| 89 |
+
The recorder also pins **`sls4all/SLS4All.Compact`** as a submodule at tag `public/1.195.0` — that's the SLS4All firmware itself, kept as a read-only vendor reference. Don't touch it; it's there so the plugin can build against a known firmware ABI.
|
| 90 |
+
|
| 91 |
+
Submodule layout inside the recorder repo:
|
| 92 |
+
```
|
| 93 |
+
sls4all/
|
| 94 |
+
Inova-API-Plugin/ # the C# plugin (our code; editable)
|
| 95 |
+
SLS4All.Compact/ # firmware (vendor; pinned)
|
| 96 |
+
datasets/
|
| 97 |
+
Agentic-SLS/ # legacy submodule, predates the HF dataset layout
|
| 98 |
+
```
|
| 99 |
+
|
| 100 |
+
### How the recorder runs
|
| 101 |
+
|
| 102 |
+
The recorder is a single Fastify Node process plus a Postgres container. `server/src/index.ts` starts the HTTP API and **five in-process recorder workers** in parallel:
|
| 103 |
+
|
| 104 |
+
| Worker | File | What it does |
|
| 105 |
+
|---|---|---|
|
| 106 |
+
| `startTelemetryRecorder` | `server/src/recorder/telemetry.ts` | Subscribes to plugin WS `/state/stream` at `TELEMETRY_HZ`. Calls `expand()` on each frame, batches ~100 rows / 200 ms, writes into `telemetry` table. Source of truth for ~64 sensor columns per tick. |
|
| 107 |
+
| `startCameraRecorder` | `server/src/recorder/camera.ts` | Polls firmware HTTP endpoints at `CAMERA_HZ` for chamber and galvo frames. Writes JPG/PNG bytes to `data/frames/{build_id}/{ts_ms}_{kind}.{ext}` and a row to the `frames` table. |
|
| 108 |
+
| `startBedMatrixRecorder` | `server/src/recorder/bedmatrix.ts` | Polls thermal IR matrix at `THERMAL_HZ`. Writes GIFs (often animated) to disk and frame rows. |
|
| 109 |
+
| `startPositionStreamRecorder` | `server/src/recorder/positionStream.ts` | Subscribes to plugin WS `/movement/position/stream` (~1 kHz native, event-driven). Writes to `position_hf` only on motion. Sparse during heating, bursts during raster. |
|
| 110 |
+
| `startPlotterStreamRecorder` | `server/src/recorder/plotterStream.ts` | Subscribes to plugin WS `/plotter/commands/stream`. Writes one row per CodeCommand to `plotter_commands`. Newer than the historical builds — 0 rows currently. |
|
| 111 |
+
| `startJobDetector` | `server/src/recorder/job.ts` | Watches firmware state to open/close `builds` rows (sets `started_at`, `phase`, `ended_at`). One build is created per print run. |
|
| 112 |
+
|
| 113 |
+
All workers also write structured rows into `events` on state transitions.
|
| 114 |
+
|
| 115 |
+
### Runtime configuration
|
| 116 |
+
|
| 117 |
+
The recorder reads `.env` at startup (`.env.example` in the repo shows the keys, redacted). Key settings:
|
| 118 |
+
|
| 119 |
+
```ini
|
| 120 |
+
INOVA_API_BASE_URL=http://192.168.1.146:5001 # plugin REST/WS port
|
| 121 |
+
INOVA_FIRMWARE_BASE_URL=http://192.168.1.146 # firmware HTTP port 80
|
| 122 |
+
DATABASE_URL=postgres://inova:inova@localhost:5432/inova
|
| 123 |
+
TELEMETRY_HZ=10
|
| 124 |
+
CAMERA_HZ=5
|
| 125 |
+
THERMAL_HZ=2
|
| 126 |
+
FRAMES_DIR=../data/frames
|
| 127 |
+
```
|
| 128 |
+
|
| 129 |
+
The `INOVA_API_BASE_URL` is the on-network address of the **physical printer** running the firmware + plugin. If you're working remotely, the recorder can't talk to it; rely on the already-exported flat files in `data/exports/` instead. The Postgres container (`agentic-sls-postgres`) runs locally on the same host as the Fastify server, persisted to `data/postgres/` (root-owned, accessible only inside the container).
|
| 130 |
+
|
| 131 |
+
### How to bring it up from scratch
|
| 132 |
+
|
| 133 |
+
Only needed if you're rebuilding the recorder side — this dataset's ETL doesn't require any of it once `data/exports/` exists.
|
| 134 |
+
|
| 135 |
+
```sh
|
| 136 |
+
# In the recorder repo:
|
| 137 |
+
git clone --recurse-submodules git@github.com:ppak10/Agentic-Additive-Manufacturing-Process-Optimization.git
|
| 138 |
+
cp .env.example .env # then fill in printer IP
|
| 139 |
+
docker compose up -d # brings up Postgres
|
| 140 |
+
cd server && npm install # then run the Fastify server in dev/prod mode
|
| 141 |
+
```
|
| 142 |
+
|
| 143 |
+
The recorder writes continuously while a build is live. When you want flat files, run `python scripts/export.py` in the recorder repo — that produces the JSONL/parquet/CSV tree under `data/exports/` that this dataset's ETL consumes.
|
| 144 |
+
|
| 145 |
+
## Ecosystem (concrete paths)
|
| 146 |
+
|
| 147 |
+
Assuming you're working on this machine (`/mnt/storage2`):
|
| 148 |
+
|
| 149 |
+
| Repo | Filesystem path | Role |
|
| 150 |
+
|---|---|---|
|
| 151 |
+
| This dataset | `/mnt/storage2/HuggingFace/Datasets/Inova-Mk1-Telemetry/` | Where you are now. ETL reads sibling exports; writes `data/ticks/`. |
|
| 152 |
+
| Recorder repo | `/mnt/storage2/GitHub/Agentic-Additive-Manufacturing-Process-Optimization/` | Owns the live DB + export script. **The only sibling repo this dataset depends on.** This ETL reads `data/exports/`. |
|
| 153 |
+
| Sibling Database dataset | `/mnt/storage2/HuggingFace/Datasets/Inova-Mk1-Database/` | Informational only — *not* a dependency. Consumers can join `print_profile_name` against `source/PrintProfiles/*.json` themselves to recover the UUID; see "Joining back to Inova-Mk1-Database" in the README. |
|
| 154 |
+
| Sibling ASTM dataset | `/mnt/storage2/HuggingFace/Datasets/Inova-Mk1-ASTM/` | Independent leaf; no direct dependency. |
|
| 155 |
+
|
| 156 |
+
`scripts/_lib.py` resolves the recorder path relative to its own location: `ROOT` is the repo root (`_lib.py` → two `.parent`s up), and then:
|
| 157 |
+
- **Recorder** (`AGENTIC_ROOT`): `ROOT.parent.parent.parent / "GitHub" / "Agentic-Additive-Manufacturing-Process-Optimization"` — three climbs from `ROOT` to reach `/mnt/storage2`, then descend.
|
| 158 |
+
|
| 159 |
+
If you move the repo out of `/mnt/storage2/HuggingFace/Datasets/`, that climb needs updating.
|
| 160 |
+
|
| 161 |
+
**Authoritative references** for sensor semantics in the recorder repo:
|
| 162 |
+
- `sls4all/Inova-API-Plugin/InovaApiPlugin.cs` — `/state/snapshot` returns `{ position, lights, power, temperature }`. Lines 85–213 are the endpoint definitions; lines 495–507 are the `CaptureSnapshot` shape.
|
| 163 |
+
- `server/src/recorder/telemetry.ts` lines 25–50 — `expand()` is the only place that defines which `(sensor_id, kind)` rows get written. Every row in the `telemetry` table is one entry from this function. Read this file before assuming what a column means.
|
| 164 |
+
- `server/src/db/schema.sql` — canonical DDL for all 6 Postgres tables.
|
| 165 |
+
|
| 166 |
+
## Running the ETL
|
| 167 |
+
|
| 168 |
+
### Prerequisites
|
| 169 |
+
|
| 170 |
+
1. Sibling recorder repo at the expected path with a populated `data/exports/` directory. If it doesn't exist or is stale, run `scripts/export.py` there first. The recorder DB has to be reachable (Docker container `agentic-sls-postgres`) for the exporter to work.
|
| 171 |
+
2. uv installed; `pyproject.toml` deps (`pyarrow`, `polars`) will be installed via `uv sync` or auto-resolved by `uv run`.
|
| 172 |
+
|
| 173 |
+
This dataset has **no other repo dependencies** at ETL time. In particular, `Inova-Mk1-Database` is not required — `print_profile_name` is preserved as a string and consumers can resolve the UUID themselves if they want.
|
| 174 |
+
|
| 175 |
+
### Commands
|
| 176 |
+
|
| 177 |
+
```sh
|
| 178 |
+
# All builds with telemetry (full rebuild — ~2 hours, ~30 GB output)
|
| 179 |
+
uv run scripts/ticks/01_extract.py
|
| 180 |
+
|
| 181 |
+
# One or more specific builds (smoke test or incremental)
|
| 182 |
+
uv run scripts/ticks/01_extract.py 13 # ~2 min for build 13
|
| 183 |
+
uv run scripts/ticks/01_extract.py 13 26 28 # build 26 is ~30 min on its own
|
| 184 |
+
```
|
| 185 |
+
|
| 186 |
+
The script **always overwrites** existing `data/ticks/{build_id:03d}.parquet` files — there's no skip-if-exists check. If you want incremental behavior, pass only the build IDs you want to refresh.
|
| 187 |
+
|
| 188 |
+
### Expected wall-time and output sizes
|
| 189 |
+
|
| 190 |
+
From the last full run (10 builds, 1.01 M ticks total, completed 2026-06-24):
|
| 191 |
+
|
| 192 |
+
| build_id | ticks | size | notes |
|
| 193 |
+
|---:|---:|---:|---|
|
| 194 |
+
| 1 | 102,805 | 2.9 GB | "Hex Coasters" Init/BedPrep phase |
|
| 195 |
+
| 2 | 68 | 2.4 MB | partial — recorder joined mid-run |
|
| 196 |
+
| 12 | 201,660 | 4.6 GB | "Hex Coasters" Layers phase |
|
| 197 |
+
| 13 | 13,811 | 527 MB | "D790 + D638 + Benchy" Heating |
|
| 198 |
+
| 14 | 2 | 48 KB | failed heating attempt |
|
| 199 |
+
| 16 | 14 | 788 KB | failed heating attempt |
|
| 200 |
+
| 17 | 2 | 32 KB | failed heating attempt |
|
| 201 |
+
| 25 | 24 | 1.2 MB | failed heating attempt |
|
| 202 |
+
| 26 | 355,580 | 11 GB | longest run (9h54m) |
|
| 203 |
+
| 28 | 340,162 | 11 GB | 2026-06-07 print, 9h28m |
|
| 204 |
+
| **total** | **1.01 M** | **30 GB** | wall time: **2h 7m** |
|
| 205 |
+
|
| 206 |
+
Wall time is dominated by IO — each non-null `frame_*` column triggers a disk read from `data/frames/{build_id}/{ts_ms}_{kind}.{ext}` in the recorder repo. CPU/RAM are unremarkable.
|
| 207 |
+
|
| 208 |
+
### Verifying output
|
| 209 |
+
|
| 210 |
+
```sh
|
| 211 |
+
# Schema sanity
|
| 212 |
+
uv run python -c "
|
| 213 |
+
import pyarrow.parquet as pq
|
| 214 |
+
pf = pq.ParquetFile('data/ticks/026.parquet')
|
| 215 |
+
print(f'rows: {pf.metadata.num_rows:,}, row_groups: {pf.metadata.num_row_groups}')
|
| 216 |
+
for f in pf.schema_arrow:
|
| 217 |
+
if f.name.startswith('frame_'):
|
| 218 |
+
print(f' {f.name}: {f.type}')
|
| 219 |
+
"
|
| 220 |
+
# Expected: struct<bytes: binary, path: string> on all three frame_* columns.
|
| 221 |
+
|
| 222 |
+
# Decode one embedded image to confirm bytes are valid
|
| 223 |
+
uv run --with pillow python -c "
|
| 224 |
+
import polars as pl, io
|
| 225 |
+
from PIL import Image
|
| 226 |
+
df = pl.read_parquet('data/ticks/026.parquet', columns=['frame_chamber'])
|
| 227 |
+
row = df.filter(pl.col('frame_chamber').is_not_null()).head(1).row(0, named=True)
|
| 228 |
+
img = Image.open(io.BytesIO(row['frame_chamber']['bytes']))
|
| 229 |
+
print(img.format, img.size)
|
| 230 |
+
"
|
| 231 |
+
# Expected: JPEG (600, 650) or similar.
|
| 232 |
+
|
| 233 |
+
# Frame-attached rates per build
|
| 234 |
+
uv run python -c "
|
| 235 |
+
import polars as pl
|
| 236 |
+
df = pl.read_parquet('data/ticks/026.parquet',
|
| 237 |
+
columns=['frame_chamber','frame_galvo','frame_thermal'])
|
| 238 |
+
for c in df.columns:
|
| 239 |
+
print(f'{c}: {df[c].is_not_null().sum():,} / {df.height:,}')
|
| 240 |
+
"
|
| 241 |
+
# Expected: chamber ~36%, galvo ~37%, thermal ~16%.
|
| 242 |
+
```
|
| 243 |
+
|
| 244 |
+
## Where humans must intervene
|
| 245 |
+
|
| 246 |
+
Two pieces of context can't be derived; they live in the recorder repo and someone has to edit them by hand:
|
| 247 |
+
|
| 248 |
+
- `Agentic-…-Optimization/data/exports/build_to_inova_session.csv` — maps `build_id` → `inova_session_id UUID`. Until filled in, `inova_session_id` is null in every row here and consumers fall back to name-based joining via `print_profile_name`. Recommended cadence: edit when you add a new build that maps to a known `PrintSession`.
|
| 249 |
+
- `Agentic-…-Optimization/data/exports/sensors.csv` — `(sensor_id, kind, unit, description)`. The `unit` and `description` columns are blank by default. This dataset's card cites those values when describing column meanings. Until filled in, we hardcode firmware conventions (temps °C, power W, position microns) in this CLAUDE.md and in the README.
|
| 250 |
+
|
| 251 |
+
Neither blocks the ETL. They improve dataset metadata.
|
| 252 |
|
| 253 |
## Architectural decisions
|
| 254 |
|
| 255 |
- **One config, not four.** Early iteration had separate `builds`, `telemetry`, `position_hf`, and `frames` configs. Replaced with a single `ticks` config because ML consumers almost always want the joined view: state + frame + position at one moment in time. The four-silo version pushed the join cost onto every downstream user.
|
| 256 |
+
- **Anchor on the 10 Hz telemetry tick, not strict outer join.** The recorder's `/state/snapshot` poll fires at 10 Hz and `expand()` emits a deterministic ~64-row burst into the `telemetry` table — so a tick already represents a full state snapshot. Anchoring on ticks gives every row densely populated columns; frames and `position_hf` attach to the tick they're closest to. A strict outer join across all stream timestamps gave ~3M mostly-sparse rows for less ML value.
|
| 257 |
- **Wide format, dotted column names matching upstream.** Sensor columns are named exactly `{sensor_id}.{kind}` — e.g. `powderBed.temp.current`, `laser.power`, `positions.position.x`. This matches the upstream `sensors.csv` glossary 1:1 so unit annotations land where consumers will look. ~64 sensor columns + build context + frame paths + position burst = 78 columns total.
|
| 258 |
+
- **Frames attach by nearest-before-tick within a 100 ms window** and **the image bytes are embedded inline**. Frame timestamps don't align with telemetry ticks (chamber 5 Hz, thermal 2 Hz, galvo varies). For each tick we look back 100 ms and grab the most recent frame of each kind; nulls when nothing landed. Each `frame_*` column is a struct of `{bytes: binary, path: string}` matching HF's `Image` feature wire format — declared as `dtype: image` in the README so `datasets` decodes to `PIL.Image` on access. The `path` field inside the struct is the original relative filename (`"26/1780265532038_chamber.jpg"`) preserved for traceability back to the recorder repo.
|
| 259 |
+
- **Null is preserved when no frame attaches** — we explicitly did **not** forward-fill the latest captured frame. Reason: shuffled training with forward-fill would pair the same image with widely varying telemetry rows (e.g. one chamber jpg stamped onto thousands of consecutive ticks during a 30-min heating phase), teaching the model spurious associations. Filtering null-frame rows at consume time is a one-liner; recovering "this image is stale" from a forward-filled column is impossible.
|
| 260 |
- **`position_hf` preserved as per-tick bursts.** The firmware emits `PositionChangedHighFrequency` event-driven, not at fixed 1 kHz — so it bursts during motion and is empty during heating. We keep the full burst inside each tick's window as `position_hf_burst: list<struct<ts_offset_ms, x, y, z1, z2, r, has_homed>>`. Empty list when no motion. Lossless within the 100 ms window; the raw `position_hf/{build_id}.parquet` upstream is the fallback if you need motion data between ticks.
|
| 261 |
+
- **Build context denormalized into every row.** `build_id`, `job_name`, `started_at`, `ended_at`, `phase`, `print_profile_name`, `inova_session_id` repeat on every row. Parquet dictionary encoding makes this essentially free (~1 byte per row regardless of value).
|
| 262 |
+
- **`print_profile_name` only, no `print_profile_id`.** The recorder's `events.jsonl` carries the *name* a build started with; the UUID lives in `Inova-Mk1-Database/source/PrintProfiles/*.json`. Earlier versions of the ETL cached the name→UUID lookup into a `print_profile_id` column, but doing that turned `Inova-Mk1-Database` into an ETL-time dependency for a one-line consumer join. We dropped the column so this dataset stands on its own with only the recorder repo. Consumers who want the UUID can join externally — see the README section "Joining back to Inova-Mk1-Database."
|
| 263 |
+
- **One parquet file per build.** `data/ticks/{build_id:03d}.parquet` (zero-padded to 3 digits so a lexical `ls` sorts numerically and the layout caps cleanly at 999 builds). HF globs `data/ticks/*.parquet` to load the full dataset. Builds without telemetry produce no file; consumers should expect missing build IDs.
|
| 264 |
- **Polars for the pivot + asof joins.** ~22 M telemetry rows (build 26) pivot to ~355 K ticks in seconds. Polars' `pivot` and `join_asof(tolerance=100ms)` do the heavy lifting; the position_hf burst is a manual sorted-merge.
|
| 265 |
+
- **Streaming chunked write for the embed step.** With image bytes inlined, build 26 alone is ~11 GB on disk. The writer is a `pyarrow.parquet.ParquetWriter` fed `CHUNK_ROWS=2000`-row slices; each slice does its own image-bytes read, so peak working set per chunk is bounded (~500 MB even for thermal-heavy builds). Polars handles the upstream pivot/join; pyarrow handles the streaming output.
|
| 266 |
|
| 267 |
## Directory layout
|
| 268 |
|
| 269 |
```
|
| 270 |
.python-version # 3.13
|
| 271 |
pyproject.toml # pyarrow, polars
|
| 272 |
+
.gitattributes # *.parquet → LFS
|
| 273 |
|
| 274 |
scripts/
|
| 275 |
_lib.py # sibling-repo paths, FK resolver
|
| 276 |
+
ticks/01_extract.py # the single ETL — wide-pivot + asof + burst + embed
|
| 277 |
|
| 278 |
data/
|
| 279 |
+
ticks/{build_id:03d}.parquet # LFS; e.g. 001.parquet, 026.parquet
|
| 280 |
```
|
| 281 |
|
| 282 |
There is no `source/` (raw data lives in the sibling recorder repo's `data/exports/`).
|
| 283 |
|
| 284 |
+
`scripts/ticks/01_extract.py` is organized as:
|
| 285 |
+
1. `load_builds_index()` / `load_frames_for_build()` — load upstream JSONL
|
| 286 |
+
2. `pivot_telemetry()` — long-to-wide on `(sensor_id, kind)`
|
| 287 |
+
3. `attach_frames()` — three `join_asof(strategy='backward', tolerance=100ms)` calls
|
| 288 |
+
4. `attach_position_hf()` — manual sorted-merge to build the burst lists
|
| 289 |
+
5. `denormalize_build()` — `pl.lit()` columns for build context
|
| 290 |
+
6. `_embed_frame_column()` / `_embed_chunk()` / `process_build()` — chunked write with pyarrow `ParquetWriter`
|
| 291 |
+
7. `main()` — iterate target build IDs, call `process_build()` per build
|
| 292 |
+
|
| 293 |
## Row shape
|
| 294 |
|
| 295 |
```python
|
|
|
|
| 301 |
"job_name": "D790 and D638 and Benchy 2026_06_02",
|
| 302 |
"started_at": "...", "ended_at": "...",
|
| 303 |
"phase": "Heating",
|
|
|
|
| 304 |
"print_profile_name": "2026_05_30 20mJ/mm Formlabs PA12 GF",
|
| 305 |
"inova_session_id": None, # filled when upstream CSV is curated
|
| 306 |
|
|
|
|
| 326 |
"quadrant1.temp.current": ..., "surfaceAvg.temp.average": ...,
|
| 327 |
...
|
| 328 |
|
| 329 |
+
# Frames — embedded HF Image structs (PIL.Image on load) or None
|
| 330 |
+
"frame_chamber": {"bytes": b"\xff\xd8...", "path": "26/1780265532038_chamber.jpg"},
|
| 331 |
+
"frame_galvo": {"bytes": b"\x89PNG...", "path": "26/1780265532040_galvo.png"},
|
| 332 |
"frame_thermal": None, # nothing in window
|
| 333 |
|
| 334 |
# 1 kHz position-stream burst within (tick_ts - 100ms, tick_ts]
|
|
|
|
| 339 |
}
|
| 340 |
```
|
| 341 |
|
| 342 |
+
## Sensor groups (from `expand()` in the recorder)
|
| 343 |
+
|
| 344 |
+
The ~64 sensor columns break down by group. All four come from a single `/state/snapshot` GET, so they share the tick timestamp exactly:
|
| 345 |
+
|
| 346 |
+
| Group | Columns | Source |
|
| 347 |
+
|---|---|---|
|
| 348 |
+
| Position (10 Hz) | `positions.position.{x,y,z1,z2,r}` — 5 cols | `s.position[k]` for k in (x,y,z1,z2,r). Microns, firmware native. |
|
| 349 |
+
| Lights | `lights.lights.{enabled,count}` — 2 cols | `s.lights.{isEnabled,lightCount}`. `enabled` is 0/1. |
|
| 350 |
+
| Power (W) | `{e.id}.power` for each `s.power.entries` — typically `{laser,fanGalvo,buzzer,laserSafety,io-en,wd-en,wd-in}` — 7 cols, plus `powerman.power.{current,required,max}` — 3 cols | `s.power.entries[].id` is the per-device draw; `powerman.*` is the manager state. |
|
| 351 |
+
| Temperature (°C) | `{e.id}.temp.{current,average,target}` for each `s.temperature.entries` — typically `{powderBed, printBed, powderChamber1..4, printChamber1..4, quadrant1..4, surface, surfaceAvg, surfaceMin, surfaceMax, testTemp1}` — ~51 cols total | `e.targetTemperature` is omitted when null, so `temp.target` columns can be null even when `current`/`average` are populated. |
|
| 352 |
+
|
| 353 |
+
If `expand()` in the recorder ever changes, all of those column names change with it — no normalization here.
|
| 354 |
+
|
| 355 |
## Important gotchas
|
| 356 |
|
| 357 |
+
- **`frame_*` bytes are embedded; `path` inside the struct is recorder-relative.** Each non-null frame column carries the actual image bytes plus the original relative path (`"26/1780265532038_chamber.jpg"`, meaning `Agentic-Additive-Manufacturing-Process-Optimization/data/frames/...`). The path is for traceability only — consumers don't need the recorder repo to access the image. The unattached frames (~half of the 1.27 M captured) still live only in the recorder repo; this dataset only carries the per-tick attached subset.
|
| 358 |
- **`positions.position.*` columns are 10 Hz**, not 1 kHz. They come from the snapshot's `position` field. For 1 kHz fidelity during motion, read `position_hf_burst`.
|
| 359 |
+
- **`inova_session_id` is always null** until someone curates `build_to_inova_session.csv` in the recorder repo. Consumers who need an entity-graph link can fall back to joining on `print_profile_name` against `Inova-Mk1-Database` meanwhile.
|
| 360 |
- **`build_id` is a Postgres BIGSERIAL**, not a UUID. One Database `PrintSession` may have many `build_id`s (one per recorder restart / attempt). That's why session-id mapping must be hand-authored.
|
| 361 |
- **Sensor units are firmware-convention, not labeled in this dataset.** `*.temp.*` are °C, `*.power*` are W, `positions.position.*` are **microns** (firmware native; divide by 1000 for mm). Authoritative annotations live in the upstream `sensors.csv` glossary; when it's filled in, the dataset card will be updated.
|
| 362 |
- **Builds without `telemetry/{build_id}.parquet` produce no file here.** `data/ticks/` will have gaps for failed-heating runs (typically 12–38 s with zero recorded telemetry).
|
| 363 |
- **The 100 ms window is the recorder's tick interval.** Frame attachment is "the most recent frame within the prior tick interval"; this is a design choice (could be wider or interpolated). If a frame is more than 100 ms stale at tick time, it's null even if it's the closest existing frame. Consider widening the window if frame_kind null rates feel too high.
|
| 364 |
+
- **The ETL always overwrites.** No skip-if-exists. If you only want incremental refresh, pass specific build IDs on the command line.
|
| 365 |
+
- **`events` and `plotter_commands` upstream tables are not exposed here.** `events` (78 rows) is sparse; `plotter_commands` (0 rows) postdates the historical builds. Both stay upstream-only for v1.
|
| 366 |
+
- **The recorder repo is a moving target.** It's actively developed; new sensors, new build records, schema changes can appear. Diff `server/src/db/schema.sql` and `server/src/recorder/telemetry.ts` against your last known state before relying on column names.
|
| 367 |
|
| 368 |
## Current state
|
| 369 |
|
| 370 |
+
- `ticks` config: implemented with embedded frame bytes. 10 parquet files, 30 GB total, 1.01 M ticks across builds 1, 2, 12, 13, 14, 16, 17, 25, 26, 28.
|
| 371 |
+
- `print_profile_name` is preserved on every row; the `print_profile_id` UUID is *not* materialized here (see the architectural decision above). The existing parquet files on disk were written before this change and still contain a `print_profile_id` column — they'll lose it on the next full regen.
|
| 372 |
+
- `events` and `plotter_commands` not surfaced as configs.
|
| 373 |
+
- **Forward-fill semantics deferred.** Current attach is "fresh frame within 100 ms of tick or null." Carrying the latest captured frame forward to fill null rows is left to consumers (one-line groupby + ffill); baking it into the dataset would destroy the fresh-vs-stale signal that's the whole point of keeping nulls.
|
| 374 |
+
- Repo is not yet committed; data/ticks/ files are unstaged. LFS rules are configured but no LFS objects pushed yet.
|
| 375 |
|
| 376 |
## Adding a build — recipe
|
| 377 |
|
| 378 |
1. New build runs in the recorder, produces telemetry / frames / position_hf in Postgres + on disk.
|
| 379 |
+
2. Run `scripts/export.py` in the recorder repo to refresh `data/exports/`. Pass `--builds N` to scope to one build if you don't want to re-export everything.
|
| 380 |
+
3. (Optional, but recommended) edit `Agentic-…-Optimization/data/exports/build_to_inova_session.csv` to fill in the `inova_session_id` UUID for the new build, then commit there.
|
| 381 |
+
4. Run `uv run scripts/ticks/01_extract.py N` here to write `data/ticks/NNN.parquet` (zero-padded — e.g. build 7 → `007.parquet`, build 142 → `142.parquet`).
|
| 382 |
+
5. `git add data/ticks/NNN.parquet` (LFS) and commit.
|
| 383 |
|
| 384 |
+
## Regenerate everything
|
| 385 |
|
| 386 |
```sh
|
| 387 |
+
rm -f data/ticks/*.parquet
|
| 388 |
uv run scripts/ticks/01_extract.py
|
| 389 |
```
|
| 390 |
+
|
| 391 |
+
Takes ~2 hours, produces ~30 GB. The IO is the bottleneck; the Polars pivot and asof joins are fast.
|
README.md
CHANGED
|
@@ -13,22 +13,34 @@ configs:
|
|
| 13 |
- split: train
|
| 14 |
path: data/ticks/*.parquet
|
| 15 |
default: true
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
---
|
| 17 |
|
| 18 |
# Inova-Mk1-Telemetry
|
| 19 |
|
| 20 |
Time-aligned printer-state recordings from Inova Mk1 SLS print runs. One row per 10 Hz **tick** of the recorder's `/state/snapshot` poll, with the full sensor state (~64 columns: temperatures, position, power, lights) on every row, the nearest camera frame paths attached when one fell in the prior 100 ms window, and any 1 kHz position-stream samples from that window collected as a nested list.
|
| 21 |
|
| 22 |
-
Builds are denormalized into every row, so each parquet file is self-sufficient for ML — no joins needed for build context.
|
| 23 |
|
| 24 |
```python
|
| 25 |
from datasets import load_dataset
|
| 26 |
ticks = load_dataset("ppak10/Inova-Mk1-Telemetry", split="train")
|
| 27 |
-
|
| 28 |
-
#
|
| 29 |
-
#
|
|
|
|
|
|
|
| 30 |
```
|
| 31 |
|
|
|
|
|
|
|
| 32 |
---
|
| 33 |
|
| 34 |
## Row shape
|
|
@@ -37,19 +49,19 @@ Each row is one moment in time (a single 10 Hz tick). 80+ columns:
|
|
| 37 |
|
| 38 |
| Group | Columns | Notes |
|
| 39 |
|---|---|---|
|
| 40 |
-
| **Build context** (denormalized) | `build_id`, `job_name`, `started_at`, `ended_at`, `phase`, `
|
| 41 |
| **Tick timestamp** | `ts` (`timestamp[us, UTC]`) | The `respondedAt` field on the `/state/snapshot` frame. |
|
| 42 |
| **Position (10 Hz)** | `positions.position.{x,y,z1,z2,r}` | Stage position at the tick, **microns** (firmware native; e.g. `z1 = 47272.79` is 47.27 mm). Always present. |
|
| 43 |
| **Lights** | `lights.lights.{enabled,count}` | |
|
| 44 |
| **Power (W)** | `{laser,fanGalvo,buzzer,laserSafety,io-en,wd-en,wd-in}.power`, `powerman.power.{current,required,max}` | Per-component power draw and the overall manager state. |
|
| 45 |
| **Temperature (°C)** | `{powderBed,printBed}.temp.{current,average,target}`, `{powderChamber1..4,printChamber1..4}.temp.{current,average,target}`, `{quadrant1..4,surface,surfaceAvg,surfaceMin,surfaceMax,testTemp1}.temp.{current,average}` | ~51 columns. All firmware temperatures in °C. |
|
| 46 |
-
| **Frame
|
| 47 |
| **Position burst** | `position_hf_burst` | A `list<struct<ts_offset_ms, x, y, z1, z2, r, has_homed>>`. Captures any 1 kHz position-stream events that fell in `(tick_ts - 100 ms, tick_ts]`. Empty list when no motion was happening. |
|
| 48 |
|
| 49 |
## Files
|
| 50 |
|
| 51 |
```
|
| 52 |
-
data/ticks/{build_id}.parquet
|
| 53 |
```
|
| 54 |
|
| 55 |
10 builds had recorded telemetry; very-short failed-heating builds (~12–38 s, no rows) produce no file. The HF glob `data/ticks/*.parquet` loads everything across builds.
|
|
@@ -64,9 +76,25 @@ This dataset is **tick-anchored**, not strict-outer-join. Compared to the upstre
|
|
| 64 |
|
| 65 |
## Joining back to Inova-Mk1-Database
|
| 66 |
|
| 67 |
-
Each row carries `
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 68 |
|
| 69 |
-
A planned authoritative `inova_session_id UUID`
|
| 70 |
|
| 71 |
## Upstream
|
| 72 |
|
|
|
|
| 13 |
- split: train
|
| 14 |
path: data/ticks/*.parquet
|
| 15 |
default: true
|
| 16 |
+
dataset_info:
|
| 17 |
+
features:
|
| 18 |
+
- name: frame_chamber
|
| 19 |
+
dtype: image
|
| 20 |
+
- name: frame_galvo
|
| 21 |
+
dtype: image
|
| 22 |
+
- name: frame_thermal
|
| 23 |
+
dtype: image
|
| 24 |
---
|
| 25 |
|
| 26 |
# Inova-Mk1-Telemetry
|
| 27 |
|
| 28 |
Time-aligned printer-state recordings from Inova Mk1 SLS print runs. One row per 10 Hz **tick** of the recorder's `/state/snapshot` poll, with the full sensor state (~64 columns: temperatures, position, power, lights) on every row, the nearest camera frame paths attached when one fell in the prior 100 ms window, and any 1 kHz position-stream samples from that window collected as a nested list.
|
| 29 |
|
| 30 |
+
Builds are denormalized into every row, so each parquet file is self-sufficient for ML — no joins needed for build context. The `print_profile_name` string the printer was running is preserved on every row; consumers who want the matching UUID from [`ppak10/Inova-Mk1-Database`](https://huggingface.co/datasets/ppak10/Inova-Mk1-Database) can resolve it themselves (one-liner shown below) — this dataset deliberately doesn't bake that join in, so it has no cross-dataset dependency at load time.
|
| 31 |
|
| 32 |
```python
|
| 33 |
from datasets import load_dataset
|
| 34 |
ticks = load_dataset("ppak10/Inova-Mk1-Telemetry", split="train")
|
| 35 |
+
row = ticks[0]
|
| 36 |
+
# row["frame_chamber"] → PIL.Image.Image (or None)
|
| 37 |
+
# row["frame_thermal"] → PIL.Image.Image (or None)
|
| 38 |
+
# row["powderBed.temp.current"] → float (°C)
|
| 39 |
+
# row["position_hf_burst"] → list of {ts_offset_ms, x, y, z1, z2, r, has_homed}
|
| 40 |
```
|
| 41 |
|
| 42 |
+
The full image bytes ship inside each row — no separate frame download required. Filter to rows that have a particular frame kind with `ticks.filter(lambda r: r["frame_chamber"] is not None)`.
|
| 43 |
+
|
| 44 |
---
|
| 45 |
|
| 46 |
## Row shape
|
|
|
|
| 49 |
|
| 50 |
| Group | Columns | Notes |
|
| 51 |
|---|---|---|
|
| 52 |
+
| **Build context** (denormalized) | `build_id`, `job_name`, `started_at`, `ended_at`, `phase`, `print_profile_name`, `inova_session_id` | Same value on every row in a given parquet file. `inova_session_id` is null until the upstream `build_to_inova_session.csv` is filled in by hand. |
|
| 53 |
| **Tick timestamp** | `ts` (`timestamp[us, UTC]`) | The `respondedAt` field on the `/state/snapshot` frame. |
|
| 54 |
| **Position (10 Hz)** | `positions.position.{x,y,z1,z2,r}` | Stage position at the tick, **microns** (firmware native; e.g. `z1 = 47272.79` is 47.27 mm). Always present. |
|
| 55 |
| **Lights** | `lights.lights.{enabled,count}` | |
|
| 56 |
| **Power (W)** | `{laser,fanGalvo,buzzer,laserSafety,io-en,wd-en,wd-in}.power`, `powerman.power.{current,required,max}` | Per-component power draw and the overall manager state. |
|
| 57 |
| **Temperature (°C)** | `{powderBed,printBed}.temp.{current,average,target}`, `{powderChamber1..4,printChamber1..4}.temp.{current,average,target}`, `{quadrant1..4,surface,surfaceAvg,surfaceMin,surfaceMax,testTemp1}.temp.{current,average}` | ~51 columns. All firmware temperatures in °C. |
|
| 58 |
+
| **Frame images** | `frame_chamber`, `frame_galvo`, `frame_thermal` | Embedded image bytes per HF `Image` feature (struct of `{bytes, path}`). Null when no frame of that kind was captured in the 100 ms window before the tick. Loads as a `PIL.Image` via `datasets`. The `path` field inside the struct preserves the original filename for traceability. |
|
| 59 |
| **Position burst** | `position_hf_burst` | A `list<struct<ts_offset_ms, x, y, z1, z2, r, has_homed>>`. Captures any 1 kHz position-stream events that fell in `(tick_ts - 100 ms, tick_ts]`. Empty list when no motion was happening. |
|
| 60 |
|
| 61 |
## Files
|
| 62 |
|
| 63 |
```
|
| 64 |
+
data/ticks/{build_id:03d}.parquet # one file per build that had telemetry, zero-padded to 3 digits
|
| 65 |
```
|
| 66 |
|
| 67 |
10 builds had recorded telemetry; very-short failed-heating builds (~12–38 s, no rows) produce no file. The HF glob `data/ticks/*.parquet` loads everything across builds.
|
|
|
|
| 76 |
|
| 77 |
## Joining back to Inova-Mk1-Database
|
| 78 |
|
| 79 |
+
Each row carries `print_profile_name` — the string the printer was running when the build started, taken straight from the `build_start` event payload. To recover the matching `PrintProfile.Id` UUID, join against the [`ppak10/Inova-Mk1-Database`](https://huggingface.co/datasets/ppak10/Inova-Mk1-Database) `PrintProfiles` entities:
|
| 80 |
+
|
| 81 |
+
```python
|
| 82 |
+
import json
|
| 83 |
+
from pathlib import Path
|
| 84 |
+
|
| 85 |
+
# Wherever you've cloned/snapshotted Inova-Mk1-Database
|
| 86 |
+
profiles_dir = Path("Inova-Mk1-Database/source/PrintProfiles")
|
| 87 |
+
name_to_id = {
|
| 88 |
+
json.load(p.open())["Name"]: json.load(p.open())["Id"]
|
| 89 |
+
for p in profiles_dir.glob("*.json")
|
| 90 |
+
}
|
| 91 |
+
|
| 92 |
+
ticks = ticks.map(lambda r: {**r, "print_profile_id": name_to_id.get(r["print_profile_name"])})
|
| 93 |
+
```
|
| 94 |
+
|
| 95 |
+
If `Inova-Mk1-Database` hasn't yet added the profile the build used, the lookup returns null and `print_profile_name` is still preserved as a breadcrumb.
|
| 96 |
|
| 97 |
+
A planned authoritative `inova_session_id UUID` will replace the name-based fallback once the upstream `Agentic-Additive-Manufacturing-Process-Optimization/data/exports/build_to_inova_session.csv` has been filled in.
|
| 98 |
|
| 99 |
## Upstream
|
| 100 |
|
data/ticks/001.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f9218481ccf8ffa21212a3f2a1deb8400c2f1085fb2186c4fe2736a6040a916a
|
| 3 |
+
size 3070050859
|
data/ticks/{1.parquet → 002.parquet}
RENAMED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:56a9e8e9d263749b271bf8879737fa0aff761770ef4b6a854a3b1b594db4a474
|
| 3 |
+
size 2509572
|
data/ticks/012.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:251d4d7eda86545e5b4411a577d337e5c1da27047dfd7ce93627e9df765c08c1
|
| 3 |
+
size 4928937483
|
data/ticks/{14.parquet → 013.parquet}
RENAMED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:9698cf8e091ac9a13d7650995e4c9873c177d113cdc449949ac9a61a0b7c6753
|
| 3 |
+
size 551842848
|
data/ticks/{16.parquet → 014.parquet}
RENAMED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:0c47665b6d90171a760ca5148a8975e5a8dd817172ea79de0913cb2475527c2d
|
| 3 |
+
size 46213
|
data/ticks/{13.parquet → 016.parquet}
RENAMED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:907d7ac915aa74c995983b2b3292e95d3f507b9f7e047cf955fc62a707eecdab
|
| 3 |
+
size 806791
|
data/ticks/{17.parquet → 017.parquet}
RENAMED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c377a97cb77161b89c9a7ae3f9a3ecf20724cccf59b322ecda2eca5af2a5375d
|
| 3 |
+
size 29798
|
data/ticks/{12.parquet → 025.parquet}
RENAMED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:100ae729c896b36fd1e42bb444d17990a1c3c87ec5cad350a32c26dee94e2e00
|
| 3 |
+
size 1208604
|
data/ticks/026.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:73954fc364fbd9557376b26f16b7ec082d443cd626cf799256025edb1e39593c
|
| 3 |
+
size 11552611342
|
data/ticks/028.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:44f6df8e1e1f67a4007da0b83314faf60a758e4994ff48274204f9bbcfc48762
|
| 3 |
+
size 11436603086
|
data/ticks/2.parquet
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:2ec94cd8dd642f43f0e3eca4a194721393d7229bf904308b502e1c15ceefbc1b
|
| 3 |
-
size 35883
|
|
|
|
|
|
|
|
|
|
|
|
data/ticks/25.parquet
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:fc5d4c35f59fde32d1039cb9d313aaf4ef699c48accf0aaebdbde473723e3f15
|
| 3 |
-
size 34645
|
|
|
|
|
|
|
|
|
|
|
|
data/ticks/26.parquet
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:40287850b02a93ef479910b971921e005037b9fd2a9670c54b0bed17b1c29e2f
|
| 3 |
-
size 8324930
|
|
|
|
|
|
|
|
|
|
|
|
data/ticks/28.parquet
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:cc7c729b93bad808d56d682ba562d8b8dd10a349c7a046d85d50c57449d5521d
|
| 3 |
-
size 8017822
|
|
|
|
|
|
|
|
|
|
|
|
scripts/_lib.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
"""Shared paths and
|
| 2 |
|
| 3 |
The raw data lives in a sibling Git repo (the recorder). This dataset has no
|
| 4 |
local source files; every extract script reads from `EXPORTS_DIR` and writes
|
|
@@ -10,17 +10,13 @@ from pathlib import Path
|
|
| 10 |
ROOT = Path(__file__).parent.parent
|
| 11 |
DATA_DIR = ROOT / "data"
|
| 12 |
|
| 13 |
-
# Sibling-repo
|
| 14 |
# its raw inputs are the flat exports written by
|
| 15 |
# `Agentic-Additive-Manufacturing-Process-Optimization/scripts/export.py`.
|
| 16 |
# /mnt/storage2/HuggingFace/Datasets/Inova-Mk1-Telemetry → up three to /mnt/storage2.
|
| 17 |
AGENTIC_ROOT = ROOT.parent.parent.parent / "GitHub" / "Agentic-Additive-Manufacturing-Process-Optimization"
|
| 18 |
EXPORTS_DIR = AGENTIC_ROOT / "data" / "exports"
|
| 19 |
|
| 20 |
-
# Used only by the `builds` extract to resolve print_profile_id.
|
| 21 |
-
DATABASE_ROOT = ROOT.parent / "Inova-Mk1-Database"
|
| 22 |
-
DATABASE_PROFILES_DIR = DATABASE_ROOT / "source" / "PrintProfiles"
|
| 23 |
-
|
| 24 |
|
| 25 |
def iter_jsonl(path: Path):
|
| 26 |
"""Stream a JSONL file row-by-row. Skips blank lines."""
|
|
@@ -48,33 +44,3 @@ def load_build_to_profile_name() -> dict[int, str]:
|
|
| 48 |
if name:
|
| 49 |
out[ev["build_id"]] = name
|
| 50 |
return out
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
def load_profile_name_to_id() -> dict[str, str]:
|
| 54 |
-
"""Read Inova-Mk1-Database PrintProfile JSONs, return {Name: Id}.
|
| 55 |
-
|
| 56 |
-
Matches on the in-app `Name` field exactly (slashes preserved); the
|
| 57 |
-
sibling event payload uses the same form (e.g.
|
| 58 |
-
"2026_05_30 20mJ/mm Formlabs PA12 GF").
|
| 59 |
-
"""
|
| 60 |
-
out: dict[str, str] = {}
|
| 61 |
-
for p in DATABASE_PROFILES_DIR.glob("*.json"):
|
| 62 |
-
with p.open() as f:
|
| 63 |
-
blob = json.load(f)
|
| 64 |
-
if "Name" in blob and "Id" in blob:
|
| 65 |
-
out[blob["Name"]] = blob["Id"]
|
| 66 |
-
return out
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
def build_id_to_profile_id() -> dict[int, tuple[str | None, str | None]]:
|
| 70 |
-
"""Compose: {build_id: (print_profile_id, print_profile_name)}.
|
| 71 |
-
|
| 72 |
-
Unresolved profile_id (no Database match) is returned as None alongside
|
| 73 |
-
the still-useful name string.
|
| 74 |
-
"""
|
| 75 |
-
b2name = load_build_to_profile_name()
|
| 76 |
-
n2id = load_profile_name_to_id()
|
| 77 |
-
return {
|
| 78 |
-
bid: (n2id.get(name), name)
|
| 79 |
-
for bid, name in b2name.items()
|
| 80 |
-
}
|
|
|
|
| 1 |
+
"""Shared paths and helpers for the extract scripts.
|
| 2 |
|
| 3 |
The raw data lives in a sibling Git repo (the recorder). This dataset has no
|
| 4 |
local source files; every extract script reads from `EXPORTS_DIR` and writes
|
|
|
|
| 10 |
ROOT = Path(__file__).parent.parent
|
| 11 |
DATA_DIR = ROOT / "data"
|
| 12 |
|
| 13 |
+
# Sibling-repo location. The Telemetry dataset has no local source/ tree;
|
| 14 |
# its raw inputs are the flat exports written by
|
| 15 |
# `Agentic-Additive-Manufacturing-Process-Optimization/scripts/export.py`.
|
| 16 |
# /mnt/storage2/HuggingFace/Datasets/Inova-Mk1-Telemetry → up three to /mnt/storage2.
|
| 17 |
AGENTIC_ROOT = ROOT.parent.parent.parent / "GitHub" / "Agentic-Additive-Manufacturing-Process-Optimization"
|
| 18 |
EXPORTS_DIR = AGENTIC_ROOT / "data" / "exports"
|
| 19 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
def iter_jsonl(path: Path):
|
| 22 |
"""Stream a JSONL file row-by-row. Skips blank lines."""
|
|
|
|
| 44 |
if name:
|
| 45 |
out[ev["build_id"]] = name
|
| 46 |
return out
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
scripts/ticks/01_extract.py
CHANGED
|
@@ -4,10 +4,11 @@
|
|
| 4 |
Reads upstream flat exports from the sibling recorder repo:
|
| 5 |
builds.jsonl, telemetry/{build_id}.parquet, frames.jsonl, position_hf/{build_id}.parquet
|
| 6 |
|
| 7 |
-
For each build with telemetry, emits `data/ticks/{build_id}.parquet`
|
|
|
|
| 8 |
- One row per unique telemetry timestamp (the 10 Hz tick from /state/snapshot)
|
| 9 |
- Wide-format sensor columns named "{sensor_id}.{kind}" (~64 columns)
|
| 10 |
-
- Denormalized build context (build_id, job_name, ...,
|
| 11 |
- frame_chamber / frame_galvo / frame_thermal: nearest frame path in
|
| 12 |
[tick_ts - 100ms, tick_ts], null when no frame fell in that window
|
| 13 |
- position_hf_burst: list of {ts_offset_ms, x, y, z1, z2, r, has_homed}
|
|
@@ -22,14 +23,26 @@ from datetime import timedelta
|
|
| 22 |
from pathlib import Path
|
| 23 |
|
| 24 |
import polars as pl
|
|
|
|
|
|
|
| 25 |
|
| 26 |
sys.path.insert(0, str(Path(__file__).parent.parent))
|
| 27 |
-
from _lib import EXPORTS_DIR, DATA_DIR, iter_jsonl,
|
| 28 |
|
| 29 |
|
| 30 |
OUTPUT_DIR = DATA_DIR / "ticks"
|
| 31 |
WINDOW = timedelta(milliseconds=100) # 10 Hz tick interval
|
| 32 |
FRAME_KINDS = ("chamber", "galvo", "thermal")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
|
| 34 |
|
| 35 |
def load_builds_index() -> dict[int, dict]:
|
|
@@ -122,25 +135,71 @@ def attach_position_hf(wide: pl.DataFrame, build_id: int) -> pl.DataFrame:
|
|
| 122 |
|
| 123 |
|
| 124 |
def denormalize_build(wide: pl.DataFrame, build_row: dict,
|
| 125 |
-
|
| 126 |
"""Prepend build-context columns to every row. Cheap in parquet thanks to
|
| 127 |
dictionary encoding (every row in this file has the same value)."""
|
| 128 |
bid = build_row["id"]
|
| 129 |
-
profile_id, profile_name = profile_lookup.get(bid, (None, None))
|
| 130 |
return wide.with_columns(
|
| 131 |
pl.lit(bid).alias("build_id"),
|
| 132 |
pl.lit(build_row.get("job_name")).alias("job_name"),
|
| 133 |
pl.lit(build_row.get("started_at")).alias("started_at"),
|
| 134 |
pl.lit(build_row.get("ended_at")).alias("ended_at"),
|
| 135 |
pl.lit(build_row.get("phase")).alias("phase"),
|
| 136 |
-
pl.lit(
|
| 137 |
-
pl.lit(profile_name).alias("print_profile_name"),
|
| 138 |
pl.lit(None, dtype=pl.String).alias("inova_session_id"),
|
| 139 |
)
|
| 140 |
|
| 141 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 142 |
def process_build(build_id: int, builds_index: dict[int, dict],
|
| 143 |
-
|
| 144 |
tel_path = EXPORTS_DIR / "telemetry" / f"{build_id}.parquet"
|
| 145 |
if not tel_path.exists():
|
| 146 |
return None
|
|
@@ -153,25 +212,32 @@ def process_build(build_id: int, builds_index: dict[int, dict],
|
|
| 153 |
frames = load_frames_for_build(build_id)
|
| 154 |
wide = attach_frames(wide, frames)
|
| 155 |
wide = attach_position_hf(wide, build_id)
|
| 156 |
-
wide = denormalize_build(wide, builds_index[build_id],
|
| 157 |
|
| 158 |
# Put build context + ts first, then sensors, then frames + burst.
|
| 159 |
leading = ["build_id", "ts", "job_name", "started_at", "ended_at", "phase",
|
| 160 |
-
"
|
| 161 |
frame_cols = [f"frame_{k}" for k in FRAME_KINDS]
|
| 162 |
trailing = frame_cols + ["position_hf_burst"]
|
| 163 |
middle = [c for c in wide.columns if c not in leading and c not in trailing]
|
| 164 |
wide = wide.select(leading + middle + trailing)
|
| 165 |
|
| 166 |
-
|
| 167 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 168 |
return out_path
|
| 169 |
|
| 170 |
|
| 171 |
def main():
|
| 172 |
OUTPUT_DIR.mkdir(parents=True, exist_ok=True)
|
| 173 |
builds_index = load_builds_index()
|
| 174 |
-
|
| 175 |
|
| 176 |
args = [int(a) for a in sys.argv[1:]]
|
| 177 |
targets = args or sorted(int(p.stem) for p in (EXPORTS_DIR / "telemetry").glob("*.parquet"))
|
|
@@ -180,7 +246,7 @@ def main():
|
|
| 180 |
if bid not in builds_index:
|
| 181 |
print(f"build {bid}: not in builds.jsonl, skipping")
|
| 182 |
continue
|
| 183 |
-
out = process_build(bid, builds_index,
|
| 184 |
if out is None:
|
| 185 |
print(f"build {bid}: no telemetry parquet, skipping")
|
| 186 |
continue
|
|
|
|
| 4 |
Reads upstream flat exports from the sibling recorder repo:
|
| 5 |
builds.jsonl, telemetry/{build_id}.parquet, frames.jsonl, position_hf/{build_id}.parquet
|
| 6 |
|
| 7 |
+
For each build with telemetry, emits `data/ticks/{build_id:03d}.parquet`
|
| 8 |
+
(zero-padded so lexical sort matches numeric build_id):
|
| 9 |
- One row per unique telemetry timestamp (the 10 Hz tick from /state/snapshot)
|
| 10 |
- Wide-format sensor columns named "{sensor_id}.{kind}" (~64 columns)
|
| 11 |
+
- Denormalized build context (build_id, job_name, ..., print_profile_name)
|
| 12 |
- frame_chamber / frame_galvo / frame_thermal: nearest frame path in
|
| 13 |
[tick_ts - 100ms, tick_ts], null when no frame fell in that window
|
| 14 |
- position_hf_burst: list of {ts_offset_ms, x, y, z1, z2, r, has_homed}
|
|
|
|
| 23 |
from pathlib import Path
|
| 24 |
|
| 25 |
import polars as pl
|
| 26 |
+
import pyarrow as pa
|
| 27 |
+
import pyarrow.parquet as pq
|
| 28 |
|
| 29 |
sys.path.insert(0, str(Path(__file__).parent.parent))
|
| 30 |
+
from _lib import EXPORTS_DIR, DATA_DIR, iter_jsonl, load_build_to_profile_name
|
| 31 |
|
| 32 |
|
| 33 |
OUTPUT_DIR = DATA_DIR / "ticks"
|
| 34 |
WINDOW = timedelta(milliseconds=100) # 10 Hz tick interval
|
| 35 |
FRAME_KINDS = ("chamber", "galvo", "thermal")
|
| 36 |
+
# frame_* path strings are relative to this directory in the upstream recorder repo.
|
| 37 |
+
FRAMES_DIR = EXPORTS_DIR.parent / "frames"
|
| 38 |
+
# HF Image feature wire format. Both fields nullable; the struct itself is null when no frame.
|
| 39 |
+
IMAGE_STRUCT_TYPE = pa.struct([
|
| 40 |
+
pa.field("bytes", pa.binary()),
|
| 41 |
+
pa.field("path", pa.string()),
|
| 42 |
+
])
|
| 43 |
+
# Streaming chunk size in rows. Tuned so peak embedded payload per chunk stays
|
| 44 |
+
# under ~1 GB (thermal frames dominate at ~315 KB each).
|
| 45 |
+
CHUNK_ROWS = 2_000
|
| 46 |
|
| 47 |
|
| 48 |
def load_builds_index() -> dict[int, dict]:
|
|
|
|
| 135 |
|
| 136 |
|
| 137 |
def denormalize_build(wide: pl.DataFrame, build_row: dict,
|
| 138 |
+
profile_name_lookup: dict[int, str]) -> pl.DataFrame:
|
| 139 |
"""Prepend build-context columns to every row. Cheap in parquet thanks to
|
| 140 |
dictionary encoding (every row in this file has the same value)."""
|
| 141 |
bid = build_row["id"]
|
|
|
|
| 142 |
return wide.with_columns(
|
| 143 |
pl.lit(bid).alias("build_id"),
|
| 144 |
pl.lit(build_row.get("job_name")).alias("job_name"),
|
| 145 |
pl.lit(build_row.get("started_at")).alias("started_at"),
|
| 146 |
pl.lit(build_row.get("ended_at")).alias("ended_at"),
|
| 147 |
pl.lit(build_row.get("phase")).alias("phase"),
|
| 148 |
+
pl.lit(profile_name_lookup.get(bid)).alias("print_profile_name"),
|
|
|
|
| 149 |
pl.lit(None, dtype=pl.String).alias("inova_session_id"),
|
| 150 |
)
|
| 151 |
|
| 152 |
|
| 153 |
+
def _embed_frame_column(paths: list[str | None]) -> pa.Array:
|
| 154 |
+
"""For one chunk's worth of paths, read the image bytes from disk and
|
| 155 |
+
return a StructArray with HF Image shape. Missing path → null struct;
|
| 156 |
+
missing-on-disk → null struct (warn-and-continue)."""
|
| 157 |
+
raw_bytes: list[bytes | None] = []
|
| 158 |
+
for p in paths:
|
| 159 |
+
if p is None:
|
| 160 |
+
raw_bytes.append(None)
|
| 161 |
+
continue
|
| 162 |
+
try:
|
| 163 |
+
raw_bytes.append((FRAMES_DIR / p).read_bytes())
|
| 164 |
+
except FileNotFoundError:
|
| 165 |
+
raw_bytes.append(None)
|
| 166 |
+
bytes_array = pa.array(raw_bytes, type=pa.binary())
|
| 167 |
+
path_array = pa.array(paths, type=pa.string())
|
| 168 |
+
# Mask the whole struct as null when there is no path. Children stay null too.
|
| 169 |
+
mask = pa.array([p is None for p in paths], type=pa.bool_())
|
| 170 |
+
return pa.StructArray.from_arrays(
|
| 171 |
+
[bytes_array, path_array],
|
| 172 |
+
fields=[pa.field("bytes", pa.binary()), pa.field("path", pa.string())],
|
| 173 |
+
mask=mask,
|
| 174 |
+
)
|
| 175 |
+
|
| 176 |
+
|
| 177 |
+
def _make_output_schema(wide_arrow_schema: pa.Schema) -> pa.Schema:
|
| 178 |
+
"""Replace frame_* string fields with HF Image struct fields."""
|
| 179 |
+
new_fields = []
|
| 180 |
+
image_field_names = {f"frame_{k}" for k in FRAME_KINDS}
|
| 181 |
+
for field in wide_arrow_schema:
|
| 182 |
+
if field.name in image_field_names:
|
| 183 |
+
new_fields.append(pa.field(field.name, IMAGE_STRUCT_TYPE))
|
| 184 |
+
else:
|
| 185 |
+
new_fields.append(field)
|
| 186 |
+
return pa.schema(new_fields)
|
| 187 |
+
|
| 188 |
+
|
| 189 |
+
def _embed_chunk(chunk: pa.Table, output_schema: pa.Schema) -> pa.Table:
|
| 190 |
+
"""Swap frame_* string columns for embedded image structs in this chunk."""
|
| 191 |
+
arrays = []
|
| 192 |
+
for field in output_schema:
|
| 193 |
+
if field.name in {f"frame_{k}" for k in FRAME_KINDS}:
|
| 194 |
+
paths = chunk[field.name].to_pylist()
|
| 195 |
+
arrays.append(_embed_frame_column(paths))
|
| 196 |
+
else:
|
| 197 |
+
arrays.append(chunk[field.name].combine_chunks())
|
| 198 |
+
return pa.Table.from_arrays(arrays, schema=output_schema)
|
| 199 |
+
|
| 200 |
+
|
| 201 |
def process_build(build_id: int, builds_index: dict[int, dict],
|
| 202 |
+
profile_name_lookup: dict[int, str]) -> Path | None:
|
| 203 |
tel_path = EXPORTS_DIR / "telemetry" / f"{build_id}.parquet"
|
| 204 |
if not tel_path.exists():
|
| 205 |
return None
|
|
|
|
| 212 |
frames = load_frames_for_build(build_id)
|
| 213 |
wide = attach_frames(wide, frames)
|
| 214 |
wide = attach_position_hf(wide, build_id)
|
| 215 |
+
wide = denormalize_build(wide, builds_index[build_id], profile_name_lookup)
|
| 216 |
|
| 217 |
# Put build context + ts first, then sensors, then frames + burst.
|
| 218 |
leading = ["build_id", "ts", "job_name", "started_at", "ended_at", "phase",
|
| 219 |
+
"print_profile_name", "inova_session_id"]
|
| 220 |
frame_cols = [f"frame_{k}" for k in FRAME_KINDS]
|
| 221 |
trailing = frame_cols + ["position_hf_burst"]
|
| 222 |
middle = [c for c in wide.columns if c not in leading and c not in trailing]
|
| 223 |
wide = wide.select(leading + middle + trailing)
|
| 224 |
|
| 225 |
+
# Stream-write: build target schema (with image structs), then iterate
|
| 226 |
+
# CHUNK_ROWS-sized slices, embedding bytes per chunk to bound memory.
|
| 227 |
+
base_table = wide.to_arrow()
|
| 228 |
+
output_schema = _make_output_schema(base_table.schema)
|
| 229 |
+
out_path = OUTPUT_DIR / f"{build_id:03d}.parquet"
|
| 230 |
+
with pq.ParquetWriter(out_path, output_schema, compression="zstd") as writer:
|
| 231 |
+
for i in range(0, base_table.num_rows, CHUNK_ROWS):
|
| 232 |
+
chunk = base_table.slice(i, CHUNK_ROWS)
|
| 233 |
+
writer.write_table(_embed_chunk(chunk, output_schema))
|
| 234 |
return out_path
|
| 235 |
|
| 236 |
|
| 237 |
def main():
|
| 238 |
OUTPUT_DIR.mkdir(parents=True, exist_ok=True)
|
| 239 |
builds_index = load_builds_index()
|
| 240 |
+
profile_name_lookup = load_build_to_profile_name()
|
| 241 |
|
| 242 |
args = [int(a) for a in sys.argv[1:]]
|
| 243 |
targets = args or sorted(int(p.stem) for p in (EXPORTS_DIR / "telemetry").glob("*.parquet"))
|
|
|
|
| 246 |
if bid not in builds_index:
|
| 247 |
print(f"build {bid}: not in builds.jsonl, skipping")
|
| 248 |
continue
|
| 249 |
+
out = process_build(bid, builds_index, profile_name_lookup)
|
| 250 |
if out is None:
|
| 251 |
print(f"build {bid}: no telemetry parquet, skipping")
|
| 252 |
continue
|