Skip to main content

Comprehensive library for seamless integration with AWS, OpenAI, and utility tools.

Project description

Wrench Code Library

Tests Coverage Python 3.11+ License: MIT


ReadTheDocs


Description

WrenchCL is a comprehensive library designed to facilitate seamless interactions with AWS services, OpenAI models, and various utility tools. This package aims to streamline the development process by providing robust components for database interactions, cloud storage, and AI-powered functionalities.

PyPI Link: WrenchCL on PyPI

Installation

Basic Installation

To install the core package with minimal dependencies:

pip install WrenchCL

Optional Dependencies

WrenchCL uses optional dependencies to keep the core package lightweight while providing additional functionality when needed:

Color Support (Logger)

pip install WrenchCL[color]
# Adds: colorama for beautiful terminal colors

AWS Services

pip install WrenchCL[aws]
# Adds: boto3, psycopg2-binary, sshtunnel, and AWS service type hints
# Enables: RDS connections, S3 operations, Lambda functions, Secrets Manager

Distributed Tracing

pip install WrenchCL[trace]
# Adds: ddtrace for Datadog APM integration
# Enables: Automatic trace correlation in logs

Development Tools

pip install WrenchCL[dev]
# Adds: pytest, coverage, pydantic for development and testing

Complete Installation

pip install WrenchCL[all]
# Installs all optional dependencies for full functionality

Development

To locally develop the plugin, clone the repository locally and make your changes.

Open the console in your working directory; the building command is

python setup.py sdist bdist_wheel

You can then install the package with

pip install ./dist/WrenchCL-0.0.1.dev0-py3-none-any.whl --force-reinstall

Use the --no-dependencies flag to reinstall quickly if there are no dependency changes

pip install ./dist/WrenchCL-0.0.1.dev0-py3-none-any.whl --force-reinstall --no-dependencies

Logger

WrenchCL ships a structured, colorized logger available as a singleton:

from WrenchCL import logger

Output modes

Mode When to use
terminal Local development — colorized, multi-line, syntax-highlighted
json Deployed services — single-line JSON with Datadog triad fields
compact Space-constrained output — single-line, no color
logger.configure(mode="json")          # structured JSON
logger.configure(mode="terminal")      # colored terminal output (default)
logger.configure(deployment_mode=True) # deployed terminal — no color, shows context prefix

Logging methods

logger.debug("message")
logger.info("message")
logger.warning("message")
logger.error("message")
logger.critical("message")
logger.exception("message")   # ERROR level + current exception info

logger.data(obj)               # pretty-print dicts, DataFrames, Pydantic models
logger.header("Section title") # formatted section header

Context prefix

In deployed or verbose mode every log line includes a bracket group that identifies the run, request context, and thread:

[A3X7K | api-handler | Thread-2 | WrenchCL] INFO    [12:34:56|file.py:10] -> message

Scoped prefix — the primary way to attach a prefix. Uses contextvars.ContextVar so it is per-context (thread and async-task safe) and cleans up automatically:

# Context manager — prefix active only inside the block
with logger.prefix("api-handler"):
    logger.info("handling request")   # [run_id | api-handler | WrenchCL]

logger.info("idle")                   # [run_id | WrenchCL]

# Decorator — prefix active for the entire function or method call
@logger.prefix("PaymentService")
def process_payment(order_id):
    logger.info("processing %s", order_id)

Global prefix — process-wide fallback, overridden by any scoped prefix:

logger.set_prefix("worker-1")   # set
logger.set_prefix()             # clear

Thread name — opt-in, off by default:

logger.configure(show_thread_name=True)
# [run_id | prefix | Thread-2 | WrenchCL]

Run ID — a 5-character uppercase alphanumeric ID generated at startup, refreshed with:

logger.initiate_new_run()
print(logger.run_id)   # e.g. "A3X7K"

Datadog integration

Install the trace extra and set LOG_DD_TRACE=true:

pip install WrenchCL[trace]
LOG_DD_TRACE=true python app.py

dd.trace_id and dd.span_id are injected automatically into JSON log records for APM correlation. In AWS Lambda or ECS the logger auto-detects the environment and switches to JSON mode.

Configuration reference

logger.configure(
    mode="terminal",          # "terminal" | "json" | "compact"
    level="INFO",             # "DEBUG" | "INFO" | "WARNING" | "ERROR" | "CRITICAL"
    deployment_mode=False,    # strip color, activate context prefix
    show_thread_name=False,   # include thread name in context bracket
    prefix=None,              # global prefix string
    color_enabled=True,
    highlight_syntax=True,
    trace_enabled=False,      # Datadog APM correlation
)

Temporary overrides:

with logger.temporary(level="DEBUG", mode="compact"):
    logger.debug("verbose output for this block only")

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wrenchcl-6.0.6.tar.gz (157.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

wrenchcl-6.0.6-py3-none-any.whl (68.3 kB view details)

Uploaded Python 3

File details

Details for the file wrenchcl-6.0.6.tar.gz.

File metadata

  • Download URL: wrenchcl-6.0.6.tar.gz
  • Upload date:
  • Size: 157.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.20 {"installer":{"name":"uv","version":"0.11.20","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for wrenchcl-6.0.6.tar.gz
Algorithm Hash digest
SHA256 6eee8ef11d7a10cbf5ec7ca58444beb64dbb2b7347f55196452e481cf7772491
MD5 6369010ac3c0f2b292623f600a3da98d
BLAKE2b-256 2d89cc09c1791247a0ba49d75a936a62114f6b04edaaf58670f03dbd65e44d7d

See more details on using hashes here.

File details

Details for the file wrenchcl-6.0.6-py3-none-any.whl.

File metadata

  • Download URL: wrenchcl-6.0.6-py3-none-any.whl
  • Upload date:
  • Size: 68.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.20 {"installer":{"name":"uv","version":"0.11.20","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for wrenchcl-6.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 3c3c9a264ab9cdf2b24a4ffe941413038618301f9fa5e740f6bf8dea7d3c2f1f
MD5 d2656508e5fdfd20b18bd8a61b0c21c7
BLAKE2b-256 d4f1fe8e2d0ba9859f7116de07b2eacd6771e4f2412ccf51feafd8b5a59bf65f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page