{"id":9352,"library":"target-hotglue","title":"Target Hotglue","description":"`target-hotglue` is an SDK designed for building Singer Targets specifically tailored for the Hotglue data integration platform. It extends the `singer-sdk` to provide features relevant to Hotglue's environment, such as authentication handling and record tracking. The current version is 0.1.11, and it typically follows the release cadence of its underlying `singer-sdk` or Hotglue platform requirements, with focused updates for new features or bug fixes.","status":"active","version":"0.1.11","language":"en","source_language":"en","source_url":"https://github.com/hotglue/target-hotglue","tags":["singer","elt","target","hotglue","data-integration","sdk"],"install":[{"cmd":"pip install target-hotglue","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"Core framework for Singer targets, target-hotglue builds upon it.","package":"singer-sdk"},{"reason":"HTTP client for making API requests, commonly used in targets.","package":"requests"},{"reason":"Provides retry and backoff capabilities for robust API calls.","package":"backoff"},{"reason":"Used for building web interfaces or API endpoints, potentially for Hotglue's specific features.","package":"flask"},{"reason":"WSGI HTTP Server for UNIX, often used to serve Flask applications in production.","package":"gunicorn"}],"imports":[{"note":"Main class to inherit from when creating a custom target.","symbol":"Target","correct":"from target_hotglue.target import Target"},{"note":"Base class for defining how records for a specific stream are processed.","symbol":"Stream","correct":"from target_hotglue.streams import Stream"}],"quickstart":{"code":"import os\nimport json\nfrom pathlib import Path\nfrom typing import Dict, Any, List\n\nfrom target_hotglue.target import Target\nfrom target_hotglue.streams import Stream\n\n# --- 1. Define your custom target and streams ---\n\n# Define a custom stream where records will be written\nclass MyCustomStream(Stream):\n    name = \"my_custom_stream\"\n    schema = {\"type\": \"object\", \"properties\": {\"id\": {\"type\": \"integer\"}, \"value\": {\"type\": \"string\"}}}\n    key_properties = [\"id\"]\n\n    def write_record(self, record: Dict[str, Any]) -> None:\n        \"\"\"\n        Processes a single record.\n        In a real target, this is where you'd write to your destination system.\n        For this example, we'll write to a local JSONL file.\n        \"\"\"\n        output_file_path = Path(self.target_config.get(\"output_file\", \"quickstart_output.jsonl\"))\n        with output_file_path.open(\"a\") as f:\n            f.write(json.dumps(record) + \"\\n\")\n        self.logger.info(f\"Wrote record to {output_file_path}: {record}\")\n\n# Define your custom target, linking it to your stream(s)\nclass MyCustomTarget(Target):\n    name = \"target-quickstart\"\n    # Define a simple configuration schema for the target\n    config_jsonschema = {\n        \"type\": \"object\",\n        \"properties\": {\n            \"output_file\": {\"type\": \"string\", \"default\": \"quickstart_output.jsonl\", \"description\": \"File to write records to\"}\n        },\n        \"required\": []\n    }\n\n    # Register your custom streams with the target\n    # The target will route records for 'my_custom_stream' to MyCustomStream\n    def get_available_streams(self) -> List[Stream]:\n        return [MyCustomStream(target=self)]\n\n# --- 2. How to run your target (simulated stdin) ---\n\n# This simulates the input a Singer tap would send to target_hotglue\nsample_singer_messages = [\n    {\"type\": \"SCHEMA\", \"stream\": \"my_custom_stream\", \"schema\": MyCustomStream.schema, \"key_properties\": MyCustomStream.key_properties},\n    {\"type\": \"RECORD\", \"stream\": \"my_custom_stream\", \"record\": {\"id\": 1, \"value\": \"Hello from Singer!\"}},\n    {\"type\": \"RECORD\", \"stream\": \"my_custom_stream\", \"record\": {\"id\": 2, \"value\": \"Another record.\"}},\n    {\"type\": \"STATE\", \"value\": {\"bookmarks\": {\"my_custom_stream\": {\"last_id\": 2}}}}\n]\n\ndef run_quickstart():\n    # Clean up previous run's output file\n    output_path = Path(os.environ.get(\"TARGET_HOTGLUE_OUTPUT_FILE\", \"quickstart_output.jsonl\"))\n    if output_path.exists():\n        output_path.unlink()\n\n    # Initialize the target with a configuration (can be from env vars or a file)\n    # Using os.environ.get for config values as requested.\n    config = {\n        \"output_file\": os.environ.get(\"TARGET_HOTGLUE_OUTPUT_FILE\", \"quickstart_output.jsonl\")\n    }\n    target_instance = MyCustomTarget(config=config)\n\n    # Manually process sample messages (this replaces target_instance.listen_for_messages() for demo)\n    print(f\"Processing {len(sample_singer_messages)} sample messages...\")\n    for message in sample_singer_messages:\n        target_instance._process_message(message) # Use internal method for demo simplicity\n\n    print(f\"\\nQuickstart finished.\")\n    if output_path.exists():\n        print(f\"Content written to '{output_path}':\")\n        print(output_path.read_text())\n    else:\n        print(\"No output file was created. Check stream configuration.\")\n\nif __name__ == \"__main__\":\n    run_quickstart()","lang":"python","description":"This quickstart demonstrates how to define a custom target and stream using `target-hotglue` and simulate processing Singer messages. In a production environment, `target-hotglue` typically reads Singer messages from `stdin` via its `main` entry point. This example writes processed records to a local JSONL file defined by the `output_file` configuration setting, which can be overridden by the `TARGET_HOTGLUE_OUTPUT_FILE` environment variable."},"warnings":[{"fix":"Ensure your Python environment is between 3.7.1 and 3.10.x. Consider using `pyenv` or `conda` to manage Python versions. Example: `pyenv install 3.10.12 && pyenv local 3.10.12`","message":"`target-hotglue` currently has a Python version constraint of `<3.11`. Attempting to install or run it with Python 3.11 or newer will result in installation errors.","severity":"gotcha","affected_versions":"<0.1.11"},{"fix":"Always check the release notes for `singer-sdk` when upgrading either library. Pin specific versions of `singer-sdk` in your project's dependencies to prevent unexpected behavior: `pip install target-hotglue singer-sdk==0.X.Y`","message":"`target-hotglue` is built on top of `singer-sdk`. Breaking changes or significant updates in `singer-sdk` (especially between major or even minor versions like `0.x` to `0.y`) can indirectly impact your `target-hotglue` implementation, even if `target-hotglue` itself hasn't released a new version.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Thoroughly review `singer-sdk`'s documentation on state management. Ensure your target correctly reads and writes state messages, especially when using custom state backends or when running in environments like Hotglue that manage state externally.","message":"Proper Singer state management, inherited from `singer-sdk`, is crucial for correct data processing (avoiding reprocessing or data loss). Misunderstanding how state messages are handled or misconfiguring the target's state backend can lead to integrity issues.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Install the library using pip: `pip install target-hotglue`","cause":"The `target-hotglue` library has not been installed or is not accessible in the current Python environment.","error":"ModuleNotFoundError: No module named 'target_hotglue'"},{"fix":"Switch to a supported Python version (e.g., 3.7-3.10). You can use tools like `pyenv` or `conda` for environment management. Example: `pyenv local 3.10.12` or create a new virtual environment with `python3.10 -m venv .venv`.","cause":"The Python version being used is not compatible with the `target-hotglue` library's requirements.","error":"ERROR: Package 'target-hotglue' requires Python '>=3.7.1, <3.11' but the running Python is 3.11.X"},{"fix":"Review your target's `config_jsonschema` and ensure all required configuration keys are present and correctly formatted in your configuration file or environment variables. Example: `echo '{\"output_file\": \"my_output.jsonl\"}' > config.json`","cause":"Your target's configuration (e.g., in `config.json` or environment variables) is missing a required field defined in your `config_jsonschema` or expected by the target's logic.","error":"KeyError: 'some_required_setting'"}]}