API Reference¶
Schema¶
tacit.Schema
¶
Base class for tacit schema definitions.
Subclass and declare columns as annotated class attributes:
class Iris(Schema):
sepal_length: float
species: str
Source code in src/tacit/schema.py
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 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 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 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 | |
parse(table)
classmethod
¶
Full parsing: coerce types + validate with pandera + wrap as DataFrame.
Executes queries against the engine. Use at pipeline boundaries where you're ingesting untrusted data.
Raises:
| Type | Description |
|---|---|
ValidationError
|
Data fails structural, coercion, or validation checks. |
Source code in src/tacit/schema.py
cast(table)
classmethod
¶
Structural check: verify column names and types match, wrap as DataFrame.
Metadata-only — does not execute queries. Use at internal pipeline boundaries where you trust the data but want type safety.
Raises:
| Type | Description |
|---|---|
StructuralError
|
Missing, extra, or wrong-type columns. |
Source code in src/tacit/schema.py
DataFrame¶
tacit.DataFrame
¶
Bases: Table
Schema-aware DataFrame. Wraps an ibis Table with a schema type parameter.
DataFrame[S] IS an ibis Table (subclass), so the full ibis API works transparently. ibis operations (.mutate(), .filter(), etc.) return plain ir.Table — the schema type drops off, which is correct by design.
Source code in src/tacit/schema.py
contract¶
tacit.contract
¶
contract(fn=None, /, *, validate=False, returns=None)
¶
Decorator that enforces DataFrame schema contracts at function boundaries.
Inspects type annotations to find DataFrame[S] parameters and return type. Calls Schema.cast() on inputs and outputs by default (structural checks only, zero execution cost). With validate=True, calls Schema.parse() instead (full pandera validation, executes queries).
Non-DataFrame parameters and return values are passed through unchanged.
The returns parameter lets the decorator own the output schema so the
function body can return a plain ir.Table without a type error::
@tacit.contract(returns=IrisFeatures)
def transform(df: DataFrame[Iris]) -> ir.Table:
return df.mutate(sepal_ratio=df.sepal_length / df.sepal_width)
Call sites still see DataFrame[IrisFeatures] as the return type.
Usage
@tacit.contract def transform(df: DataFrame[Iris]) -> DataFrame[IrisFeatures]: return IrisFeatures.cast(df.mutate(...))
@tacit.contract(validate=True) def ingest(df: DataFrame[Iris]) -> DataFrame[IrisFeatures]: return IrisFeatures.cast(df.mutate(...))
@tacit.contract(returns=IrisFeatures) def transform(df: DataFrame[Iris]) -> ir.Table: return df.mutate(...)
Source code in src/tacit/contract.py
tacit.errors.ValidationError¶
tacit.errors.ValidationError
¶
Bases: Exception
Base class for tacit validation failures.
Source code in src/tacit/errors.py
tacit.errors.StructuralError¶
tacit.errors.StructuralError
¶
tacit.errors.CoercionError¶
tacit.errors.CoercionError
¶
Bases: ValidationError