cdm_data_loaders.core.preprocessors ¶
File-level pre-processors for validating or filtering input files before parsing.
FilePreprocessError ¶
parse_md5_sidecar ¶
Extract the 32-character hex MD5 digest from sidecar file text.
Supports BSD/NCBI format (MD5(file.xml.gz)= <hex>), GNU md5sum format
(<hex> file.xml.gz or <hex> *file.xml.gz), and bare 32-character hex digests.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
content
|
str
|
raw text content of the |
required |
source_file
|
str
|
relative path of the data file being validated |
required |
Returns:
| Type | Description |
|---|---|
str
|
lowercase 32-character hexadecimal MD5 digest |
Raises:
| Type | Description |
|---|---|
FilePreprocessError
|
if |
Source code in src/cdm_data_loaders/core/preprocessors.py
validate_md5_sidecar ¶
Validate file_item against its accompanying <file>.md5 sidecar file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_item
|
FileItemDict
|
dlt file item to validate |
required |
Returns:
| Type | Description |
|---|---|
FileItemDict
|
the validated |
Raises:
| Type | Description |
|---|---|
FilePreprocessError
|
if the sidecar file is missing, unreadable, malformed, or does not match the MD5 digest of the raw file bytes |
Source code in src/cdm_data_loaders/core/preprocessors.py
validate_file_preprocessors ¶
Ensure every table key in settings.file_preprocessors matches a configured input table.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
settings
|
Any
|
pipeline settings instance |
required |
valid_tables
|
Iterable[str]
|
valid destination/input table names for the pipeline |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
if |