Skip to content

feat(custom_data): support remaining config.json fields#122

Merged
jm-rivera merged 2 commits into
mainfrom
feat/config-remaining-fields-113
Jun 29, 2026
Merged

feat(custom_data): support remaining config.json fields#122
jm-rivera merged 2 commits into
mainfrom
feat/config-remaining-fields-113

Conversation

@jm-rivera

@jm-rivera jm-rivera commented Jun 29, 2026

Copy link
Copy Markdown
Collaborator

Adds three config.json fields the importer supports but the package rejected under extra="forbid", plus a builder for the vertical-specs file, so generated bundles can carry them and round-trip cleanly.

What changed

  • dataDownloadUrl (top-level list): set_dataDownloadUrl(urls | None) replaces or unsets; add_dataDownloadUrl(url) appends, initialising the list when unset.
  • verticalSpecsFile (top-level string): set_verticalSpecsFile(name | None).
  • observationProperties (per input file): a typed ObservationProperties model (unit, scalingFactor, measurementMethod, observationPeriod) with extra="allow", surfaced through a new observationProperties= kwarg on add_explicit_schema_file. Keys are written verbatim with no dcid: aliasing and custom keys pass through, which is how the importer reads them.
  • Vertical-specs builder: add_vertical_spec(verticals=..., population_type="Thing", measured_properties=...) appends typed VerticalSpec entries, points verticalSpecsFile at the output file, and export_vertical_specs (called by export_all) writes the {"specs": [...]} JSON the importer reads when groupStatVarsByProperty is set. Lets users generate that file instead of hand-writing it.

While adding the two top-level fields I found that _merge_simple_attrs only copied the fields it enumerated by name, so any field not in that list was silently dropped on merge. Both new fields are now wired into the merge path (scalar for verticalSpecsFile, sequence for dataDownloadUrl).

Docs are intentionally left out — the loading-data docs are being rewritten under #105, so documenting these here would just be redone.

Testing

ruff format --check, ruff check, ty check all clean; uv run pytest → 129 passed. New coverage: model round-trips for all three fields, custom-key preservation, nested exclude_none, the absent-when-unset contract, both dataDownloadUrl setters, merge preservation, and the vertical-specs builder (config wiring, {"specs": [...]} export content, and the export_all hook). A new golden fixture (tests/goldens/config_all_fields.json) proves a config with all three fields survives load→dump unchanged.

Closes #113.

Co-authored-by: Claude noreply@anthropic.com

jm-rivera and others added 2 commits June 29, 2026 15:50
Adds three importer-supported config.json fields the package previously
rejected under extra="forbid":

- dataDownloadUrl (top-level list), with set_dataDownloadUrl and
  add_dataDownloadUrl on CustomDataManager
- verticalSpecsFile (top-level string), with set_verticalSpecsFile
- observationProperties on each input file, via a typed
  ObservationProperties model and a new kwarg on add_explicit_schema_file.
  Keys are emitted verbatim with no dcid: aliasing and custom keys pass
  through, matching how the importer reads them.

Also closes a pre-existing gap where _merge_simple_attrs only copied the
config fields it enumerated, silently dropping any others on merge. Both
new top-level fields are now carried through merge_config.

Docs are left for the #105 rewrite.

Closes #113.

Co-authored-by: Claude <noreply@anthropic.com>
Adds add_vertical_spec on CustomDataManager: it appends typed VerticalSpec
entries, points the config's verticalSpecsFile at the output file (default
vertical_specs.json, leaving an explicitly set name untouched), and writes
the {"specs": [...]} JSON through a new export_vertical_specs, wired into
export_all.

Companion to the verticalSpecsFile config field in this PR, so users can
generate the specs file instead of hand-writing it.

Co-authored-by: Claude <noreply@anthropic.com>
@jm-rivera jm-rivera marked this pull request as ready for review June 29, 2026 14:52
@jm-rivera jm-rivera requested a review from tillywoodfield June 29, 2026 14:52
@jm-rivera jm-rivera merged commit 93ef6e4 into main Jun 29, 2026
3 checks passed
@jm-rivera jm-rivera deleted the feat/config-remaining-fields-113 branch June 29, 2026 15:16
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.

Support remaining config.json fields: dataDownloadUrl, verticalSpecsFile, and per-file observationProperties

2 participants