Implementation:Mage ai Mage ai Destination Init
| Knowledge Sources | |
|---|---|
| Domains | Data_Integration, ETL |
| Last Updated | 2026-02-09 00:00 GMT |
Overview
Concrete tool for initializing Singer target destination instances with config, batch processing mode, and internal state registries provided by the Mage integrations Destination base class.
Description
Destination.__init__ accepts config via multiple channels (argument_parser CLI args, direct dict, config_file_path, settings YAML) and initializes internal dictionaries for per-stream tracking of schemas, validators, key_properties, bookmark_properties, replication_methods, unique_constraints, and versions. It sets up batch_processing mode (default False) and configures input source (stdin or input_file_path).
Usage
Subclass Destination and call super().__init__() with your configuration. Must implement the abstract methods export_batch_data() and test_connection().
Code Reference
Source Location
- Repository: mage-ai
- File: mage_integrations/mage_integrations/destinations/base.py
- Lines: 54-128
Signature
class Destination(ABC):
def __init__(
self,
argument_parser=None,
batch_processing: bool = False,
catalog: Dict = None,
config: Dict = None,
config_file_path: str = None,
debug: bool = False,
input_file_path: str = None,
log_to_stdout: bool = False,
logger=LOGGER,
settings: Dict = None,
settings_file_path: str = None,
show_templates: bool = False,
state_file_path: str = None,
test_connection: bool = False,
):
Import
from mage_integrations.destinations.base import Destination
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| config | Dict | Yes (one source) | Target config with connection params |
| batch_processing | bool | No | Enable batch mode (default False) |
| catalog | Dict | No | Pre-loaded catalog with stream schemas |
| input_file_path | str | No | File input instead of stdin |
| state_file_path | str | No | Path to write state output |
Outputs
| Name | Type | Description |
|---|---|---|
| self | Destination | Initialized instance with config, empty registries, logger |
Usage Examples
from mage_integrations.destinations.base import Destination
import argparse
class BigQueryDestination(Destination):
def __init__(self, **kwargs):
super().__init__(
argument_parser=argparse.ArgumentParser(),
batch_processing=True,
**kwargs,
)
def test_connection(self):
# Validate BigQuery credentials
pass
def export_batch_data(self, record_data, stream, tags=None):
# Write records to BigQuery
pass
# Run
dest = BigQueryDestination()
dest.process(sys.stdin.buffer)