cdm_data_loaders.core.registry ¶
Validated registries and module loaders for entity models, JSON Schemas, PyArrow schemas, transforms, and pre-processors.
RejectedFreezerMixin
pydantic-model
¶
Bases: BaseModel
Mixin to forbid the use of the reserved _rejected table name in registries.
Show JSON schema:
Validators:
-
_validate_and_freeze
Source code in src/cdm_data_loaders/core/registry.py
ModelRegistry
pydantic-model
¶
Bases: RejectedFreezerMixin, BaseModel
A validated registry of entity models.
Show JSON schema:
Config:
str_strip_whitespace:True
Fields:
-
registry(dict[RegistryKey, type[BaseModel]])
Validators:
-
_validate_and_freeze
Source code in src/cdm_data_loaders/core/registry.py
SchemaRegistry
pydantic-model
¶
Bases: RejectedFreezerMixin, BaseModel
A validated registry of validated entity schemas.
Show JSON schema:
{
"$defs": {
"ValidatedSchema": {
"description": "A validated JSON Schema.",
"properties": {
"jsonschema": {
"additionalProperties": true,
"title": "Jsonschema",
"type": "object"
}
},
"required": [
"jsonschema"
],
"title": "ValidatedSchema",
"type": "object"
}
},
"description": "A validated registry of validated entity schemas.",
"properties": {
"registry": {
"additionalProperties": {
"$ref": "#/$defs/ValidatedSchema"
},
"minProperties": 1,
"propertyNames": {
"minLength": 1
},
"title": "Registry",
"type": "object"
}
},
"required": [
"registry"
],
"title": "SchemaRegistry",
"type": "object"
}
Config:
str_strip_whitespace:True
Fields:
-
registry(dict[RegistryKey, Annotated[ValidatedSchema, BeforeValidator(_coerce_validated_schema)]])
Validators:
-
_validate_and_freeze
Source code in src/cdm_data_loaders/core/registry.py
ArrowSchemaRegistry
pydantic-model
¶
Bases: RejectedFreezerMixin, BaseModel
A validated registry of PyArrow schemas.
Config:
frozen:Truestr_strip_whitespace:True
Fields:
-
registry(dict[RegistryKey, InstanceOf[Schema]])
Validators:
-
_validate_and_freeze
Source code in src/cdm_data_loaders/core/registry.py
TransformRegistry
pydantic-model
¶
Bases: RejectedFreezerMixin, BaseModel
A validated registry of per-table record transform functions.
Config:
frozen:Truestr_strip_whitespace:True
Fields:
-
registry(dict[RegistryKey, RecordTransformFn])
Validators:
-
_validate_and_freeze
Source code in src/cdm_data_loaders/core/registry.py
PreprocessorRegistry
pydantic-model
¶
Bases: RejectedFreezerMixin, BaseModel
A validated registry of pipeline-wide or per-table file pre-processor functions.
Config:
frozen:Truestr_strip_whitespace:True
Fields:
-
default(tuple[FilePreprocessFn, ...]) -
registry(dict[RegistryKey, PreprocessorTuple])
Validators:
-
_validate_and_freeze -
_validate_mode
Source code in src/cdm_data_loaders/core/registry.py
get ¶
Return the file pre-processors configured for table_name or pipeline-wide default.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
table_name
|
str | None
|
target table name, or |
None
|
Returns:
| Type | Description |
|---|---|
tuple[FilePreprocessFn, ...]
|
tuple of file pre-processor callables to execute in order |
Source code in src/cdm_data_loaders/core/registry.py
load_registry_dict ¶
load_registry_dict(
module_path: str,
attribute_name: Literal["ENTITY_SCHEMAS"],
) -> SchemaRegistry
load_registry_dict(
module_path: str, attribute_name: str
) -> (
ModelRegistry
| SchemaRegistry
| TransformRegistry
| ArrowSchemaRegistry
)
Import module_path and return its validated registry for attribute_name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
module_path
|
str
|
dotted import path of the registry module |
required |
attribute_name
|
str
|
name of the dictionary attribute on the module
( |
required |
Returns:
| Type | Description |
|---|---|
ModelRegistry | SchemaRegistry | TransformRegistry | ArrowSchemaRegistry
|
the validated registry instance |
Raises:
| Type | Description |
|---|---|
ValueError
|
if the attribute name is unsupported or uses the reserved |
Source code in src/cdm_data_loaders/core/registry.py
load_file_preprocessors ¶
load_file_preprocessors(
module_path: str,
attribute_name: str = DEFAULT_PREPROCESSORS_ATTR,
) -> PreprocessorRegistry
Import module_path and return its validated :class:PreprocessorRegistry.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
module_path
|
str
|
dotted import path of the pre-processors module |
required |
attribute_name
|
str
|
name of the attribute on the module (defaults to |
DEFAULT_PREPROCESSORS_ATTR
|
Returns:
| Type | Description |
|---|---|
PreprocessorRegistry
|
the validated file pre-processor registry |
Raises:
| Type | Description |
|---|---|
TypeError
|
if the attribute is neither a dictionary nor a sequence of callables |
ValueError
|
if the registry is empty or uses the reserved |
Source code in src/cdm_data_loaders/core/registry.py
validate_registry_table_names ¶
validate_registry_table_names(
registry_keys: Iterable[str],
valid_tables: Iterable[str],
module_label: str,
) -> None
Raise ValueError if registry_keys contains table names not in valid_tables.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
registry_keys
|
Iterable[str]
|
table names configured in a registry |
required |
valid_tables
|
Iterable[str]
|
valid destination/input table names for the pipeline |
required |
module_label
|
str
|
setting attribute label reported in the error message |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
if |