nudb_config.pydantic package¶
nudb_config.pydantic.datasets module¶
- class Dataset(**data)¶
Bases:
DotMapBaseModelDataset configuration entry under
[datasets].- Parameters:
team (str)
bucket (str)
path_glob (str)
variables (list[str] | None)
thresholds_empty (DotMapDict[float] | None)
min_values (DotMapDict[str] | None)
max_values (DotMapDict[str] | None)
dataset_specific_renames (DotMapDict[str] | None)
- team¶
The name of the dapla-team who owns the dataset.
- bucket¶
The bucket name, under the dapla-team, where the dataset is located.
- path_glob¶
A glob that can be used in the bucket to pinpoint all available periods and versions of the dataset.
- variables¶
Ordered list of variable names included in the dataset.
- thresholds_empty¶
Allowable proportions of emptiness per variable.
- min_values¶
Minimum inclusive filter values per variable.
- max_values¶
Maximum inclusive filter values per variable.
- dataset_specific_renames¶
Custom renames to apply only for this dataset.
- bucket: str¶
- dataset_specific_renames: DotMapDict[str] | None¶
- max_values: DotMapDict[str] | None¶
- min_values: DotMapDict[str] | None¶
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- path_glob: str¶
- team: str¶
- thresholds_empty: DotMapDict[float] | None¶
- variables: list[str] | None¶
- class DatasetOverride(**data)¶
Bases:
DotMapBaseModelPartial dataset override entry under
[datasets].- Parameters:
team (str | None)
bucket (str | None)
path_glob (str | None)
variables (list[str] | None)
thresholds_empty (DotMapDict[float] | None)
min_values (DotMapDict[str] | None)
max_values (DotMapDict[str] | None)
dataset_specific_renames (DotMapDict[str] | None)
- bucket: str | None¶
- dataset_specific_renames: DotMapDict[str] | None¶
- max_values: DotMapDict[str] | None¶
- min_values: DotMapDict[str] | None¶
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- path_glob: str | None¶
- team: str | None¶
- thresholds_empty: DotMapDict[float] | None¶
- variables: list[str] | None¶
- class DatasetsFile(**data)¶
Bases:
DotMapBaseModelRoot schema of
datasets.toml.- Parameters:
datasets (DotMapDict[Dataset])
- datasets¶
Mapping of dataset name to its configuration.
- datasets: DotMapDict[Dataset]¶
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class DatasetsOverrideFile(**data)¶
Bases:
DotMapBaseModelRoot schema for dataset override TOMLs.
- Parameters:
datasets (DotMapDict[DatasetOverride])
- datasets: DotMapDict[DatasetOverride]¶
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
nudb_config.pydantic.dotmap module¶
- class DotMap(*args, **kwargs)¶
Bases:
objectProvide dot- and item-access for wrappers and Pydantic models.
Usage: - Wrapper:
DotMap({"a": 1}).aandDotMap({"a": 1})["a"]. - Base class:class M(DotMap, BaseModel): ...som.aandm["a"]both work, without conflicting with Pydantic’s iterator.When mixed into Pydantic models, initialization defers to Pydantic; otherwise a mapping positional argument or
data=keyword seeds the internal store.
- Parameters:
args (Any)
kwargs (Any)
- get(key, default=None)¶
Return the value for
keyif present; otherwisedefault.Tries attribute access first and then falls back to the mapping view.
- Parameters:
key (
str) – The key to look up.default (
Any|None) – Value to return ifkeyis not found.
- Returns:
The found value or
defaultif absent.- Return type:
Any
- items()¶
Return a dynamic view of key/value pairs across model or mapping.
- Return type:
ItemsView[str,Any]
- keys()¶
Return a dynamic view of keys across model or mapping.
- Return type:
KeysView[str]
- values()¶
Return a dynamic view of values across model or mapping.
- Return type:
ValuesView[Any]
- class DotMapBaseModel(**data)¶
Bases:
BaseModel,DotMapCombines the Dotmap class with Basemodel, placing BaseModel first.
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class DotMapDict(data=None, *, value_type=None)¶
Bases:
Generic[T]Dictionary wrapper that supports both attribute and item access.
- Parameters:
data (Mapping[str, T] | None)
value_type (type[T] | None)
- get(key, default=None)¶
Return the value for
keyif present; otherwisedefault.- Return type:
Optional[TypeVar(T)]- Parameters:
key (str)
default (T | None)
- items()¶
Return a dynamic view of key/value pairs.
- Return type:
ItemsView[str,TypeVar(T)]
- keys()¶
Return a dynamic view of keys.
- Return type:
KeysView[str]
- values()¶
Return a dynamic view of values.
- Return type:
ValuesView[TypeVar(T)]
nudb_config.pydantic.load module¶
- class NudbConfig(**data)¶
Bases:
DotMapBaseModelUnified configuration built from the TOML files.
This model aggregates values from
settings.toml,``options.toml``,variables.toml,variables_outdated.toml(if present),datasets.toml, andpaths.toml. It mirrors the top-level structure exposed by the Dynaconf-based loader to preserve compatibility. Any codelist augmentations performed by the Dynaconf variant are also applied during loading so that downstream behavior matches.- Parameters:
dapla_team (str)
short_name (str)
variables_sort_unit (list[str] | None)
variables (DotMapDict[Variable])
datasets (DotMapDict[Dataset])
paths (DotMapDict[PathEntry])
options (Options)
constants (Constants)
- model_config¶
Pydantic configuration allowing arbitrary DotMap content.
- dapla_team¶
Team identifier from
settings.toml.
- short_name¶
Short project name from
settings.toml.
- variables_sort_unit¶
Unit sort order from
variables.toml.
- variables¶
Mapping of variable name to definition.
- datasets¶
Mapping of dataset name to configuration.
- paths¶
Mapping of environment name to paths configuration.
- options¶
Options from
options.toml.
- constants¶
Constants from
constants.toml.
- constants: Constants¶
- dapla_team: str¶
- datasets: DotMapDict[Dataset]¶
- merge_tomls(toml_dir)¶
Merge values from external TOML files into this config and return it.
- Return type:
- Parameters:
toml_dir (str | Path)
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- paths: DotMapDict[PathEntry]¶
- short_name: str¶
- variables: DotMapDict[Variable]¶
- variables_sort_unit: list[str] | None¶
- load_pydantic_settings()¶
Load and assemble configuration using Pydantic models.
Reads the package-embedded TOML files under
nudb_config/config_tomls(settings.toml,variables.toml, optionalvariables_outdated.toml,datasets.toml,paths.toml), parses them into their respective Pydantic models, applies the same codelist augmentations as the Dynaconf-based loader, and returns a unifiedNudbConfigobject mirroring the Dynaconf structure.- Returns:
Aggregated configuration ready for downstream use.
- Return type:
nudb_config.pydantic.options module¶
- class Options(**data)¶
Bases:
DotMapBaseModelTyped options configuration under
[options].- Parameters:
warn_unsafe_derive (bool)
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- warn_unsafe_derive: bool¶
- class OptionsFile(**data)¶
Bases:
DotMapBaseModelRoot schema of
options.toml.- Parameters:
options (Options)
- options¶
Options configuration block.
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
nudb_config.pydantic.paths module¶
- class PathEntry(**data)¶
Bases:
DotMapBaseModelPath configuration for a named environment under
[paths].- Parameters:
produkt (str | None)
katalog (str | None)
shared_root_external (str | None)
shared_root_internal (str | None)
shared_utdanning_external (str | None)
shared_utdanning_internal (str | None)
- produkt¶
Product data root.
- katalog¶
Base catalog path for configuration artifacts.
Shared bucket root for common datasets external to the team.
Shared bucket root for common datasets internal to the team.
Local shared education data path external to the team.
Local shared education data path internal to the team.
- katalog: str | None¶
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- produkt: str | None¶
- shared_root_external: str | None¶
- shared_root_internal: str | None¶
- shared_utdanning_external: str | None¶
- shared_utdanning_internal: str | None¶
- class PathsFile(**data)¶
Bases:
DotMapBaseModelRoot schema of
paths.toml.- Parameters:
paths (DotMapDict[PathEntry])
- paths¶
Mapping of environment name to its paths configuration.
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- paths: DotMapDict[PathEntry]¶
nudb_config.pydantic.settings module¶
- class SettingsFile(**data)¶
Bases:
DotMapBaseModelRoot schema of
settings.toml.- Parameters:
dapla_team (str)
short_name (str)
- dapla_team¶
Name of the Dapla team that owns the data.
- short_name¶
Short identifier for the project or dataset.
- dapla_team: str¶
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- short_name: str¶
nudb_config.pydantic.variables module¶
- class Variable(**data)¶
Bases:
DotMapBaseModelDefinition of a single variable from
variables.toml.- Parameters:
name (str)
unit (str)
dtype (Literal['INTEGER', 'FLOAT', 'STRING', 'DATETIME', 'BOOLEAN'])
description_short (str | None)
length (list[int] | None)
klass_codelist (int | None)
klass_codelist_from_date (str | None)
klass_variant (int | None)
klass_variant_search_term (str | None)
klass_correspondence_to (int | None)
klass_codelist_metadata (KlassClassification | None)
klass_variant_metadata (KlassVariant | None)
renamed_from (list[str] | None)
derived_from (list[str] | None)
derived_uses_datasets (list[str] | None)
derived_join_keys (list[str] | None)
codelist_extras (dict[str, str] | None)
outdated_comment (str | None)
- name¶
Variable name injected from its TOML key.
- unit¶
Logical grouping the variable belongs to.
- dtype¶
Storage or semantic type of the variable.
- description_short¶
Optional short description.
- length¶
Allowed lengths for string fields, if constrained.
- klass_codelist¶
KLASS codelist identifier, if applicable.
- klass_codelist_from_date¶
Earliest date for the codelist.
- klass_variant¶
KLASS variant identifier, if applicable.
- klass_variant_search_term¶
Search term used to find a variant.
- klass_correspondence_to¶
The Classification ID for what we are mapping from the klass_codelist to.
- klass_codelist_metadata¶
Metadata fetched from KLASS for the codelist.
- klass_variant_metadata¶
Metadata fetched from KLASS for the variant.
- renamed_from¶
Previous column name(s) that map to this variable.
- derived_from¶
Source variables used to derive this value.
- derived_uses_datasets¶
Names of datasets a derived variable should be derived from (in the cases it is “all-data dependent”).
- derived_join_keys¶
The keys the derived variable can be joined back on a dataset with, if its a variable with one value per person, this could be just “snr” for example.
- codelist_extras¶
Additional code mappings injected at load time.
- outdated_comment¶
Explanation when the unit is outdated.
- model_config¶
Pydantic configuration allowing arbitrary KLASS types.
- codelist_extras: dict[str, str] | None¶
- derived_from: list[str] | None¶
- derived_join_keys: list[str] | None¶
- derived_uses_datasets: list[str] | None¶
- description_short: str | None¶
- dtype: Literal['INTEGER', 'FLOAT', 'STRING', 'DATETIME', 'BOOLEAN']¶
- klass_codelist: int | None¶
- klass_codelist_from_date: str | None¶
- klass_codelist_metadata: KlassClassification | None¶
- klass_correspondence_to: int | None¶
- klass_variant: int | None¶
- klass_variant_metadata: KlassVariant | None¶
- klass_variant_search_term: str | None¶
- length: list[int] | None¶
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- name: str¶
- outdated_comment: str | None¶
- renamed_from: list[str] | None¶
- unit: str¶
- class VariablesFile(**data)¶
Bases:
DotMapBaseModelRoot schema of
variables.toml.- Parameters:
variables_sort_unit (list[str] | None)
variables (DotMapDict[Variable])
- variables_sort_unit¶
Preferred order of variable units.
- variables¶
Mapping of variable name to its definition.
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- variables: DotMapDict[Variable]¶
- variables_sort_unit: list[str] | None¶