Skip to content

feat(schema): one folder per source release, sector as a column (schema 0.3.0) - #5

Merged
lbougan merged 1 commit into
mainfrom
feat/source-folders
Oct 12, 2026
Merged

lbougan merged 1 commit into
mainfrom
feat/source-folders

Conversation

@lbougan

@lbougan lbougan commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

Summary

Reorganises data/ from eleven ranked sector folders into one folder per published release of one datasource, data/<source>-<source_version>/ (today only bafu-2026-v1/). sector becomes a required enum column on processes.parquet, and each folder's metadata.json describes the source: publisher, license, required citation, sectors present, row counts.

Why: sector parquets did not stack across sources. sentier-importers rewrites a sector's files whole on every run, so a second source delivered into an existing sector folder would have erased the first. With one folder per source release a delivery replaces exactly its own folder; nothing is ever merged and two sources never share a file. Lineage is explicit per folder (metadata) and per row (source, source_version, sector).

This narrows the "organised by sector, not by source" rule to sentier-vocab, where terms are a shared concept space nobody owns. Inventory rows are owned by their source; sentier-methods and sentier-mappings already use per-dataset folders.

Changes

  • schema/common.yaml: sector enum (11 values, 99-obsolete becomes obsolete).
  • schema/process.yaml: sector required; source_version now required.
  • schema/metadata.schema.json: per-source metadata, schema_version 0.3.0.
  • scripts/validate.py: one source and one source_version per folder, equal to metadata and to the folder name; sectors list equals the column's distinct values.
  • Data moved by a one-off concatenation of the eleven sector files in rank order, sorted by process_id. No BAFU regeneration. Counts unchanged: 11,947 processes, 420,063 exchanges.
  • READMEs updated.

Test plan

  • python scripts/validate.py passes on the moved data
  • negative check: a mis-named copy with a wrong sectors list fails with the two new errors
  • sentier-importers follow-up PR regenerates bafu-2026-v1/ and matches these row counts and process_id sets
  • sentier-brightway follow-up PR loads from the new layout and re-pins

Please merge with a merge commit so the pinned sha stays reachable.

…ma 0.3.0)

Reorganise data/ from eleven ranked sector folders into one folder per
published release of one datasource, data/<source>-<source_version>/
(bafu-2026-v1). sector becomes a required enum column on processes.parquet
and metadata.json describes the source (publisher, license, citation,
sectors present, row counts). A delivery from sentier-importers now
replaces its folder whole; sources never share a file.

The validator checks one source and one version per folder, both equal to
metadata.json and to the folder name, and the sectors list against the
column. Row counts unchanged: 11,947 processes, 420,063 exchanges.

Motivation: sector parquets did not stack across sources; a second source
delivered into a sector folder would have overwritten the first.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant