Repository navigation
Support tables without primary keys in kumo.pytorch - #267
Conversation
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Change mapObserved failure: kumo.pytorch rejects an FK-only event table at TableSpec construction even though the workspace DiskGraph already supports it. Make the PK optional only for non-entity tables, preserve native/source-occurrence identity through existing paths, and keep entity lookup keyed. Completion means histories, reductions, graph sampling and serving preserve occurrence multiplicity without generated keys; keyed behavior remains intact. The old standalone dependency-pin changes are omitted because both packages now share this workspace. Verification passed: 1,926 CPU tests, 705 complete conformance checks, 41 installed-wheel checks, all three example notebooks, and independent adversarial review.
|
|
/ok to test e7a75e6 |
lambyqq
left a comment
There was a problem hiding this comment.
Approving. Two non-blocking test comments:
test_keyless_tie_order_survives_an_ordered_serving_subsetpins in-memory ordinal behavior that G-KEYLESS-001 / G-SERVING-001 deliberately don't promise, and DiskGraph doesn't have it. Suggest dropping it.- Consider a DiskGraph test that a relation between two keyless tables (or a keyless column and a non-PK column) is refused by
check()withDG-RELATION-KEYS. Today the only relation-shape test is in-memory-only (test_keyless_non_primary_key_relation_remains_valid_on_reference).
|
@bberger62 once this merges, could you close kumo-ai/rdl-platform#139 and #59 (superseded by this port)? |
## Summary Follow-up to [Siyang's review of #267](#267 (review)), addressing both non-blocking test comments. The serving-subset test asserted that an equal-timestamp, limited keyless history must choose the same row before and after rebuilding from a subset. G-KEYLESS-001 and G-SERVING-001 deliberately leave keyless IDs and equal-time tie ordering local to each preparation. Remove this test so the suite does not promise behavior the API and DiskGraph do not guarantee. Existing occurrence-preservation and serving graph checks remain. Add parameterized DiskGraph coverage for relations joining two keyless tables and relations joining a keyless column to a keyed table's non-PK column. Both shapes lack the one primary-key side DiskGraph requires. Assert that public `check()` reports `DG-RELATION-KEYS` at the offending relation and `prepare()` refuses the contract before opening the engine. The in-memory positive test remains because its reference joins support these relation columns. This changes one test file; runtime behavior and published guarantees are unchanged. ## Change map [File-by-file change map and scope](#314 (comment)). ## Testing Done From `packages/experimental/kumo-pytorch`, using the workspace environment and `PYTHONPATH=src CUDA_VISIBLE_DEVICES=''`: - `python -m pytest -q tests/test_keyless_tables.py tests/test_diskgraph_unsupported.py --require-imports` — **56 passed**, including DiskGraph coverage. - `ruff check tests/test_keyless_tables.py` and `ruff format --check tests/test_keyless_tables.py` — passed. - `git diff --check` — passed. ## Checklist - [x] Reviewed breaking changes: none. - [x] Reviewed examples and documentation: no updates needed. - [x] Updated focused test coverage. Co-authored-by: Codex <[email protected]>
Summary
Allow non-entity tables without primary keys in
kumo.pytorch, following DiskGraph's existing row identity. For example,events(owner FK → users.id, at, amount)can supply histories, aggregates and graph neighbors without an artificial event key. Entity/root and candidate entity declarations still require a PK.This ports rdl-platform#139 into the API's new home at
packages/experimental/kumo-pytorch, introduced by #244. The API implementation, tests and agreed examples are retained under thekumo.pytorchnamespace. The standalone dependency-pin changes are omitted: this package already uses the workspace DiskGraph, including merged native support from #184.Where support is missing
The current
TableSpecconstructor rejectsprimary_key=Nonewithtable name and primary key must be non-empty, before the table reaches ingestion. Downstream API paths also assume every table has a PK: native ingestion configuration always declares one, temporal sequences project it, graph output reads it for identity, and serving requires it for row uniqueness and fetching.DiskGraph already stores and traverses rows without PKs. Ingestion assigns native node IDs; graph sampling and temporal queries use those IDs to address individual occurrences. External PK lookup is a separate requirement for choosing entities. This change carries that existing distinction through the API.
Implementation and intended behavior
TableSpec(..., primary_key=None)andbuild.Table(..., key=None). A shared declaration check rejects PK-less sample/candidate entities before binding, type inference or source access.distinct=Trueremoves repeated visits rather than collapsing equal values.rows_speconly for keyed tables. Update authored documentation and regenerate the public API reference.No source key generation, additional identity column or persistent identity inventory is introduced. Existing keyed ordering, entity lookup, source cleanup and unsupported-operation checks retain their behavior. Native source, workspace packaging and dependencies are unchanged by this PR.
The new
G-KEYLESS-001guarantee has two hand-calculated examples:(9,10]count 1. Empty history: count/sum 0.Keyless IDs remain opaque and local to an index or prepared serving dataset. Reordering, repartitioning or serving subsets can change tied selections and floating reduction rounding. Occurrence multiplicity and integer reductions remain exact; stable cross-preparation identity requires a declared PK.
Testing Done
Validation uses Python 3.12 on CPU, with DiskGraph built from this branch's in-tree source. The editable package is
kumo.pytorch; the oldrdl-pytorcheditable install was removed. Installed-wheel checks use a separate environment and staged tests/docs/examples withoutsrc/; both API and engine imports were verified to come from the installed wheels.From
packages/experimental/kumo-pytorch:Both the source distribution and its wheel build successfully. The installed-wheel gate also exercises the README, keyless/entity tests and example notebooks. Ruff uses the CI pin, 0.17.3. Native compilation used the existing Rust 1.98 compiler; CI uses the repository's pinned toolchain. No GPU or live-service validation is claimed.
Earlier standalone benchmarks measured roughly 4% additional in-memory test-engine time and 6.3% retained source heap. Those historical measurements were not repeated for this monorepo port.
Migration and review
All 26 existing touched files matched the imported base after namespace conversion; the four new guarantee/test files had no collisions. This is the same RDL feature moved into the monorepo, with no additional behavior or altered golden answers. The new package's existing CPU, DiskGraph, notebooks and installed-wheel workflows cover the changed paths.
Independent adversarial review found no actionable issues. It executed all 26 focused keyless cases and four golden case/engine combinations, plus multi-file/shard, NULL-FK, aliased-row, repeated-visit, graph and serving probes. It also checked namespace coexistence and verified that all 67 Python modules in the built wheel match source byte-for-byte.
Change map
File-by-file change map.
Reviewed at: e7a75e6