Adventure starts here
- Overview
- Quickstart
- Design
- Abstractions
Concepts
- Pipelines
- Blocks
- Overview
- Types
- Dynamic blocks
- Resources
- Data loader
- Transformer
- Data exporter
- Sensors
- Callbacks
- Conditionals
- Data integrations
- Triggers
- Pipeline runs
- Backfills
Project
- Setup
- Version control
- Docker
- Variables
- Custom libraries
- Database
- Credentials
- IO Config Setup
- Code execution
- Timezones
- Settings
- Version upgrades
Contributing
- Overview
- Dev environment
- Backend
- Frontend
- Documentation
Transformer
Transformer templates
Generic
if 'transformer' not in globals():
from mage_ai.data_preparation.decorators import transformer
if 'test' not in globals():
from mage_ai.data_preparation.decorators import test
@transformer
def transform(*args, **kwargs):
"""
Template code for a transformer block.
Add more parameters to this function if this block has multiple parent blocks.
There should be one parameter for each output variable from each parent block.
Args:
args: The input variables from upstream blocks
Returns:
Anything (e.g. data frame, dictionary, array, int, str, etc.)
"""
# Specify your transformation logic here
return {}
@test
def test_output(output, *args) -> None:
"""
Template code for testing the output of the block.
"""
assert output is not None, 'The output is undefined'
Was this page helpful?
On this page
Assistant
Responses are generated using AI and may contain mistakes.