kde_cpi.data package¶
Top-level data module for CPI processing.
- class kde_cpi.data.Area(code, name)[source]¶
Bases:
objectGeographic area metadata from the CPI area lookup table.
- class kde_cpi.data.CpiDatabaseLoader(dsn=None, schema='public', connection_kwargs=NOTHING)[source]¶
Bases:
objectPersist CPI datasets into PostgreSQL using asyncpg primitives.
- async bulk_load(dataset, *, truncate=True)[source]¶
Copy the full dataset into PostgreSQL, optionally truncating first.
- async connect(**overrides)[source]¶
Establish (or reuse) the async connection.
- Return type:
Connection- Parameters:
overrides (Any)
- async fetch_dataset()[source]¶
Reconstruct a Dataset from the current database contents.
- Return type:
- async sync_metadata(dataset)[source]¶
Upsert mapping tables and series definitions without touching observations.
- async upsert_observations(observations)[source]¶
Upsert one or more observation rows.
- Return type:
- Parameters:
observations (Iterable[Observation])
- class kde_cpi.data.CpiDatasetBuilder(client=NOTHING)[source]¶
Bases:
objectCoordinate retrieval and parsing of CPI datasets from BLS flat files.
- Parameters:
client (CpiHttpClient)
-
client:
CpiHttpClient¶
- class kde_cpi.data.CpiHttpClient(base_url='https://download.bls.gov/pub/time.series/cu/', timeout=30.0, session=NOTHING, headers=NOTHING)[source]¶
Bases:
objectThin HTTP wrapper around the BLS CPI flat-file endpoints.
- get_text(filename, *, encoding='utf-8')[source]¶
Fetch a remote CPI resource and return its decoded text payload.
-
session:
Session¶
- class kde_cpi.data.Dataset(areas=NOTHING, items=NOTHING, periods=NOTHING, footnotes=NOTHING, series=NOTHING, observations=NOTHING)[source]¶
Bases:
objectAggregate CPI dataset containing mapping tables, series, and observations.
- Parameters:
- extend_observations(observations)[source]¶
Append observation records to the dataset, dropping duplicates.
- Return type:
- Parameters:
observations (Iterable[Observation])
-
observations:
list[Observation]¶
- class kde_cpi.data.Footnote(code, text)[source]¶
Bases:
objectFootnote reference associated with CPI observations.
- class kde_cpi.data.Item(code, name, display_level, selectable, sort_sequence)[source]¶
Bases:
objectItem metadata describing CPI product groupings.
- class kde_cpi.data.Observation(series_id, year, period, value, footnotes=NOTHING)[source]¶
Bases:
objectSingle CPI observation value tied to a series and period.
- class kde_cpi.data.Period(code, abbr, name)[source]¶
Bases:
objectPeriod metadata describing CPI reporting intervals.
- class kde_cpi.data.Series(series_id, area_code, item_code, seasonal, periodicity_code, base_code, base_period, begin_year, begin_period, end_year, end_period, *, series_title='')[source]¶
Bases:
objectMetadata describing a CPI series and its structural attributes.
- Parameters:
- async kde_cpi.data.load_full_history(dsn, *, schema='public', truncate=True, data_files=None)[source]¶
Load the full CPI history and write it into the database.
- async kde_cpi.data.update_current_periods(dsn, *, schema='public')[source]¶
Refresh the current-year CPI data without truncating history.
Submodules¶
- kde_cpi.data.client module
- kde_cpi.data.files module
- kde_cpi.data.ingest module
- kde_cpi.data.loader module
CpiDatabaseLoaderCpiDatabaseLoader.bulk_load()CpiDatabaseLoader.close()CpiDatabaseLoader.connect()CpiDatabaseLoader.connection_kwargsCpiDatabaseLoader.dsnCpiDatabaseLoader.ensure_schema()CpiDatabaseLoader.fetch_dataset()CpiDatabaseLoader.merge_dataset()CpiDatabaseLoader.schemaCpiDatabaseLoader.sync_metadata()CpiDatabaseLoader.upsert_observations()
- kde_cpi.data.models module
- kde_cpi.data.parser module
- kde_cpi.data.pipeline module