Transform
Derive fields from every row with deterministic Python.
Transform maps each distinct input value to fields produced by a trusted callable. It is the right choice for parsing, arithmetic, normalization, and other exact row-local work.
Worked example
Transform(
name="parse-published-time",
input_spaces=("headlines",),
output_space="parsed-headlines",
primary_key="news_id",
evidence=("published_at_raw",),
fn=PythonFunction(
name="parse_published_time",
source="""from datetime import datetime
def parse_published_time(row):
try:
value = datetime.fromisoformat(row["published_at_raw"])
except (TypeError, ValueError):
value = None
return {
"published_at": value
}
""",
),
emits=("published_at",),
)Callable contract
fn(row) -> mapping. The returned fields are added to the source row.
Rows available to the callable
Each row argument contains the declared primary-key fields and the declared evidence fields available for that input role. If the callable reads a field that is not part of the primary key, declare it as evidence.
| Parameter | Default | Meaning |
|---|---|---|
input_spaces | required | The Space or Spaces read by the task. |
output_space | required | The Space that receives the task output. |
name | required | A stable task name used in sessions, reviews, and metrics. |
primary_key | id | The field, or tuple of fields, that identifies one task input. Duplicate primary-key values are evaluated once. |
evidence | none | Optional fields made available to the callable in addition to the primary key. |
fn | required | A deterministic callable that completely defines the operation's decision. Use an importable named function from your package, or PythonFunction(name=..., source=...) when authoring through the hosted API or node editor. Pairwise endomorphic functions may declare an exact indexed candidate_gate. |
function_parameters | registered defaults | Typed values bound to parameters declared by the registered function. Finite candidate sets let reviewed evidence support parameter advice. |
| Parameter | Default | Meaning |
|---|---|---|
emits | none | Descriptive names of fields produced by the callable. |
Output
One output row per distinct primary-key value, with produced fields attached.
Design guidance
Prefer Transform over SemTransform whenever the result can be computed reliably. This avoids model cost and makes the output exactly reproducible. A hosted PythonFunction may catch ValueError, TypeError, or OverflowError around parsing; broad exception handlers, raise, else, and finally are not accepted.