[WIP] Proposal: Dynaword bundle layout (data.parquet + metadata.parquet)
Work in progress — a proposal for discussion, not for merge yet. Commit 2 (Hub config cutover) must only be applied together with the migration of all sources; until then, review commit 1 on its own.
Proposal: Dynaword bundle layout for the next version of Polish Dynaword
Base: main at ca786ff. Commits: 3b4476f (accept the bundle layout alongside the legacy shards), 85bce52 (Hub config cutover).
1. Goal
Every source in Polish Dynaword should have the same layout as in Danish Dynaword: a separate file with the text, a separate file with the provenance of every record, and a datasheet with a YAML header. Record provenance (address, license, author) should be part of the dataset, not a side JSONL file that cannot be loaded together with the data. The upload recipe in dynaword-pipeline already produces this layout, so sources contributed through Fabryka Track would land in the repository without conversion.
2. Current contract (main)
data/<key>/<key>.parquet: 8 columnsid, text, source, added, created, token_count, license, author(src/normalize_schema.py,SCHEMA), enforced bysrc/test_uniform_schema.pyfor everydata/*/*.parquet.data/<key>/<key>.attribution.jsonl(LFS, optional): record provenance in a free per-source shape, e.g.id, url, license, license_evidence, text_sha256, transformations.data/<key>/<key>.stats.json: document, token and character counts; the source of all totals.data/<key>/<key>.md: datasheet without a YAML header; the date added is on a- **Added:** YYYY-MM-DDline.created: free text, e.g.2002-2026,2011-12-24, 2026-05-25,unknown.- README: one Hub config,
data/*/*.parquet.
3. Proposed layout
data/<key>/
├── data.parquet id, text, source, added, created, token_count
├── metadata.parquet id, license, author, source_ref, attribution, quality_warnings
├── <key>.md datasheet with a YAML header
├── <key>.stats.json unchanged
└── <key>.license-evidence.json unchanged
data.parquethas exactly the DanishSampleSchema(6 columns).metadata.parquethas one row for every row ofdata.parquet, in the same order, joined onid.source_refis the record's address (URI),attributionholds the remaining provenance evidence as JSON text, andquality_warningsholds sorted, comma-separated labels.createdis a date pairYYYY-MM-DD, YYYY-MM-DD; an unknown start is0001-01-01.- The datasheet has a YAML header (
pretty_name,language: [pl],license,domains) and the sections of the Danish template. - README has two Hub configs:
defaultoverdata/*/data.parquetandmetadataoverdata/*/metadata.parquet.
A synthetic 40-record example produced by the recipe was used for the checks below; it is not part of this PR.
4. Differences
| Area | Now | Proposal | Consequence |
|---|---|---|---|
| Data files | one <key>.parquet |
data.parquet + metadata.parquet |
the Hub shows two tables instead of one |
license, author |
columns in the data | columns in metadata.parquet |
filtering by license needs a join on id |
| Record provenance | <key>.attribution.jsonl, per-source shape |
source_ref + attribution in metadata.parquet |
one shape for all sources, readable by datasets |
created |
free text | date pair | descriptive values must be translated by hand |
| Datasheet | no YAML, Added line |
Danish-style YAML header | test_added_dates accepts both, because a card without an Added line passes |
quality_warnings |
none | labels from the recipe | new field, empty for existing sources |
| Hub config | data/*/*.parquet |
default and metadata |
change only in the release that migrates all sources |
5. Changes in this PR
3b4476faccepts the new layout alongside the old one:src/normalize_schema.py:DATA_SCHEMA,METADATA_SCHEMA,shard_path();src/test_uniform_schema.py: checks both bundle schemas and row-by-rowidalignment, and rejects a corpus that mixes both layouts;src/test_added_dates.py: readsdata.parquetor<key>.parquet;src/migrate_to_bundle.pywith tests: converts an existing source without touching its files;AGENTS.md: describes the layout and the single-release cutover.
85bce52switches the Hub config in README and in thesrc/make_docs.pytemplate, which would otherwise restore the old one on regeneration. Apply this commit only together with the migration of all sources.
Tests (python3 -m pytest src/, Python 3.12, requirements-dev.txt, with the LFS data checked out):
main(ca786ff): 1022 passed, 0 failed.- This branch: 1034 passed, 0 failed (12 new tests).
- A copy of the repo whose
data/holds only the synthetic example bundle: all generic (non-per-source) tests pass excepttest_stale_shards_are_registered_shards, which fails only because the copy lacks the other sources. - The same copy with one legacy source added fails
test_a_source_ships_one_layout_and_the_corpus_does_not_mix_them, as intended.
6. Migrating existing sources
src/migrate_to_bundle.py data/<key> --out <dir> for each source:
- writes the 6 columns to
data.parquet, andlicenseandauthortometadata.parquet; - takes
source_reffrom the record'surlfield (orsource_ref,canonical_url,source_url) in<key>.attribution.jsonl, and writes the rest of the record as JSON intoattribution; - converts
created: a year, a year range and a single date become a date pair;unknownand empty become0001-01-01, <added>. Any other value is rejected instead of guessed.
What this does not cover:
- The converter has not been run on the real sources yet.
- Some sources have a descriptive
createdin the registry, e.g.2018-2024 (book publication metadata proxy). If such values also appear in the rows, the converter rejects them and they need a per-source decision. - The repo has 28 per-source contract tests (
src/test_<key>_contract.py); 25 of them read parquet and 27 refer to the license. They must be rewritten for the new layout in the migration release, ideally through a shared helper that joins both files. src/build_dynaword.pywrites<key>.parquet(it must be switched over, or the converter run after the build).src/pattern_frequency_report.pyreadsdata/*/*.parquet, so after migration it would also pick upmetadata.parquet, which has notextcolumn.src/render_sample.pywould show only the 6 columns ofdata.parquet, without the license and author that AGENTS.md requires in a PR sample.- Hand-written datasheets need a YAML header added.
<key>.attribution.jsonlfiles become redundant after migration. Removing them from the repository is a separate decision, because the LFS history remains.
7. Open questions
- Should
licenseandauthoralso stay indata.parquet(8 columns as today), so filtering by license does not need a join? This departs from the DanishSampleSchema. - Is
0001-01-01acceptable as the unknown start ofcreated, or is an empty field better? - Should
attributionremain JSON text, or get a fixed, typed shape shared by all sources? - Should the migration ship in a single release (the mixed-layout test enforces this), or should the repository keep both layouts for a while in separate Hub configs?
- Who rewrites the 28 contract tests and the tools listed in section 6?
🤖 Generated with Claude Code