singer_sdk.InlineMapper

class singer_sdk.InlineMapper[source]

Bases: BaseSingerReader, BaseSingerWriter

Abstract base class for inline mappers.

message_reader_class[source]

alias of SimpleSingerReader

message_writer_class[source]

alias of SimpleSingerWriter

classmethod append_builtin_config(config_jsonschema)[source]

Appends built-in config to config_jsonschema if not already set.

To customize or disable this behavior, developers may either override this class method or override the capabilities property to disabled any unwanted built-in capabilities.

For all except very advanced use cases, we recommend leaving these implementations “as-is”, since this provides the most choice to users and is the most “future proof” in terms of taking advantage of built-in capabilities which may be added in the future.

Parameters:

config_jsonschema (dict) – [description]

Return type:

None

classmethod cb_version(ctx, param, value)[source]

CLI callback to print the plugin version and exit.

Parameters:
  • ctx (Context) – Click context.

  • param (Option) – Click parameter.

  • value (bool) – Boolean indicating whether to print the version.

Return type:

None

classmethod get_plugin_version()[source]

Return the package version number.

Returns:

The package version number.

Return type:

str

classmethod get_sdk_version()[source]

Return the package version number.

Returns:

The package version number.

Return type:

str

classmethod get_singer_command()[source]

Execute standard CLI handler for inline mappers.

Returns:

A click.Command object.

Return type:

Command

classmethod get_supported_python_versions()[source]

Return the supported Python versions.

Returns:

A list of supported Python versions.

Return type:

list[str] | None

classmethod instantiate_processor(instance, default_cls)[source]

Instantiate a processor instance.

Parameters:
  • instance (_T | None) – The instance to instantiate.

  • default_cls (type[_T]) – The default class to instantiate.

Returns:

The instantiated processor instance.

Return type:

_T

classmethod invoke(*, about=False, about_format=None, config=(), file_input=None)[source]

Invoke the mapper.

Parameters:
  • about (bool) – Display package metadata and settings.

  • about_format (str | None) – Specify output style for –about.

  • config (tuple[str, ...]) – Configuration file location or ‘ENV’ to use environment variables. Accepts multiple inputs as a tuple.

  • file_input (IO[str] | None) – Optional file to read input from.

Return type:

None

classmethod print_about(output_format=None)[source]

Print capabilities and other tap metadata.

Parameters:

output_format (str | None) – Render option for the plugin information.

Return type:

None

classmethod print_version(print_fn=<built-in function print>)[source]

Print help text for the tap.

Parameters:

print_fn (Callable[[Any], None]) – A function to use to display the plugin version. Defaults to print().

Return type:

None

static config_from_cli_args(*args)[source]

Parse CLI arguments into a config dictionary.

Parameters:

args (str) – CLI arguments.

Raises:

FileNotFoundError – If the config file does not exist.

Returns:

A tuple containing the config dictionary and a boolean indicating whether the config file was found.

Return type:

tuple[list[Path], bool]

__init__(*, config=None, parse_env_config=False, validate_config=True, message_reader=None, message_writer=None)[source]

Initialize the inline mapper.

Parameters:
  • config (dict | PurePath | str | list[PurePath | str] | None)

  • parse_env_config (bool)

  • validate_config (bool)

  • message_reader (GenericSingerReader | None)

  • message_writer (GenericSingerWriter | None)

Return type:

None

listen(file_input=None)[source]

Read from input until all messages are processed.

Parameters:

file_input (IO[str] | None) – Readable stream of messages. Defaults to standard in.

Return type:

None

abstractmethod map_activate_version_message(message_dict)[source]

Map a version message to zero or more new messages.

Parameters:

message_dict (dict) – An ACTIVATE_VERSION message JSON dictionary.

Return type:

t.Iterable[singer.Message]

map_batch_message(message_dict)[source]

Map a batch message to zero or more new messages.

Parameters:

message_dict (dict) – A BATCH message JSON dictionary.

Raises:

NotImplementedError – if not implemented by subclass.

Return type:

t.Iterable[singer.Message]

abstractmethod map_record_message(message_dict)[source]

Map a record message to zero or more new messages.

Parameters:

message_dict (dict) – A RECORD message JSON dictionary.

Return type:

t.Iterable[singer.Message]

abstractmethod map_schema_message(message_dict)[source]

Map a schema message to zero or more new messages.

Parameters:

message_dict (dict) – A SCHEMA message JSON dictionary.

Return type:

t.Iterable[singer.Message]

abstractmethod map_state_message(message_dict)[source]

Map a state message to zero or more new messages.

Parameters:

message_dict (dict) – A STATE message JSON dictionary.

Return type:

t.Iterable[singer.Message]

process_endofpipe()[source]

Process end of pipe.

Return type:

None

process_lines(file_input)[source]

Internal method to process jsonl lines from a Singer tap.

Parameters:

file_input (IO[str] | None) – Readable stream of messages, each on a separate line.

Returns:

A counter object for the processed lines.

Return type:

Counter[str]

setup_mapper()[source]

Initialize the plugin mapper for this tap.

Return type:

None

write_message(message)[source]

Write a message to the tap’s message writer.

Parameters:

message (Any)

Return type:

None

property config: Mapping[str, Any][source]

Get config.

Returns:

A frozen (read-only) config dictionary map.

property initialized_at: int[source]

Start time of the plugin.

Returns:

The start time of the plugin.

property mapper: PluginMapper[source]

Plugin mapper for this tap.

Returns:

A PluginMapper object.

Raises:

MapperNotInitialized – If the mapper has not been initialized.

name: str[source]

The executable name of the tap or target plugin. e.g. tap-foo

package_name: str | None = None[source]

The package name of the plugin. e.g meltanolabs-tap-foo

property state: dict[source]

Get state.

Raises:

NotImplementedError – If the derived plugin doesn’t override this method.