dataenginex.core¶
Schemas, validators, medallion architecture, and pipeline configuration.
dataenginex.core
¶
Core framework — schemas, validators, medallion architecture, pipeline config, quality.
Public API::
from dataenginex.core import (
# Medallion
MedallionArchitecture, DataLayer, StorageFormat, LayerConfiguration,
StorageBackend, LocalParquetStorage, BigQueryStorage, DualStorage, DataLineage,
# Pipeline
PipelineConfig, PipelineMetrics,
# Quality
QualityGate, QualityStore, QualityResult, QualityDimension,
# Schemas
JobPosting, JobSourceEnum, UserProfile,
ErrorDetail, ErrorResponse, RootResponse, HealthResponse,
StartupResponse, ComponentStatus, ReadinessResponse,
EchoRequest, EchoResponse,
DataQualityReport, PipelineExecutionMetadata,
# Validators
SchemaValidator, DataQualityChecks, DataHash,
QualityScorer, ValidationReport,
)
BigQueryStorage
¶
Bases: StorageBackend
BigQuery cloud storage implementation.
Source code in packages/dataenginex/src/dataenginex/core/medallion_architecture.py
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 | |
write(data, path, format=StorageFormat.BIGQUERY)
¶
Write data to BigQuery table.
Path format: "dataset.table"
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Any
|
Data to write (dataframe or dict records) |
required |
path
|
str
|
BigQuery path as "dataset.table" |
required |
format
|
StorageFormat
|
Storage format |
BIGQUERY
|
Returns:
| Type | Description |
|---|---|
bool
|
True if successful, False otherwise |
Source code in packages/dataenginex/src/dataenginex/core/medallion_architecture.py
read(path, format=StorageFormat.BIGQUERY)
¶
Read data from BigQuery table.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
BigQuery path as "dataset.table" |
required |
format
|
StorageFormat
|
Storage format |
BIGQUERY
|
Returns:
| Type | Description |
|---|---|
Any
|
Data read from table, or None if failed |
Source code in packages/dataenginex/src/dataenginex/core/medallion_architecture.py
delete(path)
¶
Delete BigQuery table.
Source code in packages/dataenginex/src/dataenginex/core/medallion_architecture.py
list_objects(prefix='')
¶
List BigQuery tables matching prefix (stub).
exists(path)
¶
DataLayer
¶
DataLineage
¶
Tracks data lineage through the medallion layers.
Source code in packages/dataenginex/src/dataenginex/core/medallion_architecture.py
record_bronze_ingestion(source, record_count, timestamp)
¶
Record data entry into Bronze layer.
Source code in packages/dataenginex/src/dataenginex/core/medallion_architecture.py
record_silver_transformation(lineage_id, processed_count, quality_score)
¶
Record data transformation in Silver layer.
Source code in packages/dataenginex/src/dataenginex/core/medallion_architecture.py
record_gold_enrichment(lineage_id, enriched_count, embedding_model)
¶
Record data enrichment in Gold layer.
Source code in packages/dataenginex/src/dataenginex/core/medallion_architecture.py
get_lineage(lineage_id)
¶
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 packages/dataenginex/src/dataenginex/core/medallion_architecture.py
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 435 436 437 | |
write_bronze(data, source, timestamp)
¶
Write to Bronze layer — path: bronze/{source}/{timestamp}.
write_silver(data, entity_type, timestamp)
¶
Write to Silver layer — path: silver/{entity_type}/{timestamp}.
Source code in packages/dataenginex/src/dataenginex/core/medallion_architecture.py
write_gold(data, entity_type, timestamp)
¶
Write to Gold layer — path: gold/{entity_type}/{timestamp}.
read_bronze(source, timestamp)
¶
read_silver(entity_type, timestamp)
¶
LayerConfiguration
dataclass
¶
Configuration for a medallion layer.
Source code in packages/dataenginex/src/dataenginex/core/medallion_architecture.py
__post_init__()
¶
Validate configuration.
LocalParquetStorage
¶
Bases: StorageBackend
Local Parquet file storage implementation.
Source code in packages/dataenginex/src/dataenginex/core/medallion_architecture.py
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 | |
write(data, path, format=StorageFormat.PARQUET)
¶
Write data to local Parquet file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Any
|
Data to write (dict, list, or dataframe) |
required |
path
|
str
|
Relative path from base_path |
required |
format
|
StorageFormat
|
Storage format (must be PARQUET for this backend) |
PARQUET
|
Returns:
| Type | Description |
|---|---|
bool
|
True if successful, False otherwise |
Source code in packages/dataenginex/src/dataenginex/core/medallion_architecture.py
read(path, format=StorageFormat.PARQUET)
¶
Read data from local Parquet file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
Relative path from base_path |
required |
format
|
StorageFormat
|
Storage format |
PARQUET
|
Returns:
| Type | Description |
|---|---|
Any
|
Data read from file, or None if failed |
Source code in packages/dataenginex/src/dataenginex/core/medallion_architecture.py
delete(path)
¶
Delete Parquet file.
Source code in packages/dataenginex/src/dataenginex/core/medallion_architecture.py
list_objects(prefix='')
¶
List files under prefix relative to base_path.
Source code in packages/dataenginex/src/dataenginex/core/medallion_architecture.py
MedallionArchitecture
¶
Manages the three-layer medallion architecture for DEX.
Source code in packages/dataenginex/src/dataenginex/core/medallion_architecture.py
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 packages/dataenginex/src/dataenginex/core/medallion_architecture.py
write(data, path, format)
abstractmethod
¶
Write data to path in the given format.
Returns True on success, False on failure.
Source code in packages/dataenginex/src/dataenginex/core/medallion_architecture.py
read(path, format)
abstractmethod
¶
delete(path)
abstractmethod
¶
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 packages/dataenginex/src/dataenginex/core/medallion_architecture.py
StorageFormat
¶
PipelineConfig
¶
Configuration for DEX data pipelines.
Source code in packages/dataenginex/src/dataenginex/core/pipeline_config.py
PipelineMetrics
¶
Metrics tracking for pipeline monitoring.
Source code in packages/dataenginex/src/dataenginex/core/pipeline_config.py
QualityDimension
¶
Bases: StrEnum
Named quality dimensions tracked by the quality framework.
Source code in packages/dataenginex/src/dataenginex/core/quality.py
QualityGate
¶
Orchestrates quality checks at medallion layer transitions.
Combines DataProfiler, DataQualityChecks, and QualityScorer
to produce a single pass/fail QualityResult for a batch of records.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
store
|
QualityStore | None
|
Optional |
None
|
profiler
|
DataProfiler | None
|
Optional |
None
|
Source code in packages/dataenginex/src/dataenginex/core/quality.py
171 172 173 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 | |
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 (QualityScorer).
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
|
Field names required for completeness check.
Falls back to |
None
|
dataset_name
|
str
|
Name passed to the profiler. |
'batch'
|
Returns:
| Type | Description |
|---|---|
QualityResult
|
A |
Source code in packages/dataenginex/src/dataenginex/core/quality.py
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 | |
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 packages/dataenginex/src/dataenginex/core/quality.py
to_dict()
¶
Serialise the result to a plain dictionary.
Source code in packages/dataenginex/src/dataenginex/core/quality.py
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 packages/dataenginex/src/dataenginex/core/quality.py
record(result)
¶
Persist a quality result for its layer.
Source code in packages/dataenginex/src/dataenginex/core/quality.py
latest(layer)
¶
Return the most recent result for layer, or None.
summary()
¶
Return a quality summary across all layers.
The shape matches the /api/v1/data/quality response contract.
Source code in packages/dataenginex/src/dataenginex/core/quality.py
history(layer, limit=10)
¶
Return the last limit results for layer as dicts.
Source code in packages/dataenginex/src/dataenginex/core/quality.py
ComponentStatus
¶
Bases: BaseModel
Health status of a single dependency component.
Source code in packages/dataenginex/src/dataenginex/core/schemas.py
DataQualityReport
¶
Bases: BaseModel
Data quality check results (Issue #33)
Source code in packages/dataenginex/src/dataenginex/core/schemas.py
EchoRequest
¶
Bases: BaseModel
Request body for the /echo debug endpoint.
Source code in packages/dataenginex/src/dataenginex/core/schemas.py
EchoResponse
¶
Bases: BaseModel
Response body for the /echo debug endpoint.
Source code in packages/dataenginex/src/dataenginex/core/schemas.py
ErrorDetail
¶
Bases: BaseModel
Detail of a single validation or processing error.
Source code in packages/dataenginex/src/dataenginex/core/schemas.py
ErrorResponse
¶
Bases: BaseModel
Standard error response returned by all API error handlers.
Source code in packages/dataenginex/src/dataenginex/core/schemas.py
HealthResponse
¶
Bases: BaseModel
Response body for the /health liveness probe.
Source code in packages/dataenginex/src/dataenginex/core/schemas.py
JobPosting
¶
Bases: BaseModel
Core job posting schema for CareerDEX (Silver layer)
Source code in packages/dataenginex/src/dataenginex/core/schemas.py
JobSourceEnum
¶
Bases: StrEnum
Supported external data sources (project-specific enumeration)
Source code in packages/dataenginex/src/dataenginex/core/schemas.py
PipelineExecutionMetadata
¶
Bases: BaseModel
Tracks pipeline execution for lineage and troubleshooting (Issue #34)
Source code in packages/dataenginex/src/dataenginex/core/schemas.py
ReadinessResponse
¶
Bases: BaseModel
Response body for the /ready readiness probe.
Source code in packages/dataenginex/src/dataenginex/core/schemas.py
RootResponse
¶
Bases: BaseModel
Response body for the root / endpoint.
Source code in packages/dataenginex/src/dataenginex/core/schemas.py
StartupResponse
¶
Bases: BaseModel
Response body for the /startup probe.
Source code in packages/dataenginex/src/dataenginex/core/schemas.py
UserProfile
¶
Bases: BaseModel
CareerDEX user profile schema
Source code in packages/dataenginex/src/dataenginex/core/schemas.py
DataHash
¶
Generates content hashes for deduplication (DEX requirement).
Source code in packages/dataenginex/src/dataenginex/core/validators.py
generate_job_hash(job_id, source, company_name, job_title)
staticmethod
¶
Generate a hash for job posting content to identify duplicates. Uses job_id + source + company + title as content identifier.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
job_id
|
str
|
Source job ID |
required |
source
|
str
|
Job source (linkedin, indeed, etc.) |
required |
company_name
|
str
|
Company name |
required |
job_title
|
str
|
Job title |
required |
Returns:
| Type | Description |
|---|---|
str
|
SHA256 hash of content |
Source code in packages/dataenginex/src/dataenginex/core/validators.py
generate_user_hash(email, first_name, last_name)
staticmethod
¶
Generate a hash for user profile to identify duplicates.
Returns:
| Type | Description |
|---|---|
str
|
SHA256 hash of user identity |
Source code in packages/dataenginex/src/dataenginex/core/validators.py
DataQualityChecks
¶
Implements data quality checks across multiple dimensions.
Source code in packages/dataenginex/src/dataenginex/core/validators.py
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 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 172 173 174 175 176 177 178 179 180 181 182 | |
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 packages/dataenginex/src/dataenginex/core/validators.py
check_accuracy_salary(salary_min, salary_max)
staticmethod
¶
Check salary range accuracy and reasonableness.
Returns:
| Type | Description |
|---|---|
tuple[bool, list[str]]
|
Tuple of (is_accurate, issues) |
Source code in packages/dataenginex/src/dataenginex/core/validators.py
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 packages/dataenginex/src/dataenginex/core/validators.py
check_uniqueness_job_id(current_id, seen_ids)
staticmethod
¶
Check if job ID is unique in the batch.
Returns:
| Type | Description |
|---|---|
tuple[bool, str]
|
Tuple of (is_unique, issue_message) |
Source code in packages/dataenginex/src/dataenginex/core/validators.py
check_validity_location(country, city, latitude=None, longitude=None)
staticmethod
¶
Check location validity.
Returns:
| Type | Description |
|---|---|
tuple[bool, list[str]]
|
Tuple of (is_valid, issues) |
Source code in packages/dataenginex/src/dataenginex/core/validators.py
QualityScorer
¶
Calculates quality scores for data records.
Source code in packages/dataenginex/src/dataenginex/core/validators.py
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 357 | |
score_job_posting(record)
staticmethod
¶
Calculate quality score for job posting (0-1 scale).
Scoring criteria: - Has salary range: +0.1 - Has location details: +0.1 - Has skill requirements: +0.15 - Has job description (>200 chars): +0.2 - Has reasonable dates: +0.1 - Has company info: +0.1 - Has employment type: +0.1 - Has benefits listed: +0.05
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
record
|
dict[str, Any]
|
Job posting record |
required |
Returns:
| Type | Description |
|---|---|
float
|
Quality score (0.0 - 1.0) |
Source code in packages/dataenginex/src/dataenginex/core/validators.py
score_user_profile(record)
staticmethod
¶
Calculate quality score for user profile (0-1 scale).
Scoring criteria: - Has email: +0.15 - Has name: +0.1 - Has professional info: +0.2 - Has skills: +0.15 - Has experience: +0.1 - Has preferences: +0.15 - Profile completion >50%: +0.15
Returns:
| Type | Description |
|---|---|
float
|
Quality score (0.0 - 1.0) |
Source code in packages/dataenginex/src/dataenginex/core/validators.py
SchemaValidator
¶
Validates that data conforms to DEX schema specifications.
Source code in packages/dataenginex/src/dataenginex/core/validators.py
validate_job_posting(data)
staticmethod
¶
Validate job posting data against JobPosting schema.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Mapping[str, Any]
|
Dictionary containing job posting data |
required |
Returns:
| Type | Description |
|---|---|
tuple[bool, list[str]]
|
Tuple of (is_valid, error_messages) |
Source code in packages/dataenginex/src/dataenginex/core/validators.py
validate_user_profile(data)
staticmethod
¶
Validate user profile data against schema.
Source code in packages/dataenginex/src/dataenginex/core/validators.py
ValidationReport
¶
Generates validation reports for data quality assessment.
Source code in packages/dataenginex/src/dataenginex/core/validators.py
add_error(record_id, error_type, message)
¶
Record a validation error.
Source code in packages/dataenginex/src/dataenginex/core/validators.py
add_warning(record_id, warning_type, message)
¶
Record a validation warning.
mark_valid()
¶
finalize()
¶
Generate final validation report.