Read-only CSV question#
Migration rehearsal#
Split with a seed#
dataset = load_dataset("stanfordnlp/imdb", split="train")
split = dataset.train_test_split(test_size=0.2, seed=42)
train_val = split["train"].train_test_split(test_size=0.125, seed=42)
train_ds = train_val["train"]70 percent of all rows
val_ds = train_val["test"]10 percent
test_ds = split["test"]20 percent
dataset.to_parquet("imdb_train.parquet")best storage format
load_dataset("wikimedia/wikipedia", "20231101.en", split="train", streaming=True)
Project functions#
| Task | Code |
|---|
| Profile CSV columns | profile(text) |
|---|
| Preview cell changes | preview(table, recipe) |
|---|
| Apply reviewed repairs | repair(table, recipe, decisions=None) |
|---|
| Check one record | row_issues(row, contract) |
|---|
| Find duplicate groups | duplicate_rows(rows, contract) |
|---|
| Audit two partitions | audit(train, test) |
|---|
| Split by group hash | split_groups(records, test_fraction=0.2, seed='course') |
|---|
| Run a bounded read | run_query(data, sql, max_rows=100, max_steps=100000) |
|---|
Version large files#
| Command | What it does |
|---|
git lfs track "*.safetensors" | Stores the file outside git with a pointer |
|---|
dvc add data/training_set.parquet | Makes a small .dvc pointer file |
|---|
dvc remote add -d myremote s3://my-bucket/dvc-store | Sets the DVC remote |
|---|
dvc push | Uploads tracked data to the remote |
|---|
snapshot_download("sentence-transformers/all-MiniLM-L6-v2") | Caches a full model repo |
|---|
Rules in code#
- Recipe order
- trim, then alias, then date for each column.
- Changes
- each change names row, column, before and after.
- No coercion
- Boolean true fails integer and number fields.
- Duplicates
- every colliding row is reported, the first one too.
- Gate
- a dataset passes with no quarantined rows and no dataset issues.
- Fingerprint
- NFKC, casefold and collapsed spaces, then SHA-256.
- Group split
- SHA-256 of seed and group over
2**256, below the fraction is test. - Formats
- Parquet for storage, Arrow in memory, CSV and JSON to exchange.
Questions#
- Does normalization catch paraphrases?
- No. It finds exact normalized copies only.
- Does rehearsal change the source database?
- No. The source is never opened writable.
- Does the model run its SQL freely?
- No. SQLite authorization still controls execution.
- Can I drop quarantined rows at once?
- No. Partitions are evidence, not permission to discard.
- Why set a seed?
- The same seed produces the same split every time.
Tips#
- Replay a recipe on another table with
--recipe recipe.json. - Read cleaned.csv with
csv.DictReader as the downstream consumer. - Wait for the gate command to finish before you load its outputs.
- Keep the input beside the output so others can reproduce it.
- Keep model weights out of git with
.gitignore. Use DVC to reproduce runs.