medallantic API¶
Status: Available in ETLantic 0.41.0. Medallion facade + SparkForge migrate. Install narrative: package README. Hub: Optional packages API.
Setup¶
Failure modes¶
| Topic | Behavior |
|---|---|
| IR convertibility | MDL210 manual; MDL220 unsupported |
Public API¶
medallantic
¶
Medallantic — engine-agnostic medallion pipelines built on ETLantic.
AdaptationResult
dataclass
¶
AdaptationResult(pipeline_cls: type[Pipeline], profile: Profile, validation_policy: ValidationPolicy, write_intents: tuple[WriteIntent, ...] = (), step_map: dict[str, str] = dict(), layer_by_node: dict[str, str] = dict(), diagnostics: tuple[Diagnostic, ...] = (), metadata: dict[str, Any] = dict(), required_delta_operations: tuple[str, ...] = ())
Result of adapting a SparkForge pipeline IR.
AdapterError
¶
Bases: Exception
Raised when SparkForge → ETLantic adaptation fails closed.
Bronze
¶
Bronze(*, asset: str | None = None, source: str | None = None, write_mode: str | None = None, transform_ref: str | None = None, rules: dict[str, Any] | None = None, description: str | None = None, tags: tuple[str, ...] | list[str] | None = None, kind: str | None = None, metadata: dict[str, Any] | None = None, name: str | None = None)
Gold
¶
MedallionPipeline
¶
Class-style native medallion authoring.
Subclass and declare Bronze / Silver / Gold attributes, then call
to_definition() or lower().
to_document
classmethod
¶
Return the facade-owned medallion document for this class.
from_dict
classmethod
¶
Build an anonymous MedallionPipeline subclass from a document dict.
lower
classmethod
¶
Lower this pipeline onto ETLantic Pipeline / definition surfaces.
to_definition
classmethod
¶
Return a sealed public PipelineDefinition.
Silver
¶
MedallionBuilder
¶
LayerKind
¶
Bases: StrEnum
SparkForge medallion layer (adapter-only vocabulary).
SparkForgePipelineSpec
dataclass
¶
SparkForgePipelineSpec(name: str, schema: str = 'default', steps: tuple[SparkForgeStepSpec, ...] = (), min_bronze_rate: float = 90.0, min_silver_rate: float = 95.0, min_gold_rate: float = 98.0, engine: str = 'spark', legacy_engine_extensions: tuple[str, ...] = (), metadata: dict[str, Any] = dict())
Complete SparkForge pipeline description (fixture-friendly).
parse
classmethod
¶
Parse IR and return any coercion / hygiene diagnostics.
SparkForgeStepSpec
dataclass
¶
SparkForgeStepSpec(name: str, kind: StepKind, layer: LayerKind, source: str | None = None, table_name: str | None = None, transform_ref: str | None = None, rules: dict[str, Any] = dict(), write_mode: str | None = None, metadata: dict[str, Any] = dict())
One SparkForge step in secret-free form.
StepKind
¶
Bases: StrEnum
SparkForge step kinds represented in the compatibility IR.
LoweringError
¶
Bases: Exception
Raised when medallion → ETLantic lowering fails closed.
LoweringResult
dataclass
¶
LoweringResult(pipeline_cls: type[Pipeline], profile: Profile, validation_policy: ValidationPolicy, write_intents: tuple[WriteIntent, ...] = (), step_map: dict[str, str] = dict(), layer_by_node: dict[str, str] = dict(), diagnostics: tuple[Diagnostic, ...] = (), metadata: dict[str, Any] = dict(), required_delta_operations: tuple[str, ...] = ())
MedallionRow
¶
Bases: Data
Generic row contract for medallion planning/parity (passthrough).
RuleDSLError
¶
Bases: ValueError
Raised when a Medallantic rules shorthand cannot be parsed.
MedallionDocument
dataclass
¶
MedallionDocument(name: str, schema: str = 'default', steps: tuple[MedallionStep, ...] = (), min_bronze_rate: float = 90.0, min_silver_rate: float = 95.0, min_gold_rate: float = 98.0, engine: str = 'local', description: str | None = None, tags: tuple[str, ...] = (), metadata: dict[str, Any] = dict())
Declarative medallion pipeline document owned by Medallantic.
MedallionStep
dataclass
¶
MedallionStep(name: str, layer: str, kind: str, source: str | None = None, asset: str | None = None, transform_ref: str | None = None, rules: dict[str, Any] = dict(), write_mode: str | None = None, description: str | None = None, tags: tuple[str, ...] = (), metadata: dict[str, Any] = dict())
One bronze, silver, or gold step in a medallion document.
adapt_pipeline
¶
adapt_pipeline(spec: SparkForgePipelineSpec, *, capabilities: PluginCapabilities | None = None, strict_delta: bool = True) -> AdaptationResult
Map a SparkForge pipeline IR to a concrete ETLantic Pipeline subclass.
adapt_profile
¶
adapt_profile(spec: SparkForgePipelineSpec, *, name: str | None = None, bindings: dict[str, str] | None = None) -> Profile
Build an ETLantic Profile from SparkForge builder config.
adapt_validation_policy
¶
Map layer thresholds onto a named ValidationPolicy (metadata only).
enrich_plan
¶
Place serialized write intents under plan.intents['write_intents'].
from_document
¶
Create an anonymous MedallionPipeline subclass from a document.
Raises:
| Type | Description |
|---|---|
ValueError
|
When a step declares a layer outside bronze/silver/gold. |
assert_delta_capabilities
¶
assert_delta_capabilities(operations: list[str], *, capabilities: PluginCapabilities | None = None, strict: bool = True) -> list[Diagnostic]
Fail closed when declared Delta ops are unsupported by capabilities.
When capabilities is None and strict is True (default), emit errors
so callers must supply a plugin that supports spark_delta before
execution. When strict is False (plan-only), emit warnings instead.
retry_policy_from_sparkforge
¶
Normalize SparkForge retry config into ETLantic RetryPolicy.
write_mode_from_sparkforge
¶
Map a SparkForge write-mode string to ETLantic WriteMode.
write_mode_metadata
¶
Extra write-mode metadata preserved when modes collapse (e.g. partitions).
explain_medallion_plan
¶
explain_medallion_plan(plan: PipelinePlan, *, definition: PipelineDefinition | None = None) -> dict[str, Any]
Merge core plan explain with medallion layer and lifecycle metadata.
enrich_lifecycle_event
¶
enrich_lifecycle_event(event: LifecycleEvent | SecurityEvent, layer_by_node: dict[str, str]) -> LifecycleEvent | SecurityEvent
Attach medallion layer annotation when step is known.
layer_run_summary
¶
Summarize run report steps grouped by medallion layer.
lower_document
¶
lower_document(doc: MedallionDocument, *, required_delta_operations: tuple[str, ...] = (), diagnostic_phase: str = 'medallion_authoring', allowed_transform_refs: tuple[str, ...] | None = None, transform_refs_fail_closed: bool = False, profile: Profile | None = None) -> LoweringResult
Map a medallion document to a concrete ETLantic Pipeline subclass.
Bronze/silver/gold remain facade metadata on layer_by_node; ETLantic
core never sees medallion enums.
Importable transform_ref values are deny-by-default when
transform_refs_fail_closed is True or when profile.security_mode is
production. Pass allowed_transform_refs (or profile metadata
medallantic.allowed_transform_refs) to permit specific callables.
medallion_development_profile
¶
Development profile with medallion observability defaults.
medallion_production_profile
¶
Production template — requires explicit plugin allowlist before deploy.
medallion_test_profile
¶
Test profile with strict validation and in-memory history.
adapt_run_result
¶
adapt_run_result(payload: dict[str, Any], *, pipeline_id: str | None = None, profile: str = 'medallantic') -> PipelineRunReport
Convert a SparkForge-shaped result dict into PipelineRunReport.
Never retains secret-like keys or free-text credentials from the source
payload. Unknown run statuses fail closed to failed with diagnostic
PMSF500.
enforce_accept_rates
¶
enforce_accept_rates(report: PipelineRunReport, *, policy_metadata: dict[str, Any], layer_by_node: dict[str, str] | None = None) -> PipelineRunReport
Fail a successful report when accept-rate thresholds are violated.
Returns the original report when thresholds pass or are absent. On
violation, returns a replaced report with FAILED status and
MDL120 diagnostics.
evaluate_accept_rates
¶
evaluate_accept_rates(*, policy_metadata: dict[str, Any], validations: list[ValidationResult] | list[dict[str, Any]], layer: str | None = None) -> list[dict[str, Any]]
Compare validation accept rates against Medallantic layer thresholds.
Threshold keys live on ValidationPolicy.metadata as
min_accept_rate_{ingest,clean,publish} (bronze/silver/gold).
Returns a list of findings; empty when thresholds are satisfied or absent.
report_to_sparkforge_explain
¶
Dual-reporting helper: ETLantic report → SparkForge-shaped explain dict.
parse_rules_shorthand
¶
Parse column→shorthand lists into a portable quality ruleset.
Supported shorthands (strings)::
not_null
unique / uniqueness
regex:<pattern>
length:min:max | min_length:N | max_length:N
in:a|b|c
range:min:max
ge:N / le:N / gt:N / lt:N / eq:N / ne:N
custom:<name>
Structured dict forms are also accepted per entry.
bind_debug_session
¶
Return an ETLantic DebugSession for an adapted pipeline class.
debug_request_from_sparkforge
¶
debug_request_from_sparkforge(*, mode: str | None = 'standard', run_until: str | None = None, run_one: str | None = None, run_from: str | None = None, skip_writes: bool = False, materialization: MaterializationPolicy | None = None, retry: dict[str, Any] | RetryPolicy | None = None, parameter_overrides: dict[str, dict[str, Any]] | None = None, implementation_overrides: dict[str, str] | None = None, invalidation: str | InvalidationMode | None = None) -> RunRequest
Build a RunRequest from SparkForge debug/session options.
skip_writes sets no_write=True only. Materialization stays
DEFAULT unless the caller passes materialization= explicitly.
VALIDATE intent also sets no_write=True.
intent_from_sparkforge
¶
Map SparkForge run-mode strings to RunIntent.
selection_from_sparkforge
¶
selection_from_sparkforge(*, run_until: str | None = None, run_one: str | None = None, run_from: str | None = None) -> RunSelection
Map SparkForge selective-execution flags to RunSelection.
adapt
¶
Lower SparkForge IR onto ETLantic via shared Medallantic lowering.
The public migrate namespace is medallantic.migrate.sparkforge. Top-level
medallantic.adapt / medallantic.ir remain compatibility re-exports.
MedallionRow
¶
Bases: Data
Generic row contract for medallion planning/parity (passthrough).
AdapterError
¶
Bases: Exception
Raised when SparkForge → ETLantic adaptation fails closed.
AdaptationResult
dataclass
¶
AdaptationResult(pipeline_cls: type[Pipeline], profile: Profile, validation_policy: ValidationPolicy, write_intents: tuple[WriteIntent, ...] = (), step_map: dict[str, str] = dict(), layer_by_node: dict[str, str] = dict(), diagnostics: tuple[Diagnostic, ...] = (), metadata: dict[str, Any] = dict(), required_delta_operations: tuple[str, ...] = ())
Result of adapting a SparkForge pipeline IR.
enrich_plan
¶
Place serialized write intents under plan.intents['write_intents'].
adapt_profile
¶
adapt_profile(spec: SparkForgePipelineSpec, *, name: str | None = None, bindings: dict[str, str] | None = None) -> Profile
Build an ETLantic Profile from SparkForge builder config.
adapt_validation_policy
¶
Map layer thresholds onto a named ValidationPolicy (metadata only).
spec_to_document
¶
Convert SparkForge IR into the shared MedallionDocument.
adapt_pipeline
¶
adapt_pipeline(spec: SparkForgePipelineSpec, *, capabilities: PluginCapabilities | None = None, strict_delta: bool = True) -> AdaptationResult
Map a SparkForge pipeline IR to a concrete ETLantic Pipeline subclass.
authoring
¶
Native MedallionPipeline class authoring surfaces.
LayerStep
¶
LayerStep(*, asset: str | None = None, source: str | None = None, write_mode: str | None = None, transform_ref: str | None = None, rules: dict[str, Any] | None = None, description: str | None = None, tags: tuple[str, ...] | list[str] | None = None, kind: str | None = None, metadata: dict[str, Any] | None = None, name: str | None = None)
Base descriptor for bronze/silver/gold class attributes.
Bronze
¶
Bronze(*, asset: str | None = None, source: str | None = None, write_mode: str | None = None, transform_ref: str | None = None, rules: dict[str, Any] | None = None, description: str | None = None, tags: tuple[str, ...] | list[str] | None = None, kind: str | None = None, metadata: dict[str, Any] | None = None, name: str | None = None)
Silver
¶
Gold
¶
MedallionPipeline
¶
Class-style native medallion authoring.
Subclass and declare Bronze / Silver / Gold attributes, then call
to_definition() or lower().
to_document
classmethod
¶
Return the facade-owned medallion document for this class.
from_dict
classmethod
¶
Build an anonymous MedallionPipeline subclass from a document dict.
lower
classmethod
¶
Lower this pipeline onto ETLantic Pipeline / definition surfaces.
to_definition
classmethod
¶
Return a sealed public PipelineDefinition.
from_document
¶
Create an anonymous MedallionPipeline subclass from a document.
Raises:
| Type | Description |
|---|---|
ValueError
|
When a step declares a layer outside bronze/silver/gold. |
builder
¶
Fluent MedallionBuilder for native medallion authoring.
MedallionBuilder
¶
callables
¶
Resolve Medallantic transform_ref callables into ETLantic Transformations.
resolve_transform_callable
¶
resolve_transform_callable(transform_ref: str, *, allowed_refs: Collection[str] | None = None, fail_closed: bool = False) -> Callable[..., Any]
Import module:attr or module.attr and return the callable.
When fail_closed is True, imports are denied unless allowed_refs
explicitly lists the reference (deny-by-default). When allowed_refs is
provided without fail_closed, only listed refs are permitted.
make_callable_transformation
¶
make_callable_transformation(name: str, *, transform_ref: str, fn: Callable[..., Any] | None = None, row_type: type[Any], allowed_refs: Collection[str] | None = None, fail_closed: bool = False) -> type[Transformation]
Build a Transformation that executes transform_ref on local records.
column_rules
¶
Non-portable PySpark Column / callable quality rules (Medallantic-only).
These rules are not part of etlantic.quality/1. They require the
quality.pyspark_column engine capability and fail closed with MDL130
when the selected engine cannot execute them.
NativeColumnRule
dataclass
¶
NativeColumnRule(field: str, kind: str, expr_ref: str | None = None, required: bool = True, metadata: dict[str, Any] = field(default_factory=dict))
One engine-native Column / callable validator (secret-free metadata).
is_native_rule_entry
¶
Return True when a rule entry is a PySpark Column / native callable.
split_portable_and_native_rules
¶
split_portable_and_native_rules(rules: dict[str, Any] | None) -> tuple[dict[str, Any], list[NativeColumnRule]]
Partition a rules mapping into portable shorthand and native Column rules.
compat
¶
SQL / Spark / Delta / write-policy compatibility mappings.
write_mode_from_sparkforge
¶
Map a SparkForge write-mode string to ETLantic WriteMode.
write_mode_metadata
¶
Extra write-mode metadata preserved when modes collapse (e.g. partitions).
retry_policy_from_sparkforge
¶
Normalize SparkForge retry config into ETLantic RetryPolicy.
assert_delta_capabilities
¶
assert_delta_capabilities(operations: list[str], *, capabilities: PluginCapabilities | None = None, strict: bool = True) -> list[Diagnostic]
Fail closed when declared Delta ops are unsupported by capabilities.
When capabilities is None and strict is True (default), emit errors
so callers must supply a plugin that supports spark_delta before
execution. When strict is False (plan-only), emit warnings instead.
diagnostics
¶
Stable Medallantic construction and graph diagnostics (MDL1xx).
mdl_diagnostic
¶
mdl_diagnostic(code: str, message: str, *, severity: Severity = Severity.ERROR, path: tuple[str, ...] = (), phase: str = 'medallion_authoring') -> Diagnostic
Build a Medallantic MDL* diagnostic.
explain
¶
Medallion-oriented plan explain output.
explain_medallion_plan
¶
explain_medallion_plan(plan: PipelinePlan, *, definition: PipelineDefinition | None = None) -> dict[str, Any]
Merge core plan explain with medallion layer and lifecycle metadata.
ir
¶
SparkForge-independent intermediate IR for migration mapping.
Medallion layer names live only in this adapter package — never in ETLantic core.
LayerKind
¶
Bases: StrEnum
SparkForge medallion layer (adapter-only vocabulary).
StepKind
¶
Bases: StrEnum
SparkForge step kinds represented in the compatibility IR.
SparkForgeStepSpec
dataclass
¶
SparkForgeStepSpec(name: str, kind: StepKind, layer: LayerKind, source: str | None = None, table_name: str | None = None, transform_ref: str | None = None, rules: dict[str, Any] = dict(), write_mode: str | None = None, metadata: dict[str, Any] = dict())
One SparkForge step in secret-free form.
SparkForgePipelineSpec
dataclass
¶
SparkForgePipelineSpec(name: str, schema: str = 'default', steps: tuple[SparkForgeStepSpec, ...] = (), min_bronze_rate: float = 90.0, min_silver_rate: float = 95.0, min_gold_rate: float = 98.0, engine: str = 'spark', legacy_engine_extensions: tuple[str, ...] = (), metadata: dict[str, Any] = dict())
Complete SparkForge pipeline description (fixture-friendly).
parse
classmethod
¶
Parse IR and return any coercion / hygiene diagnostics.
lifecycle
¶
Medallantic layer lifecycle defaults (facade-only; not core wire vocabulary).
lifecycle_policy_for_layer
¶
lifecycle_policy_for_layer(*, subject_id: str, layer: str, incremental_field: str | None = None, metadata: dict[str, Any] | None = None) -> LifecyclePolicy
Return the default lifecycle policy for a medallion layer.
incremental_strategy_for_step
¶
incremental_strategy_for_step(*, subject_id: str, layer: str, incremental_column: str | None = None, watermark_column: str | None = None) -> IncrementalStrategy | None
Map Medallantic incremental/watermark columns onto IncrementalStrategy.
lifecycle_views
¶
Layer-aware lifecycle views over normalized ETLantic events.
lower
¶
Lower MedallionDocument onto ETLantic Pipeline / PipelineDefinition.
LoweringError
¶
Bases: Exception
Raised when medallion → ETLantic lowering fails closed.
MedallionRow
¶
Bases: Data
Generic row contract for medallion planning/parity (passthrough).
LoweringResult
dataclass
¶
LoweringResult(pipeline_cls: type[Pipeline], profile: Profile, validation_policy: ValidationPolicy, write_intents: tuple[WriteIntent, ...] = (), step_map: dict[str, str] = dict(), layer_by_node: dict[str, str] = dict(), diagnostics: tuple[Diagnostic, ...] = (), metadata: dict[str, Any] = dict(), required_delta_operations: tuple[str, ...] = ())
build_profile
¶
build_profile(doc: MedallionDocument, *, name: str | None = None, bindings: dict[str, str] | None = None) -> Profile
Build an ETLantic Profile from a medallion document.
build_validation_policy
¶
Map layer thresholds onto a named ValidationPolicy (metadata only).
lower_document
¶
lower_document(doc: MedallionDocument, *, required_delta_operations: tuple[str, ...] = (), diagnostic_phase: str = 'medallion_authoring', allowed_transform_refs: tuple[str, ...] | None = None, transform_refs_fail_closed: bool = False, profile: Profile | None = None) -> LoweringResult
Map a medallion document to a concrete ETLantic Pipeline subclass.
Bronze/silver/gold remain facade metadata on layer_by_node; ETLantic
core never sees medallion enums.
Importable transform_ref values are deny-by-default when
transform_refs_fail_closed is True or when profile.security_mode is
production. Pass allowed_transform_refs (or profile metadata
medallantic.allowed_transform_refs) to permit specific callables.
migrate
¶
Migration bridges from legacy builders into Medallantic.
GenerationResult
dataclass
¶
GenerationResult(definition: PipelineDefinition | None, convertibility: Convertibility, diagnostics: tuple[Diagnostic, ...], source_fingerprint: str | None = None, adaptation: AdaptationResult | None = None)
Result of safe native generation from SparkForge IR.
InventoryArtifact
dataclass
¶
InventoryArtifact(path: str, builder_kind: BuilderKind, step_count: int, convertibility: Convertibility, diagnostic_codes: tuple[str, ...] = (), source_fingerprint: str | None = None, notes: tuple[str, ...] = ())
One discovered migration candidate (secret-free).
MigrationInventoryReport
dataclass
¶
MigrationInventoryReport(root: str, artifacts: tuple[InventoryArtifact, ...] = (), diagnostics: tuple[Diagnostic, ...] = ())
Secret-free project inventory for SparkForge migration.
generate_from_artifact
¶
generate_from_artifact(artifact: InventoryArtifact, *, root: str | Path, require_auto: bool = True) -> GenerationResult
Generate from an inventory artifact under root when auto-safe.
generate_from_ir
¶
generate_from_ir(payload: dict[str, Any], *, source_path: str | None = None, require_auto: bool = True) -> GenerationResult
Generate a native PipelineDefinition from SparkForge IR JSON.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
payload
|
dict[str, Any]
|
Secret-free SparkForge pipeline IR mapping. |
required |
source_path
|
str | None
|
Optional path label for diagnostics. |
None
|
require_auto
|
bool
|
When True, refuse generation unless convertibility is auto. |
True
|
Returns:
| Type | Description |
|---|---|
GenerationResult
|
|
generate_from_path
¶
Load JSON IR from disk and generate a native definition.
scan_project
¶
Scan a project tree for SparkForge / SQL builder migration candidates.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | Path
|
Project root or a single JSON/Python file. |
required |
Returns:
| Type | Description |
|---|---|
MigrationInventoryReport
|
Secret-free |
generate
¶
Safe native Medallantic definition generation from SparkForge IR (M7).
Generators never resolve secrets, never import untrusted project code, and
never read production tables. Only auto-safe inventory artifacts / IR payloads
are converted; manual and unsupported paths emit stable MDL* diagnostics.
GenerationResult
dataclass
¶
GenerationResult(definition: PipelineDefinition | None, convertibility: Convertibility, diagnostics: tuple[Diagnostic, ...], source_fingerprint: str | None = None, adaptation: AdaptationResult | None = None)
Result of safe native generation from SparkForge IR.
generate_from_ir
¶
generate_from_ir(payload: dict[str, Any], *, source_path: str | None = None, require_auto: bool = True) -> GenerationResult
Generate a native PipelineDefinition from SparkForge IR JSON.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
payload
|
dict[str, Any]
|
Secret-free SparkForge pipeline IR mapping. |
required |
source_path
|
str | None
|
Optional path label for diagnostics. |
None
|
require_auto
|
bool
|
When True, refuse generation unless convertibility is auto. |
True
|
Returns:
| Type | Description |
|---|---|
GenerationResult
|
|
generate_from_path
¶
Load JSON IR from disk and generate a native definition.
generate_from_artifact
¶
generate_from_artifact(artifact: InventoryArtifact, *, root: str | Path, require_auto: bool = True) -> GenerationResult
Generate from an inventory artifact under root when auto-safe.
inventory
¶
SparkForge / SQL builder project inventory scanner (Medallantic M7).
Analysis is static and secret-free: JSON IR parsing and text pattern matching only. Never imports untrusted project code, never resolves secrets, never reads production tables, and never mutates targets.
InventoryArtifact
dataclass
¶
InventoryArtifact(path: str, builder_kind: BuilderKind, step_count: int, convertibility: Convertibility, diagnostic_codes: tuple[str, ...] = (), source_fingerprint: str | None = None, notes: tuple[str, ...] = ())
One discovered migration candidate (secret-free).
MigrationInventoryReport
dataclass
¶
MigrationInventoryReport(root: str, artifacts: tuple[InventoryArtifact, ...] = (), diagnostics: tuple[Diagnostic, ...] = ())
Secret-free project inventory for SparkForge migration.
scan_project
¶
Scan a project tree for SparkForge / SQL builder migration candidates.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | Path
|
Project root or a single JSON/Python file. |
required |
Returns:
| Type | Description |
|---|---|
MigrationInventoryReport
|
Secret-free |
sparkforge
¶
SparkForge IR migration namespace (medallantic.migrate.sparkforge).
AdaptationResult
dataclass
¶
AdaptationResult(pipeline_cls: type[Pipeline], profile: Profile, validation_policy: ValidationPolicy, write_intents: tuple[WriteIntent, ...] = (), step_map: dict[str, str] = dict(), layer_by_node: dict[str, str] = dict(), diagnostics: tuple[Diagnostic, ...] = (), metadata: dict[str, Any] = dict(), required_delta_operations: tuple[str, ...] = ())
Result of adapting a SparkForge pipeline IR.
AdapterError
¶
Bases: Exception
Raised when SparkForge → ETLantic adaptation fails closed.
LayerKind
¶
Bases: StrEnum
SparkForge medallion layer (adapter-only vocabulary).
SparkForgePipelineSpec
dataclass
¶
SparkForgePipelineSpec(name: str, schema: str = 'default', steps: tuple[SparkForgeStepSpec, ...] = (), min_bronze_rate: float = 90.0, min_silver_rate: float = 95.0, min_gold_rate: float = 98.0, engine: str = 'spark', legacy_engine_extensions: tuple[str, ...] = (), metadata: dict[str, Any] = dict())
Complete SparkForge pipeline description (fixture-friendly).
parse
classmethod
¶
Parse IR and return any coercion / hygiene diagnostics.
SparkForgeStepSpec
dataclass
¶
SparkForgeStepSpec(name: str, kind: StepKind, layer: LayerKind, source: str | None = None, table_name: str | None = None, transform_ref: str | None = None, rules: dict[str, Any] = dict(), write_mode: str | None = None, metadata: dict[str, Any] = dict())
One SparkForge step in secret-free form.
StepKind
¶
Bases: StrEnum
SparkForge step kinds represented in the compatibility IR.
LiveBridgeError
¶
LiveBridgeError(message: str, *, diagnostics: list[Diagnostic] | None = None, code: str = 'PMSF350')
Bases: Exception
Raised when a live PipelineBuilder cannot be extracted.
adapt_pipeline
¶
adapt_pipeline(spec: SparkForgePipelineSpec, *, capabilities: PluginCapabilities | None = None, strict_delta: bool = True) -> AdaptationResult
Map a SparkForge pipeline IR to a concrete ETLantic Pipeline subclass.
adapt_profile
¶
adapt_profile(spec: SparkForgePipelineSpec, *, name: str | None = None, bindings: dict[str, str] | None = None) -> Profile
Build an ETLantic Profile from SparkForge builder config.
adapt_validation_policy
¶
Map layer thresholds onto a named ValidationPolicy (metadata only).
enrich_plan
¶
Place serialized write intents under plan.intents['write_intents'].
spec_to_document
¶
Convert SparkForge IR into the shared MedallionDocument.
assert_delta_capabilities
¶
assert_delta_capabilities(operations: list[str], *, capabilities: PluginCapabilities | None = None, strict: bool = True) -> list[Diagnostic]
Fail closed when declared Delta ops are unsupported by capabilities.
When capabilities is None and strict is True (default), emit errors
so callers must supply a plugin that supports spark_delta before
execution. When strict is False (plan-only), emit warnings instead.
retry_policy_from_sparkforge
¶
Normalize SparkForge retry config into ETLantic RetryPolicy.
write_mode_from_sparkforge
¶
Map a SparkForge write-mode string to ETLantic WriteMode.
write_mode_metadata
¶
Extra write-mode metadata preserved when modes collapse (e.g. partitions).
from_pipeline_builder
¶
from_pipeline_builder(builder: Any, *, name: str | None = None, engine: str = 'spark') -> tuple[SparkForgePipelineSpec, list[Diagnostic]]
Extract a secret-free SparkForgePipelineSpec from a live builder.
Accepts:
- objects with steps / to_dict / export attributes (SparkForge)
- plain mappings already shaped like IR
sparkforge_available
¶
Return True when a SparkForge pipeline_builder module can be imported.
adapt_run_result
¶
adapt_run_result(payload: dict[str, Any], *, pipeline_id: str | None = None, profile: str = 'medallantic') -> PipelineRunReport
Convert a SparkForge-shaped result dict into PipelineRunReport.
Never retains secret-like keys or free-text credentials from the source
payload. Unknown run statuses fail closed to failed with diagnostic
PMSF500.
report_to_sparkforge_explain
¶
Dual-reporting helper: ETLantic report → SparkForge-shaped explain dict.
bind_debug_session
¶
Return an ETLantic DebugSession for an adapted pipeline class.
debug_request_from_sparkforge
¶
debug_request_from_sparkforge(*, mode: str | None = 'standard', run_until: str | None = None, run_one: str | None = None, run_from: str | None = None, skip_writes: bool = False, materialization: MaterializationPolicy | None = None, retry: dict[str, Any] | RetryPolicy | None = None, parameter_overrides: dict[str, dict[str, Any]] | None = None, implementation_overrides: dict[str, str] | None = None, invalidation: str | InvalidationMode | None = None) -> RunRequest
Build a RunRequest from SparkForge debug/session options.
skip_writes sets no_write=True only. Materialization stays
DEFAULT unless the caller passes materialization= explicitly.
VALIDATE intent also sets no_write=True.
intent_from_sparkforge
¶
Map SparkForge run-mode strings to RunIntent.
invalidation_from_sparkforge
¶
Map SparkForge rerun/invalidation strings to InvalidationMode.
selection_from_sparkforge
¶
selection_from_sparkforge(*, run_until: str | None = None, run_one: str | None = None, run_from: str | None = None) -> RunSelection
Map SparkForge selective-execution flags to RunSelection.
sparkforge_live
¶
Live SparkForge PipelineBuilder → secret-free IR extraction.
SparkForge is an optional dependency. When it is not installed, callers
should use frozen IR fixtures via :func:medallantic.adapt.adapt_pipeline.
This module never embeds secrets or source rows.
LiveBridgeError
¶
LiveBridgeError(message: str, *, diagnostics: list[Diagnostic] | None = None, code: str = 'PMSF350')
Bases: Exception
Raised when a live PipelineBuilder cannot be extracted.
sparkforge_available
¶
Return True when a SparkForge pipeline_builder module can be imported.
from_pipeline_builder
¶
from_pipeline_builder(builder: Any, *, name: str | None = None, engine: str = 'spark') -> tuple[SparkForgePipelineSpec, list[Diagnostic]]
Extract a secret-free SparkForgePipelineSpec from a live builder.
Accepts:
- objects with steps / to_dict / export attributes (SparkForge)
- plain mappings already shaped like IR
sql
¶
SQL pipeline-builder IR migration namespace (medallantic.migrate.sql).
AdaptationResult
dataclass
¶
AdaptationResult(pipeline_cls: type[Pipeline], profile: Profile, validation_policy: ValidationPolicy, write_intents: tuple[WriteIntent, ...] = (), step_map: dict[str, str] = dict(), layer_by_node: dict[str, str] = dict(), diagnostics: tuple[Diagnostic, ...] = (), metadata: dict[str, Any] = dict(), required_delta_operations: tuple[str, ...] = ())
Result of adapting a SparkForge pipeline IR.
AdapterError
¶
Bases: Exception
Raised when SparkForge → ETLantic adaptation fails closed.
LayerKind
¶
Bases: StrEnum
SparkForge medallion layer (adapter-only vocabulary).
SparkForgePipelineSpec
dataclass
¶
SparkForgePipelineSpec(name: str, schema: str = 'default', steps: tuple[SparkForgeStepSpec, ...] = (), min_bronze_rate: float = 90.0, min_silver_rate: float = 95.0, min_gold_rate: float = 98.0, engine: str = 'spark', legacy_engine_extensions: tuple[str, ...] = (), metadata: dict[str, Any] = dict())
Complete SparkForge pipeline description (fixture-friendly).
parse
classmethod
¶
Parse IR and return any coercion / hygiene diagnostics.
SparkForgeStepSpec
dataclass
¶
SparkForgeStepSpec(name: str, kind: StepKind, layer: LayerKind, source: str | None = None, table_name: str | None = None, transform_ref: str | None = None, rules: dict[str, Any] = dict(), write_mode: str | None = None, metadata: dict[str, Any] = dict())
One SparkForge step in secret-free form.
StepKind
¶
Bases: StrEnum
SparkForge step kinds represented in the compatibility IR.
LiveBridgeError
¶
LiveBridgeError(message: str, *, diagnostics: list[Diagnostic] | None = None, code: str = 'PMSQ350')
Bases: Exception
Raised when a live SqlPipelineBuilder cannot be extracted.
adapt_pipeline
¶
adapt_pipeline(spec: SparkForgePipelineSpec, *, capabilities: PluginCapabilities | None = None, strict_delta: bool = True) -> AdaptationResult
Map a SparkForge pipeline IR to a concrete ETLantic Pipeline subclass.
adapt_profile
¶
adapt_profile(spec: SparkForgePipelineSpec, *, name: str | None = None, bindings: dict[str, str] | None = None) -> Profile
Build an ETLantic Profile from SparkForge builder config.
adapt_validation_policy
¶
Map layer thresholds onto a named ValidationPolicy (metadata only).
enrich_plan
¶
Place serialized write intents under plan.intents['write_intents'].
spec_to_document
¶
Convert SparkForge IR into the shared MedallionDocument.
write_mode_from_sparkforge
¶
Map a SparkForge write-mode string to ETLantic WriteMode.
write_mode_metadata
¶
Extra write-mode metadata preserved when modes collapse (e.g. partitions).
from_sql_pipeline_builder
¶
from_sql_pipeline_builder(builder: Any, *, name: str | None = None, engine: str = 'sql') -> tuple[SparkForgePipelineSpec, list[Diagnostic]]
Extract a secret-free SparkForgePipelineSpec from a live SQL builder.
Accepts:
- objects with steps / to_dict / export attributes
- SQLAlchemy Select-like objects
- plain mappings already shaped like IR
sql_pipeline_builder_available
¶
Return True when a SQL pipeline builder module can be imported.
adapt_run_result
¶
adapt_run_result(payload: dict[str, Any], *, pipeline_id: str | None = None, profile: str = 'medallantic') -> PipelineRunReport
Convert a SparkForge-shaped result dict into PipelineRunReport.
Never retains secret-like keys or free-text credentials from the source
payload. Unknown run statuses fail closed to failed with diagnostic
PMSF500.
report_to_sparkforge_explain
¶
Dual-reporting helper: ETLantic report → SparkForge-shaped explain dict.
sql_live
¶
Live SqlPipelineBuilder → secret-free IR extraction.
SqlPipelineBuilder / Moltres are optional dependencies. When they are not
installed, callers should use frozen IR fixtures via
:func:medallantic.adapt.adapt_pipeline. This module never embeds secrets or
source rows.
LiveBridgeError
¶
LiveBridgeError(message: str, *, diagnostics: list[Diagnostic] | None = None, code: str = 'PMSQ350')
Bases: Exception
Raised when a live SqlPipelineBuilder cannot be extracted.
sql_pipeline_builder_available
¶
Return True when a SQL pipeline builder module can be imported.
from_sql_pipeline_builder
¶
from_sql_pipeline_builder(builder: Any, *, name: str | None = None, engine: str = 'sql') -> tuple[SparkForgePipelineSpec, list[Diagnostic]]
Extract a secret-free SparkForgePipelineSpec from a live SQL builder.
Accepts:
- objects with steps / to_dict / export attributes
- SQLAlchemy Select-like objects
- plain mappings already shaped like IR
moltres_rules
¶
Non-portable Moltres / SQL-native quality rules (Medallantic-only).
These rules are not part of etlantic.quality/1. They require the
quality.moltres_expr engine capability and fail closed with MDL132
when the selected engine cannot execute them.
NativeMoltresRule
dataclass
¶
NativeMoltresRule(field: str, kind: str, expr_ref: str | None = None, required: bool = True, metadata: dict[str, Any] = field(default_factory=dict))
One engine-native Moltres / SQLAlchemy expression validator.
is_moltres_rule_entry
¶
Return True when a rule entry is a Moltres / SQLAlchemy-native validator.
split_portable_and_moltres_rules
¶
split_portable_and_moltres_rules(rules: dict[str, Any] | None) -> tuple[dict[str, Any], list[NativeMoltresRule]]
Partition a rules mapping into portable shorthand and Moltres rules.
profiles
¶
Medallion profile templates composing core production envelopes.
reports
¶
Normalize SparkForge-shaped run results into PipelineRunReport.
adapt_run_result
¶
adapt_run_result(payload: dict[str, Any], *, pipeline_id: str | None = None, profile: str = 'medallantic') -> PipelineRunReport
Convert a SparkForge-shaped result dict into PipelineRunReport.
Never retains secret-like keys or free-text credentials from the source
payload. Unknown run statuses fail closed to failed with diagnostic
PMSF500.
report_to_sparkforge_explain
¶
Dual-reporting helper: ETLantic report → SparkForge-shaped explain dict.
evaluate_accept_rates
¶
evaluate_accept_rates(*, policy_metadata: dict[str, Any], validations: list[ValidationResult] | list[dict[str, Any]], layer: str | None = None) -> list[dict[str, Any]]
Compare validation accept rates against Medallantic layer thresholds.
Threshold keys live on ValidationPolicy.metadata as
min_accept_rate_{ingest,clean,publish} (bronze/silver/gold).
Returns a list of findings; empty when thresholds are satisfied or absent.
enforce_accept_rates
¶
enforce_accept_rates(report: PipelineRunReport, *, policy_metadata: dict[str, Any], layer_by_node: dict[str, str] | None = None) -> PipelineRunReport
Fail a successful report when accept-rate thresholds are violated.
Returns the original report when thresholds pass or are absent. On
violation, returns a replaced report with FAILED status and
MDL120 diagnostics.
rules
¶
Medallantic shorthand rule DSL → etlantic.quality/1.
RuleDSLError
¶
Bases: ValueError
Raised when a Medallantic rules shorthand cannot be parsed.
parse_rules_shorthand
¶
Parse column→shorthand lists into a portable quality ruleset.
Supported shorthands (strings)::
not_null
unique / uniqueness
regex:<pattern>
length:min:max | min_length:N | max_length:N
in:a|b|c
range:min:max
ge:N / le:N / gt:N / lt:N / eq:N / ne:N
custom:<name>
Structured dict forms are also accepted per entry.
runtime_map
¶
Map SparkForge debug / run modes onto ETLantic RunRequest surfaces.
intent_from_sparkforge
¶
Map SparkForge run-mode strings to RunIntent.
selection_from_sparkforge
¶
selection_from_sparkforge(*, run_until: str | None = None, run_one: str | None = None, run_from: str | None = None) -> RunSelection
Map SparkForge selective-execution flags to RunSelection.
invalidation_from_sparkforge
¶
Map SparkForge rerun/invalidation strings to InvalidationMode.
debug_request_from_sparkforge
¶
debug_request_from_sparkforge(*, mode: str | None = 'standard', run_until: str | None = None, run_one: str | None = None, run_from: str | None = None, skip_writes: bool = False, materialization: MaterializationPolicy | None = None, retry: dict[str, Any] | RetryPolicy | None = None, parameter_overrides: dict[str, dict[str, Any]] | None = None, implementation_overrides: dict[str, str] | None = None, invalidation: str | InvalidationMode | None = None) -> RunRequest
Build a RunRequest from SparkForge debug/session options.
skip_writes sets no_write=True only. Materialization stays
DEFAULT unless the caller passes materialization= explicitly.
VALIDATE intent also sets no_write=True.
bind_debug_session
¶
Return an ETLantic DebugSession for an adapted pipeline class.
schema
¶
Facade-owned medallion document schema (not an ETLantic wire schema).
MedallionStep
dataclass
¶
MedallionStep(name: str, layer: str, kind: str, source: str | None = None, asset: str | None = None, transform_ref: str | None = None, rules: dict[str, Any] = dict(), write_mode: str | None = None, description: str | None = None, tags: tuple[str, ...] = (), metadata: dict[str, Any] = dict())
One bronze, silver, or gold step in a medallion document.
MedallionDocument
dataclass
¶
MedallionDocument(name: str, schema: str = 'default', steps: tuple[MedallionStep, ...] = (), min_bronze_rate: float = 90.0, min_silver_rate: float = 95.0, min_gold_rate: float = 98.0, engine: str = 'local', description: str | None = None, tags: tuple[str, ...] = (), metadata: dict[str, Any] = dict())
Declarative medallion pipeline document owned by Medallantic.