dataenginex.core
Core framework — schemas, validators, medallion architecture, quality.
Domain-specific symbols should live in the application package
(e.g. myapp.core).
Public API::
from dataenginex.core import (
# Medallion
MedallionArchitecture, DataLayer, StorageFormat, LayerConfiguration,
StorageBackend, LocalParquetStorage, BigQueryStorage, DualStorage,
DataLineage,
# Quality
QualityGate, QualityStore, QualityResult, QualityDimension,
# Schemas (generic API)
ErrorDetail, ErrorResponse, RootResponse, HealthResponse,
StartupResponse, ComponentStatus, ReadinessResponse,
EchoRequest, EchoResponse,
# Validators (generic)
DataQualityChecks, ValidationReport,
)
BigQueryStorage
Bases: StorageBackend
BigQuery cloud storage — re-exported from :mod:dataenginex.lakehouse.storage.
This is a backwards-compatibility shim. The real implementation
lives in dataenginex.lakehouse.storage.BigQueryStorage.
Source code in src/dataenginex/core/medallion_architecture.py
319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 | |
DataLayer
Bases: StrEnum
Medallion architecture layers
Source code in src/dataenginex/core/medallion_architecture.py
52 53 54 55 56 57 | |
DataLineage
Tracks data lineage through the medallion layers.
Source code in src/dataenginex/core/medallion_architecture.py
437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 | |
record_bronze_ingestion(source, record_count, timestamp)
Record data entry into Bronze layer.
Source code in src/dataenginex/core/medallion_architecture.py
443 444 445 446 447 448 449 450 451 452 453 | |
record_silver_transformation(lineage_id, processed_count, quality_score)
Record data transformation in Silver layer.
Source code in src/dataenginex/core/medallion_architecture.py
455 456 457 458 459 460 461 462 463 464 465 466 467 | |
record_gold_enrichment(lineage_id, enriched_count, embedding_model)
Record data enrichment in Gold layer.
Source code in src/dataenginex/core/medallion_architecture.py
469 470 471 472 473 474 475 476 477 478 479 480 481 | |
get_lineage(lineage_id)
Get lineage information for a record.
Source code in src/dataenginex/core/medallion_architecture.py
483 484 485 | |
DualStorage
Manages dual storage strategy: local Parquet + BigQuery.
Pattern: - Development/Testing: Write to local Parquet - Production/Cloud: Write to both local (backup) and BigQuery (primary)
Source code in src/dataenginex/core/medallion_architecture.py
354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 | |
write_bronze(data, source, timestamp)
Write to Bronze layer — path: bronze/{source}/{timestamp}.
Source code in src/dataenginex/core/medallion_architecture.py
412 413 414 | |
write_silver(data, entity_type, timestamp)
Write to Silver layer — path: silver/{entity_type}/{timestamp}.
Source code in src/dataenginex/core/medallion_architecture.py
416 417 418 | |
write_gold(data, entity_type, timestamp)
Write to Gold layer — path: gold/{entity_type}/{timestamp}.
Source code in src/dataenginex/core/medallion_architecture.py
420 421 422 | |
read_bronze(source, timestamp)
Read from Bronze layer.
Source code in src/dataenginex/core/medallion_architecture.py
424 425 426 | |
read_silver(entity_type, timestamp)
Read from Silver layer.
Source code in src/dataenginex/core/medallion_architecture.py
428 429 430 | |
read_gold(entity_type, timestamp)
Read from Gold layer.
Source code in src/dataenginex/core/medallion_architecture.py
432 433 434 | |
LayerConfiguration
dataclass
Configuration for a medallion layer.
Source code in src/dataenginex/core/medallion_architecture.py
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | |
__post_init__()
Validate configuration.
Source code in src/dataenginex/core/medallion_architecture.py
75 76 77 78 | |
LocalParquetStorage
Bases: StorageBackend
Local Parquet file storage backed by pyarrow.
Raises RuntimeError if pyarrow is not installed.
Source code in src/dataenginex/core/medallion_architecture.py
192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 | |
write(data, path, format=StorageFormat.PARQUET)
Write data to a local Parquet file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Any
|
List of dicts, or a pyarrow Table. |
required |
path
|
str
|
Relative path from base_path. |
required |
format
|
StorageFormat
|
Must be |
PARQUET
|
Returns:
| Type | Description |
|---|---|
bool
|
True on success. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If format is not PARQUET. |
RuntimeError
|
If pyarrow is not installed. |
Source code in src/dataenginex/core/medallion_architecture.py
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 | |
read(path, format=StorageFormat.PARQUET)
Read data from a local Parquet file.
Returns:
| Type | Description |
|---|---|
list[dict[str, Any]] | None
|
List of record dicts, or None if the file doesn't exist. |
Source code in src/dataenginex/core/medallion_architecture.py
267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 | |
delete(path)
Delete a Parquet file from disk.
Source code in src/dataenginex/core/medallion_architecture.py
293 294 295 296 297 298 299 300 301 302 303 304 305 | |
list_objects(prefix='')
List files under prefix relative to base_path.
Source code in src/dataenginex/core/medallion_architecture.py
307 308 309 310 311 312 | |
exists(path)
Return True if path exists on disk.
Source code in src/dataenginex/core/medallion_architecture.py
314 315 316 | |
MedallionArchitecture
Manages the three-layer medallion architecture for DEX.
Source code in src/dataenginex/core/medallion_architecture.py
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 | |
get_layer_config(layer)
classmethod
Get configuration for a specific layer.
Source code in src/dataenginex/core/medallion_architecture.py
126 127 128 129 130 131 132 133 134 | |
get_all_layers()
classmethod
Get configurations for all layers in order.
Source code in src/dataenginex/core/medallion_architecture.py
136 137 138 139 | |
StorageBackend
Bases: ABC
Abstract storage backend interface.
All lakehouse storage implementations must subclass this and provide
concrete write, read, delete, list_objects, and
exists methods. The interface accepts a StorageFormat hint
so backends can choose serialisation.
Built-in implementations
LocalParquetStorage— local Parquet files (this module)BigQueryStorage— Google BigQuery tables (this module)JsonStorage— JSON files (dataenginex.lakehouse.storage)ParquetStorage— pyarrow-backed Parquet (dataenginex.lakehouse.storage)S3Storage— AWS S3 object storage (dataenginex.lakehouse.storage)GCSStorage— Google Cloud Storage (dataenginex.lakehouse.storage)
Source code in src/dataenginex/core/medallion_architecture.py
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 | |
write(data, path, format)
abstractmethod
Write data to path in the given format.
Returns True on success, False on failure.
Source code in src/dataenginex/core/medallion_architecture.py
159 160 161 162 163 164 165 | |
read(path, format)
abstractmethod
Read data from path. Returns None on failure.
Source code in src/dataenginex/core/medallion_architecture.py
167 168 169 170 | |
delete(path)
abstractmethod
Delete the resource at path. Returns True on success.
Source code in src/dataenginex/core/medallion_architecture.py
172 173 174 175 | |
list_objects(prefix='')
abstractmethod
List object paths under prefix.
Returns a list of relative paths. Empty list on failure or when no objects match.
Source code in src/dataenginex/core/medallion_architecture.py
177 178 179 180 181 182 183 184 | |
exists(path)
abstractmethod
Return True if path exists in the backend.
Source code in src/dataenginex/core/medallion_architecture.py
186 187 188 189 | |
StorageFormat
Bases: StrEnum
Supported storage formats
Source code in src/dataenginex/core/medallion_architecture.py
43 44 45 46 47 48 49 | |
QualityDimension
Bases: StrEnum
Named quality dimensions tracked by the quality framework.
Source code in src/dataenginex/core/quality.py
51 52 53 54 55 56 57 58 | |
QualityGate
Orchestrates quality checks at medallion layer transitions.
The gate is domain-agnostic: callers inject a scoring function,
required fields, and a uniqueness key to customise evaluation for their
data model. When none are supplied the gate still computes completeness,
uniqueness, and consistency but accuracy defaults to 0.0.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
store
|
QualityStore | None
|
Optional |
None
|
profiler
|
DataProfiler | None
|
Optional |
None
|
scorer
|
Callable[[dict[str, Any]], float] | None
|
Optional callable |
None
|
required_fields
|
set[str] | None
|
Field names required for the completeness check.
If |
None
|
uniqueness_key
|
str
|
Record key used for uniqueness checks
(default |
'id'
|
Source code in src/dataenginex/core/quality.py
174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 | |
store
property
Return the attached quality store, if any.
evaluate(records, layer, *, required_fields=None, dataset_name='batch')
Evaluate a batch of records against a layer's quality threshold.
Steps performed:
1. Profile the dataset (DataProfiler).
2. Check completeness for each record (DataQualityChecks).
3. Score each record via the injected scorer (accuracy).
4. Check uniqueness across the batch.
5. Compute per-dimension averages and overall score.
6. Compare overall score to the layer's quality_threshold.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
records
|
list[dict[str, Any]]
|
List of record dicts to evaluate. |
required |
layer
|
DataLayer
|
Target |
required |
required_fields
|
set[str] | None
|
Override per-call required fields.
Falls back to constructor |
None
|
dataset_name
|
str
|
Name passed to the profiler. |
'batch'
|
Returns:
| Type | Description |
|---|---|
QualityResult
|
A |
Source code in src/dataenginex/core/quality.py
257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 | |
QualityResult
dataclass
Immutable result of evaluating a batch through a QualityGate.
Attributes:
| Name | Type | Description |
|---|---|---|
passed |
bool
|
Whether the batch met the layer's quality threshold. |
layer |
str
|
Target medallion layer that was evaluated. |
quality_score |
float
|
Overall quality score (0.0–1.0). |
threshold |
float
|
Layer threshold the batch was compared against. |
record_count |
int
|
Number of records in the batch. |
valid_count |
int
|
Number of records that passed schema validation. |
dimensions |
dict[str, float]
|
Per-dimension scores. |
profile |
ProfileReport | None
|
Optional |
evaluated_at |
datetime
|
Timestamp of the evaluation. |
Source code in src/dataenginex/core/quality.py
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | |
to_dict()
Serialise the result to a plain dictionary.
Source code in src/dataenginex/core/quality.py
87 88 89 90 91 92 93 94 95 96 97 98 | |
QualityStore
In-memory store that accumulates quality metrics per medallion layer.
Each call to :meth:record appends a snapshot. :meth:summary returns
the latest-known scores across all layers, suitable for the
/api/v1/data/quality endpoint.
Source code in src/dataenginex/core/quality.py
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 | |
record(result)
Persist a quality result for its layer.
Source code in src/dataenginex/core/quality.py
116 117 118 119 120 121 122 123 124 125 126 127 | |
latest(layer)
Return the most recent result for layer, or None.
Source code in src/dataenginex/core/quality.py
129 130 131 132 | |
summary()
Return a quality summary across all layers.
The shape matches the /api/v1/data/quality response contract.
Source code in src/dataenginex/core/quality.py
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 | |
history(layer, limit=10)
Return the last limit results for layer as dicts.
Source code in src/dataenginex/core/quality.py
168 169 170 171 | |
ComponentStatus
Bases: BaseModel
Health status of a single dependency component.
Source code in src/dataenginex/core/schemas.py
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | |
EchoRequest
Bases: BaseModel
Request body for the /echo debug endpoint.
Source code in src/dataenginex/core/schemas.py
153 154 155 156 157 158 159 | |
EchoResponse
Bases: BaseModel
Response body for the /echo debug endpoint.
Source code in src/dataenginex/core/schemas.py
162 163 164 165 166 167 168 169 170 171 172 173 | |
ErrorDetail
Bases: BaseModel
Detail of a single validation or processing error.
Source code in src/dataenginex/core/schemas.py
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 | |
ErrorResponse
Bases: BaseModel
Standard error response returned by all API error handlers.
Source code in src/dataenginex/core/schemas.py
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 | |
HealthResponse
Bases: BaseModel
Response body for the /health liveness probe.
Source code in src/dataenginex/core/schemas.py
36 37 38 39 40 41 | |
ReadinessResponse
Bases: BaseModel
Response body for the /ready readiness probe.
Source code in src/dataenginex/core/schemas.py
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | |
RootResponse
Bases: BaseModel
Response body for the root / endpoint.
Source code in src/dataenginex/core/schemas.py
25 26 27 28 29 30 31 32 33 | |
StartupResponse
Bases: BaseModel
Response body for the /startup probe.
Source code in src/dataenginex/core/schemas.py
44 45 46 47 48 49 | |
DataQualityChecks
Generic data quality checks — not tied to any domain schema.
Source code in src/dataenginex/core/validators.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | |
check_completeness(record, required_fields)
staticmethod
Check that all required fields are present and non-null.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
record
|
dict[str, Any]
|
Data record to check. |
required |
required_fields
|
set[str]
|
Set of field names that must be present. |
required |
Returns:
| Type | Description |
|---|---|
tuple[bool, list[str]]
|
Tuple of (is_complete, missing_fields). |
Source code in src/dataenginex/core/validators.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | |
check_consistency_dates(posted_date, last_modified_date, expiration_date=None)
staticmethod
Check temporal consistency of dates.
Returns:
| Type | Description |
|---|---|
tuple[bool, list[str]]
|
Tuple of (is_consistent, issues). |
Source code in src/dataenginex/core/validators.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | |
ValidationReport
Generates validation reports for data quality assessment.
Source code in src/dataenginex/core/validators.py
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | |
add_error(record_id, error_type, message)
Record a validation error.
Source code in src/dataenginex/core/validators.py
78 79 80 81 | |
add_warning(record_id, warning_type, message)
Record a validation warning.
Source code in src/dataenginex/core/validators.py
83 84 85 | |
mark_valid()
Mark a record as valid.
Source code in src/dataenginex/core/validators.py
87 88 89 | |
finalize()
Generate final validation report.
Source code in src/dataenginex/core/validators.py
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | |