Skip to content

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:

  1. parsing: CSV or XLSX bytes, an inline series or connector rows to a ParsedTable;
  2. mapping: each column to a shared name with a confidence, the reason and alternatives;
  3. 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.

ModuleWhat it holds
ump_intake.blobsContent-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.mappingMapping 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.panelPanel 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.parsingParsing (stage 1): CSV or XLSX bytes, an inline series, or connector rows to a ParsedTable.

Documented on the page of the module that defines them.

NameKindSummary
CONTROL_HINTSconstant
DATE_NAMESconstant
DEFAULT_TIME_IDconstantThe time registry entry used when the caller names none (POC default, proposed).
EXPOSURE_TOKENSconstant
EXTRACTION_RATINGSconstant
KPI_ALIASESconstant
SPEND_TOKENSconstant
TOTALS_TOLERANCE_RELconstant§15 G-DATA-02 tie-out tolerance (relative), proposed. Callers may pass their own tolerance_rel.
TOTAL_REconstant
WEEK_ENDING_NAMESconstantHeaders (after _norm) that label a weekly row by its last day (spec §4: convert to week start).
BlobClientclass
ParsedTableclass
build_panelfunctionApply {column: target}. Returns the canonical table, tie-out, aggregation notes and fit hints.
channel_offunctionThe channel-level ancestor of a media id (a platform such as social.meta rolls up to social).
convert_week_endingfunctionSpec §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_ratingfunction
header_indexfunctionFirst row with at least two non-empty, non-numeric cells.
kpi_idsfunction
media_treefunction
panel_rowsfunctionRead a canonical panel CSV back to (columns, rows) with numbers as floats and dates as ISO text.
parse_csv_bytesfunction
parse_inlinefunction{dates, kpi, spend: {ch: [...]}, controls: {...}, kpi_name?} (the adapter SeriesData shape).
parse_rowsfunctionRows 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_uploadfunction
parse_xlsx_bytesfunction
previewfunction
put_blobfunctionWrite-once content-addressed file. Returns (hex, blob://sha256/<hex>).
read_blobfunction
slugfunction
split_rowsfunctionSeparate data rows from blank and printed total rows.
suggest_columnfunction
suggest_mappingfunction
tie_outfunctionG-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_entriesfunctionThe spec §4 time registry: {id, tz, week_start, grain, fiscal, valid} entries.
time_entryfunctionOne time registry entry (DEFAULT_TIME_ID when time_id is None); 422 SCHEMA_INVALID if unknown.
to_csvfunctionCSV text with \n line ends; an optional printed Total row at the bottom.
to_datefunction
to_numberfunction