From 5be09948db803291304343185b7ba1947d0d4ab5 Mon Sep 17 00:00:00 2001 From: igutierrez Date: Sat, 21 Nov 2026 17:53:01 -0600 Subject: [PATCH] agent-skills: notebook stops before training on snapshot data warnings (data-prep case 02) Duplicate or missing primary keys, unparseable values and unmatched foreign keys are snapshot warnings, and the notebook used to train on what was left. The snapshot cell now records them and stops unless the user accepted the loss; adds the dropped-key message to troubleshooting 1a. Co-Authored-By: Claude Opus 5.5 --- .../references/kumo_finetuning_sdk.md | 30 ++++++++++++++++--- .../references/troubleshooting_signals.md | 14 +++++---- 2 files changed, 35 insertions(+), 9 deletions(-) diff --git a/agent-skills/skills/kumoai-reference/references/kumo_finetuning_sdk.md b/agent-skills/skills/kumoai-reference/references/kumo_finetuning_sdk.md index bd74d0edc..b4f0bd2c6 100644 --- a/agent-skills/skills/kumoai-reference/references/kumo_finetuning_sdk.md +++ b/agent-skills/skills/kumoai-reference/references/kumo_finetuning_sdk.md @@ -417,7 +417,22 @@ Source: shipped package (`kumo.engine.pquery.predictive_query`) Materialization is **explicit**. `fit` does not do it for you. ```python -snapshot = graph.snapshot() +import warnings + +# Kumo reports rows it dropped or could not link as warnings and keeps going +# (troubleshooting_signals.md §1a). Stop here, before any training, so the user decides first. +DATA_WARNINGS = ('duplicate primary-key', 'null or invalid primary key', + 'invalid values found', 'non-null rows') +with warnings.catch_warnings(record=True) as caught: + warnings.simplefilter('always') + snapshot = graph.snapshot() +for w in caught: + print(f'{w.category.__name__}: {w.message}') +data_problems = [str(w.message) for w in caught + if any(s in str(w.message) for s in DATA_WARNINGS)] +if data_problems and not DATA_LOSS_ACCEPTED: # config cell; False unless the user chose + raise RuntimeError('Kumo reported a problem in the data; stopped before training:\n' + + '\n'.join(data_problems)) training_table = pquery.generate_training_table(snapshot) prediction_table = pquery.generate_prediction_table( @@ -436,7 +451,13 @@ PredictiveQuery.generate_prediction_table(snapshot, *, prediction_time=None, pla - `snapshot` is **positional** on both. `prediction_time` and `plan` are keyword-only on `generate_prediction_table`. - `graph.snapshot()` reads every table through its connector and builds an on-disk DiskGraph index - under the scratch directory. An unchanged valid snapshot is reused on later runs. + under the scratch directory. An unchanged valid snapshot is reused on later runs, and its data + warnings are raised again. +- **The snapshot cell stops on a data warning.** Repeated or missing primary keys, unparseable + values and unmatched foreign keys are warnings, not errors: without the stop the notebook trains + on what is left. `DATA_LOSS_ACCEPTED = False` goes in the config cell; it becomes `True` only + after the user has seen the messages and chosen to continue with the loss, never on the agent's + own initiative. - `GraphSnapshot` exposes `.id`, `.index_path`, `.graph_config`. - `TrainingTable` exposes `.train_table_path` (ordinary parquet), `.manifest_path`, `.required_stages`, `.generation_plan`. @@ -734,7 +755,7 @@ print('task type:', pquery.get_task_type()) # 5. Materialize. PREDICTION_TIME is NAIVE — a tz-aware datetime raises ValueError. PREDICTION_TIME = datetime(2026, 8, 1) -snapshot = graph.snapshot() +snapshot = graph.snapshot() # wrapped in the §7 data-warning stop training_table = pquery.generate_training_table(snapshot) prediction_table = pquery.generate_prediction_table( snapshot, prediction_time=PREDICTION_TIME, # NAIVE datetime, inside the event history @@ -862,7 +883,8 @@ targets a superseded build and needs rewriting against §10 — do not copy its - [ ] `with_column(...)` results assigned or chained — it returns a new Table. - [ ] `Graph(tables=[...], edges=[Edge(...)])` — list form; `graph.validate()` emitted. - [ ] `pquery.validate()` and `get_task_type()` run before training, both called with no arguments. -- [ ] `graph.snapshot()` before generating any table. +- [ ] `graph.snapshot()` before generating any table, inside the §7 data-warning stop, with + `DATA_LOSS_ACCEPTED = False` in the config cell. - [ ] **`trainer.fit(training_table, snapshot=snapshot)`** — `snapshot=` present. - [ ] **`trainer.predict(prediction_table, snapshot=snapshot, ...)`** — `snapshot=` present. - [ ] `binary_classification_threshold` / `num_classes_to_return` on `predict`, never on diff --git a/agent-skills/skills/kumoai-reference/references/troubleshooting_signals.md b/agent-skills/skills/kumoai-reference/references/troubleshooting_signals.md index a57911a67..fb1522457 100644 --- a/agent-skills/skills/kumoai-reference/references/troubleshooting_signals.md +++ b/agent-skills/skills/kumoai-reference/references/troubleshooting_signals.md @@ -5,7 +5,7 @@ Observable symptom → likely cause → fix. Ordered by when the agent hits them This file is the signal set as previously compiled. It is **not** re-verifiable against the published Kumo documentation, which is stale for this version of the local SDK and is not a source here — do not cite it, fetch it, or reconcile against it. > No verbatim Kumo exception text is established for this SDK. Entries below are keyed on the **observable condition**, not on a quoted message. **Do not fabricate Kumo error strings.** -> The five messages quoted in §1a are the exceptions: they are the SDK's own text, read from its source. +> The six messages quoted in §1a are the exceptions: they are the SDK's own text, read from its source. **Who applies a fix.** A fix that changes the data — casting a column, deduplicating, flattening, filling or filtering values, combining columns into a key, normalising key types — is the user's @@ -74,7 +74,7 @@ Fully specify tables in production code to avoid unexpected re-inference. ### Symptom: row count silently drops after ingestion **Cause:** Duplicate primary key values — Kumo retains one row per key and drops the rest. **Fix:** Report how many rows the key repeats on (the preflight probe, or the snapshot warning in -§1a) and put the choice to the user: a different, genuinely unique key, or the source deduplicated +§1a, which stops the notebook before training) and put the choice to the user: a different, genuinely unique key, or the source deduplicated upstream. The agent does not deduplicate. ### Symptom: a categorical column has very high cardinality @@ -98,13 +98,17 @@ change data, types or the query to make it go away (*Who applies a fix*, above). |---|---|---| | `Snapshot contains duplicate primary-key row(s) for .` | `` rows share a key; Kumo keeps one per key and drops the rest | a different key, or the source deduplicated; or continue knowing `` rows are gone | | `Foreign key
. matched of non-null rows` | only `` of `` rows reach the parent; the rest get no edge | the link may be wrong (wrong column, or values differing in format, e.g. `007` vs `7`), or the parent rows are missing | +| `Snapshot dropped row(s) with a null or invalid primary key in
.` | `` rows have no usable key and are gone from the table | the source fixed upstream, or a different key; or continue knowing `` rows are gone | | ` invalid values found in
.` | `` values did not parse as the column's type and are read as null (see §5) | whether those rows are bad data, or the column's type is wrong | | `key
. has a floating-point dtype` | an ID column is stored as a float (often an integer key with nulls) | the column fixed upstream as an integer or string key | | `foreign key
. (dtype=…) cannot link to primary key
. (dtype=…)` | the two sides of a link hold different types | which side is right, fixed upstream; never cast one side in the notebook | -A float or mismatched key fails `graph.validate()` and stops the notebook. The other three are -warnings: the notebook keeps going and trains on what is left. Either way, the report the user -reads starts with the message, the table and column, and the count. +A float or mismatched key fails `graph.validate()` and stops the notebook. The other four are +warnings: Kumo keeps going and trains on what is left, so the notebook's snapshot cell turns them +into a stop before training (`kumo_finetuning_sdk.md` §7). Either way, the report the user reads +starts with the message, then, per table, how many rows were lost or left unlinked and why — +repeated key, missing key, or a value (a time, a number) that did not parse — and asks before +anything trains. ---