Skip to content

Transformer

James Lott edited this page Mar 10, 2018 · 5 revisions

Synopsis

from transformer import TransformerError

def transform(cfg, path, data, meta):
  # Use values from cfg and/or meta to perform transformations
  # on any or all of data, path, and meta
  return path, data, meta

transform

Spec

transform(cfg, path, data, meta)

Description

The purpose of transformers is to provide a method through which assets can be paramaterized/templatized, allowing outputs to be written with project specific values.

A transformer is simply a function which takes as its parameters a dictionary providing project level configuration data (cfg) and all of the properties of an asset (path, data, and meta). This function can use any of the information it is passed to transform any of the other information it is passed (e.g., data might be a template which can be rendered using the values in cfg). After the asset is transformed, the transformer must return all of the asset properties. If the expected transformation of the asset fails for any reason, the transformer is expected to raise TransformerError.

A transformer should be implemented in a dedicated module as an exposed method named transform.

Clone this wiki locally