singer_sdk.InlineMapper

class singer_sdk.InlineMapper[source]

Bases: PluginBase, SingerReader, SingerWriter

Abstract base class for inline mappers.

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

Create the tap or target.

Parameters:
  • config (dict | PurePath | str | list[PurePath | str] | None) – May be one or more paths, either as str or PurePath objects, or it can be a predetermined config dict.

  • parse_env_config (bool) – True to parse settings from env vars.

  • validate_config (bool) – True to require validation of config settings.

Raises:

ValueError – If config is not a dict or path string.

Return type:

None

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

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]

deserialize_json(line)[source]

Deserialize a line of json.

Parameters:

line (str) – A single line of json.

Returns:

A dictionary of the deserialized json.

Raises:

json.decoder.JSONDecodeError – raised if any lines are not valid json

Return type:

dict

format_message(message)[source]

Format a message as a JSON string.

Parameters:

message (Message) – The message to format.

Returns:

The formatted message.

Return type:

str

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 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

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

This method is internal to the SDK and should not need to be overridden.

abstract 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]

abstract 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]

abstract 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]

abstract 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]

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

setup_mapper()[source]

Initialize the plugin mapper for this tap.

Return type:

None

write_message(message)[source]

Write a message to stdout.

Parameters:

message (Message) – The message to write.

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.