loom.etl.runtime¶
Runtime contracts used by executor and backend implementations.
- class loom.etl.runtime.AgentBatchRunner(*args, **kwargs)[source]¶
Bases:
ProtocolOptional capability protocol for running a declared agent over a frame.
Implemented by
loom.ai.etland injected intoETLExecutorandETLCompileras a separate dependency, so the ETL pillar depends on this contract and never on the AI pillar. Used exclusively to serveWithAgentdeclarations.- validate(name, output_type, *, max_usd)[source]¶
Check, without spending anything, that name can serve a step.
- Parameters:
- Returns:
Every issue found; empty when the agent can serve the step.
- Return type:
tuple[AgentIssue, …]
- map(name, frame, *, keys, prompt, output_type, max_usd)[source]¶
Run agent name once per row of frame.
- Parameters:
name (str) – Agent name declared by the step.
frame (Any) – Backend frame holding the rows to answer.
keys (Sequence[str]) – Columns identifying a row, copied to the output.
prompt (object) – Backend expression, or column name, giving each row’s prompt.
output_type (type[Any]) – Type every answer is decoded into.
max_usd (Decimal | None) – Budget of this call;
Nonespends without a ceiling.
- Returns:
One output row per input row, failures included.
- Return type:
- class loom.etl.runtime.AgentIssue(kind, message)[source]¶
Bases:
objectOne reason a declared agent cannot serve a step.
- Parameters:
kind (AgentIssueKind)
message (str)
- kind¶
What is wrong.
- class loom.etl.runtime.AgentIssueKind(value)[source]¶
Bases:
StrEnumWhy a declared agent cannot serve a step.
- exception loom.etl.runtime.ConfigValueError(key, value_type, failure)[source]¶
Bases:
ConfigErrorA declared config value is missing, unresolvable or of the wrong type.
The message names the key and the expected type only; neither the value nor the underlying exception is attached (
__cause__and__context__areNone).- Parameters:
key (str)
value_type (object)
failure (ConfigValueFailure)
- Return type:
None
- key¶
Dot-separated config path.
- failure¶
Why the value could not be supplied.
- class loom.etl.runtime.ConfigValueFailure(value)[source]¶
Bases:
StrEnumWhy a config value could not be supplied.
- class loom.etl.runtime.TableDiscovery(*args, **kwargs)[source]¶
Bases:
ProtocolProtocol for catalog-backed table existence and schema discovery.
Used by
ETLCompilerwhen a catalog is injected at construction time to validate that source and target tables are valid before execution begins.- schema(ref)[source]¶
Return full table schema.
- Parameters:
ref (TableRef) – Logical table reference.
- Returns:
Ordered column schema tuple, or
Nonewhen table is missing.- Return type:
tuple[ColumnSchema, …] | None
- update_schema(ref, schema)[source]¶
Persist table schema after a successful write.
- Parameters:
ref (TableRef) – Logical table reference.
schema (tuple[ColumnSchema, ...]) – Authoritative table schema.
- Return type:
None
- class loom.etl.runtime.SourceReader(*args, **kwargs)[source]¶
Bases:
ProtocolProtocol for reading one ETL source specification into a frame.
- read(spec, params_instance, /)[source]¶
Read the source and return a frame.
- Parameters:
spec (TableSourceSpec | FileSourceSpec | TempSourceSpec | MongoSourceSpec | ClickHouseSourceSpec | DynamoDbSourceSpec) – Compiled source specification.
params_instance (Any) – Concrete params for current run.
- Returns:
Backend frame type accepted by the step
execute()method.- Return type:
- class loom.etl.runtime.SQLExecutor(*args, **kwargs)[source]¶
Bases:
ProtocolOptional capability protocol for SQL execution over source frames.
- class loom.etl.runtime.TargetWriter(*args, **kwargs)[source]¶
Bases:
ProtocolProtocol for writing one frame into one ETL target specification.
- write(frame, spec, params_instance, /, *, streaming=False, write_ctx=None)[source]¶
Write frame to target.
- Parameters:
frame (Any) – Frame returned by step
execute().spec (TargetSpec) – Compiled target specification.
params_instance (Any) – Concrete params for current run.
streaming (bool) – Hint for lazy backends to use streaming materialization.
write_ctx (WriteContext | None) – Execution context for audit-column injection.
Nonedisables audit columns regardless of config.
- Return type:
None