Transformation is a named Python function stored on the platform, with a typed input / output schema. Create one imperatively with Transformation.new(...) or declaratively with the @Transformation.from_function decorator; run it with run or wire it into a Pipeline as a TransformationNode. Every method has an async sibling prefixed with a.
Lifecycle
new
Display name. Used by
from_function and fetch(name=…) as the idempotency key.What the transformation does.
The Python function name defined inside
function.Output schema, same shape as
inputs.The function source as a string. Should return a dict keyed by your output names.
The new instance, with
.id, .branch_id, and .version populated.save
save alternative to new). Populates .id on the instance.
fetch
id or name (at least one is required). username / org_name disambiguate a shared transformation. Raises TransformationNotFound if nothing matches.
list
include_shared=True to include shared ones, verbose=True to populate full TransformationListEntry fields (otherwise only ids come back). Returns a TransformationList.
update
_UNSET sentinel distinguishes “not supplied” from an explicit None). Mutates the local instance to match. Returns self.
delete
From a Python function
from_function
Transformation. Works with or without parentheses.
- Source — the function body is captured via
inspect.getsource(decorator lines stripped) and stored asfunction. - Name / description — default to the function’s
__name__and docstring. - Schema inference —
inputscome from parameter type annotations;outputsfrom the return annotation. ATypedDictreturn maps each key to its type; a literalreturn {…}uses its string keys; anything else becomes a singleresult. Types map viaIOType.from_python. Pass explicitinputs=/outputs=to override. - Idempotency — by default the decorator fetches by
name, and updates only if the source or schema changed, otherwise creates. Returns the resultingTransformation. defer=True— skip the network call and return an unsavedTransformationyou can.save()later.
Running
run
inputs schema, input keys are validated against it — unknown keys raise TransformationInvalidSchema before any request is made. A schemaless instance (e.g. one constructed by id without a fetch) skips this check. A failed engine run raises TransformationRunFailed.
Returns
Typed
TransformationRunResult — .status, .outputs (native Python values, unwrapped from the engine’s DataType envelope), and an optional .error.Instance attributes
ATransformation carries: id, name, description, function_name, inputs, outputs, function, branch_id, version.
Types
IOConfig
A single input / output schema entry. On create / update the wire keeps only io_type; fetch returns the full object.
Optional human description.
TransformationRunResult
"success" or "failure" — see TransformationStatus.Output values keyed by output name, unwrapped to native Python types.
Present on failure.
TransformationListEntry
user_id, org_id, username, email when verbose=True.
TransformationList
Enums
IOType
Wire vocabulary for input / output types:
| Member | Wire value | Python type |
|---|---|---|
ANY | any | Any / unannotated |
STRING | string | str |
INT | int32 | int |
FLOAT | float | float |
BOOL | bool | bool |
LIST | vec<any> | list |
FILE | file | vectorshift.File |
IOType.from_python(annotation) maps a Python type annotation to the matching member, defaulting to ANY.
TransformationStatus
SUCCESS ("success") · FAILURE ("failure")
Errors
All subclassTransformationError, which subclasses VectorshiftError.
TransformationNotFound— afetchreturned no result.TransformationAmbiguousName—from_functionfound more than one transformation by name.TransformationRunFailed— a run completed with a failed status; carries.transformation_idand.message.TransformationInvalidSchema— wrong keys, unknownio_type, or unknown input keys passed torun.TransformationCompileError— the engine refused the Python source.
What’s next
Overview
Mental model and quick start.
Run & I/O types
Typed inputs, run results, and IOType mapping.
Pipeline node
Wire a Transformation into a Pipeline.
