euromod_linking.query¶
Connector-backed read helpers for a country’s policy structure.
Two-stage design so extension exploration is cheap:
_build_raw_country materialises the connector object graph for a country ONCE (the expensive first-touch interop), extracting every policy/constant definition plus its extension links (shortName, baseOff) as plain data. Cached per country.
_resolve builds a CountryIndex from that raw data for a given (dataset, extensions) configuration in pure Python — no connector interop. Duplicate definitions are resolved switch- and extension-aware: a per-system switch config (get_switch_value baseline for a dataset + caller overrides) drives the same include/exclude logic as euromod.container.filter; the effective value is the last non-‘n/a’ among active definitions in spine order (fallback: last non-‘n/a’ overall).
Both raw and resolved results are cached; the model is read-only at runtime so caches stay valid for the process lifetime.
system_extension_names, system_constant_names, system_constant_params and income_list_components are kept here rather than taken from euromod, so the package works against every released version of the connector.
Exceptions¶
Mapping key not found. |
Classes¶
Functions¶
|
Materialise (or reuse) the country's raw data and resolve it for one config. |
|
|
|
Effective (variable, sign) components of an income list in a live system, |
|
Yield policies of a Country or System, skipping ReferencePolicy objects |
|
Pure resolution of an income list's effective components under one |
|
$-prefixed constant names defined (via DefConst) in a live System object. |
|
All $-prefixed parameter names overridable via run(constantsToOverwrite=...), |
|
Extension short names the model accepts in run(switches=...). |
Module Contents¶
- exception euromod_linking.query.IncomeListLookupError(message: str, available: list[str])[source]¶
Mapping key not found.
- available¶
- class euromod_linking.query.CountryIndex[source]¶
-
- constants: dict[str, ConstantInfo]¶
- policies: dict[str, PolicyInfo]¶
- systems: dict[str, SystemInfo]¶
- euromod_linking.query.build_country_index(country_code: str, dataset=None, extensions=None) CountryIndex[source]¶
Materialise (or reuse) the country’s raw data and resolve it for one config.
- euromod_linking.query.get_country_index(country_code: str, dataset=None, extensions=None) CountryIndex | None[source]¶
- euromod_linking.query.income_list_components(country_code: str, system_name: str, list_name: str, dataset=None, extensions=None) list[tuple[str, str]][source]¶
Effective (variable, sign) components of an income list in a live system, resolved for the given (dataset, extensions) configuration.
- euromod_linking.query.iter_real_policies(scope)[source]¶
Yield policies of a Country or System, skipping ReferencePolicy objects (which lack .functions/.comment and crash naive iteration/find()).
- euromod_linking.query.resolve_income_list(rsys: dict, cfg: dict, list_name: str, _seen: frozenset = frozenset()) list[tuple[str, str]][source]¶
Pure resolution of an income list’s effective components under one (dataset, extensions) switch config, from a system’s raw data.
Extension-aware at every level: the defining policy, the DefIl function, and each component parameter must be active/included. Duplicate DefIl definitions resolve in spine order (last active wins, the constants rule); nested ils_*/il_* components expand recursively, cycle-safe, with signs multiplied through. Deterministic; components in definition order, deduped.
- euromod_linking.query.system_constant_names(system) set[str][source]¶
$-prefixed constant names defined (via DefConst) in a live System object. Extension-independent; used to validate constants_to_overwrite.
- euromod_linking.query.system_constant_params(system) dict[str, set[str]][source]¶
All $-prefixed parameter names overridable via run(constantsToOverwrite=…), mapped to the set of groups they are defined with (’’ = ungrouped).
Walks every function, not just DefConst: uprating factors (e.g. $f_cpi) are parameters of the Uprate function keyed by year-group, and must validate as (“$f_cpi”, “2023”)-style overrides.
- euromod_linking.query.system_extension_names(country_code: str, system_name: str | None = None) set[str][source]¶
Extension short names the model accepts in run(switches=…).
A switch the model does not know is silently dropped by the engine (it only mutters “An error occurred during the processing of the ExtensionSwitches”), so a scenario can appear to run while the behaviour it asked for never happened. Callers validate against this first.
Sources, unioned: the country’s own extensions (country.extensions merges local + model-wide, i.e. everything declared in Config/SWITCHABLEPOLICYCONFIG.xml — including add-on extensions such as LMA_trans) and the per-dataset switch defaults actually observed for the system. Returns an empty set if neither can be read, which callers treat as “cannot validate” rather than “nothing is valid”.