ump_intake
package ump-intake
ump_intake: shared data intake for the UMP POC (spec §6, datasets, extraction and lineage).
Three pure stages plus the content-addressed blob write:
- parsing: CSV or XLSX bytes, an inline series or connector rows to a
ParsedTable; - mapping: each column to a shared name with a confidence, the reason and alternatives;
- panel: apply the mapping, roll platforms up to channels, tie out to printed totals (G-DATA-02) and render the canonical weekly CSV.
Used by apps/onboarding (wizard intake) and apps/data (catalogue upload, connected datasets).
Read the ump-intake guide first for the main entry points.
Modules
Section titled “Modules”| Module | What it holds |
|---|---|
ump_intake.blobs | Content-addressed blob writes and reads through core’s POST /v1/blobs (the GCS stand-in), so every write is principal-checked and emits blob.stored. The client is any object with upload_blob and get_blob coroutines (ump_sdk.AsyncCoreClient). |
ump_intake.mapping | Mapping suggestions (stage 2): each column to a shared name (date, KPI id, media id from the registry media tree, control, or ignore), with a confidence, the reason and alternatives. |
ump_intake.panel | Panel build (stage 3): apply the confirmed mapping, aggregate columns that map to the same media id, tie the extracted totals to the printed ones (G-DATA-02), and render the canonical weekly CSV. |
ump_intake.parsing | Parsing (stage 1): CSV or XLSX bytes, an inline series, or connector rows to a ParsedTable. |
Re-exports
Section titled “Re-exports”Documented on the page of the module that defines them.
| Name | Kind | Summary |
|---|---|---|
CONTROL_HINTS | constant | |
DATE_NAMES | constant | |
DEFAULT_TIME_ID | constant | The time registry entry used when the caller names none (POC default, proposed). |
EXPOSURE_TOKENS | constant | |
EXTRACTION_RATINGS | constant | |
KPI_ALIASES | constant | |
SPEND_TOKENS | constant | |
TOTALS_TOLERANCE_REL | constant | §15 G-DATA-02 tie-out tolerance (relative), proposed. Callers may pass their own tolerance_rel. |
TOTAL_RE | constant | |
WEEK_ENDING_NAMES | constant | Headers (after _norm) that label a weekly row by its last day (spec §4: convert to week start). |
BlobClient | class | |
ParsedTable | class | |
build_panel | function | Apply {column: target}. Returns the canonical table, tie-out, aggregation notes and fit hints. |
channel_of | function | The channel-level ancestor of a media id (a platform such as social.meta rolls up to social). |
convert_week_ending | function | Spec §4: relabel a week-ending date column by the date each week starts (six days earlier), as a logged step. Returns a new table (the input is left as it was) and the step record. Unreadable dates are kept as they were and counted; a start date that is not the entry’s week_start weekday is converted anyway and labelled in the issues, so the caller sees the weeks do not line up with the registry. |
default_rating | function | |
header_index | function | First row with at least two non-empty, non-numeric cells. |
kpi_ids | function | |
media_tree | function | |
panel_rows | function | Read a canonical panel CSV back to (columns, rows) with numbers as floats and dates as ISO text. |
parse_csv_bytes | function | |
parse_inline | function | {dates, kpi, spend: {ch: [...]}, controls: {...}, kpi_name?} (the adapter SeriesData shape). |
parse_rows | function | Rows read through a data connection (a list of lists, or of dicts read in columns order) to a table, so mapping suggestions and build_panel work on connected data exactly as on a file. Blank and printed total rows are separated the same way. raw_bytes is the CSV rendering, held in memory only: callers decide whether the copy policy lets it be stored. |
parse_upload | function | |
parse_xlsx_bytes | function | |
preview | function | |
put_blob | function | Write-once content-addressed file. Returns (hex, blob://sha256/<hex>). |
read_blob | function | |
slug | function | |
split_rows | function | Separate data rows from blank and printed total rows. |
suggest_column | function | |
suggest_mapping | function | |
tie_out | function | G-DATA-02: extracted totals against printed totals, per source column. The headline pair is the column with the largest relative gap, so the gate reflects the worst column. |
time_entries | function | The spec §4 time registry: {id, tz, week_start, grain, fiscal, valid} entries. |
time_entry | function | One time registry entry (DEFAULT_TIME_ID when time_id is None); 422 SCHEMA_INVALID if unknown. |
to_csv | function | CSV text with \n line ends; an optional printed Total row at the bottom. |
to_date | function | |
to_number | function |