{"library":"snakemake-interface-logger-plugins","title":"Snakemake Logger Plugin Interface","type":"library","description":"The `snakemake-interface-logger-plugins` library provides the abstract base classes and registry for implementing custom logger plugins for Snakemake. It defines the interface for `LoggerPlugin` and `LoggerWrapper` classes, allowing users to extend Snakemake's logging capabilities. The current version is 2.0.1 and it follows the Snakemake plugin API's release cadence, typically tied to major Snakemake versions.","language":"python","status":"active","last_verified":"Mon May 18","install":{"commands":["pip install snakemake-interface-logger-plugins","pip install snakemake"],"cli":null},"imports":["from snakemake_interface_logger_plugins.plugin import LoggerPlugin","from snakemake_interface_logger_plugins.wrapper import LoggerWrapper","from snakemake_interface_logger_plugins.settings import CommonLoggerSettings"],"auth":{"required":false,"env_vars":[]},"links":{"homepage":null,"github":null,"docs":null,"changelog":null,"pypi":"https://pypi.org/project/snakemake-interface-logger-plugins/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null},"quickstart":{"code":"import os\nfrom argparse import ArgumentParser\nfrom snakemake_interface_logger_plugins.plugin import LoggerPlugin\nfrom snakemake_interface_logger_plugins.wrapper import LoggerWrapper\nfrom snakemake_interface_logger_plugins.settings import CommonLoggerSettings\n\n# Save this as my_custom_logger.py\n\nclass MyLoggerPlugin(LoggerPlugin):\n    \"\"\"A simple custom logger plugin for Snakemake.\"\"\"\n    def __init__(self, settings: CommonLoggerSettings | None = None):\n        self.settings = settings\n\n    def register_args(self, argparser: ArgumentParser):\n        \"\"\"Register command line arguments for this plugin.\"\"\"\n        argparser.add_argument(\n            \"--my-logger-prefix\",\n            default=\"[CUSTOM LOG]\",\n            help=\"Prefix for custom logger messages.\"\n        )\n\n    def setup(self):\n        \"\"\"Perform setup actions before any logging occurs.\"\"\"\n        # Access custom args via self.settings if defined\n        # print(f\"{self.settings.my_logger_prefix} Initializing MyLoggerPlugin...\")\n        pass # For this minimal example, we don't need complex setup\n\n    def get_wrapper(self) -> LoggerWrapper:\n        \"\"\"Return an instance of the logger wrapper.\"\"\"\n        return MyLoggerWrapper(self.settings)\n\nclass MyLoggerWrapper(LoggerWrapper):\n    \"\"\"Handles actual logging events.\"\"\"\n    def __init__(self, settings: CommonLoggerSettings | None = None):\n        self.settings = settings\n\n    def handle_info(self, msg: str):\n        prefix = getattr(self.settings, 'my_logger_prefix', '[MYLOGGER]')\n        print(f\"{prefix} INFO: {msg}\")\n\n    def handle_error(self, msg: str):\n        prefix = getattr(self.settings, 'my_logger_prefix', '[MYLOGGER]')\n        print(f\"{prefix} ERROR: {msg}\")\n\n    # Implement other handle_* methods as needed for full functionality\n    # e.g., handle_log, handle_job_info, handle_job_error, handle_start, handle_finish, etc.\n    # For this example, we only show info and error.\n    # All abstract methods must be implemented, even if with a 'pass'\n    def handle_log(self, msg: str):\n        prefix = getattr(self.settings, 'my_logger_prefix', '[MYLOGGER]')\n        print(f\"{prefix} LOG: {msg}\")\n\n    def handle_start(self):\n        prefix = getattr(self.settings, 'my_logger_prefix', '[MYLOGGER]')\n        print(f\"{prefix} Workflow started.\")\n\n    def handle_finish(self):\n        prefix = getattr(self.settings, 'my_logger_prefix', '[MYLOGGER]')\n        print(f\"{prefix} Workflow finished.\")\n\n    def handle_job_info(self, job_info: dict):\n        prefix = getattr(self.settings, 'my_logger_prefix', '[MYLOGGER]')\n        print(f\"{prefix} Job info: {job_info.get('jobid')} - {job_info.get('output')}\")\n\n    def handle_job_error(self, job_info: dict):\n        prefix = getattr(self.settings, 'my_logger_prefix', '[MYLOGGER]')\n        print(f\"{prefix} Job error: {job_info.get('jobid')} - {job_info.get('output')}\")\n\n# To run this with Snakemake, save it as `my_custom_logger.py` and then run:\n# snakemake --snakefile Snakefile --logger-plugin my_custom_logger.py --my-logger-prefix \"[SNAKEMAKE-CUSTOM]\" -c1\n# (Requires a simple Snakefile, e.g., 'rule all: run: print(\"Hello from Snakemake\")')\n","lang":"python","description":"This quickstart demonstrates how to create a basic Snakemake logger plugin. It defines `MyLoggerPlugin` (the entry point for Snakemake) and `MyLoggerWrapper` (which handles the actual logging messages). It also shows how to register custom command-line arguments and access them via settings. To use, save the code as `my_custom_logger.py` and run Snakemake with `--logger-plugin my_custom_logger.py`.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":{"tag":null,"tag_description":null,"last_tested":"2026-05-18","installed_version":"2.0.1","pypi_latest":"2.0.1","is_stale":false,"summary":{"python_range":"3.10–3.9","success_rate":60,"avg_install_s":6.5,"avg_import_s":null,"wheel_type":"wheel"},"results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"snakemake","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"snakemake-interface-logger-plugins","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"snakemake","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":12.4,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"snakemake-interface-logger-plugins","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":1.4,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"snakemake","exit_code":0,"wheel_type":"sdist","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"130.7M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"snakemake-interface-logger-plugins","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"20.8M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"snakemake","exit_code":0,"wheel_type":"sdist","failure_reason":null,"import_side_effects":"broken","install_time_s":11.6,"import_time_s":null,"mem_mb":null,"disk_size":"129M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"snakemake-interface-logger-plugins","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":1.9,"import_time_s":null,"mem_mb":null,"disk_size":"21M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"snakemake","exit_code":0,"wheel_type":"sdist","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"119.0M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"snakemake-interface-logger-plugins","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"12.6M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"snakemake","exit_code":0,"wheel_type":"sdist","failure_reason":null,"import_side_effects":"broken","install_time_s":11.3,"import_time_s":null,"mem_mb":null,"disk_size":"117M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"snakemake-interface-logger-plugins","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":1.7,"import_time_s":null,"mem_mb":null,"disk_size":"13M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"snakemake","exit_code":0,"wheel_type":"sdist","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"118.6M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"snakemake-interface-logger-plugins","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"12.4M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"snakemake","exit_code":0,"wheel_type":"sdist","failure_reason":null,"import_side_effects":"broken","install_time_s":10.8,"import_time_s":null,"mem_mb":null,"disk_size":"117M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"snakemake-interface-logger-plugins","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":1.7,"import_time_s":null,"mem_mb":null,"disk_size":"13M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"snakemake","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"snakemake-interface-logger-plugins","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"snakemake","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":14,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"snakemake-interface-logger-plugins","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":1.7,"import_time_s":null,"mem_mb":null,"disk_size":null}]}}