transforms¶
Phase 2 — optional prepare() transformation snapshot and integrity checks.
transforms
¶
Phase 2 — transformation sanity checks.
The harness cannot know what cleaning your analysis performs, so this phase is
opt-in. If your Python adapter exposes a prepare(df, seed=None) -> DataFrame
function, the harness runs it, records a before/after shape snapshot, and applies
any transform_checks declared in the project file. If there is no prepare()
step, the phase records that the analysis consumes the raw data as loaded.
run_phase(adapter, df, project, prepared=None)
¶
Run Phase 2 transformation sanity checks and return the prepared frame.
If the adapter exposes a callable prepare, records a before/after shape snapshot
and evaluates each declared transform_check; otherwise records that the analysis
consumes the raw dataset as loaded. prepared may be supplied by the caller
(cli.main computes it once and reuses it here) to avoid invoking prepare() a
second time; if it is None and the adapter declares prepare(), this function
calls it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
adapter
|
Analysis adapter module, optionally exposing |
required | |
df
|
The raw input |
required | |
project
|
The :class: |
required | |
prepared
|
Optionally, the already-computed prepared |
None
|
Returns:
| Type | Description |
|---|---|
|
A |
|
|
class: |
|
|
|
Source code in crossverify/transforms.py
_evaluate(spec, df)
¶
Evaluate a single transform-check spec against df.
Dispatches on spec["kind"] (range, no_duplicate_rows, row_count);
unknown kinds yield an INFO skip and a malformed spec yields a FAIL rather than
silently passing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
spec
|
A single transform-check specification mapping (must contain |
required | |
df
|
The prepared |
required |
Returns:
| Name | Type | Description |
|---|---|---|
A |
class: |