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

This version

6.0.1

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.1.tar.gz (155.1 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.1-py3-none-any.whl (65.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: wrenchcl-6.0.1.tar.gz
  • Upload date:
  • Size: 155.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","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.1.tar.gz
Algorithm Hash digest
SHA256 d7be6ff6e9a9fb35d7c3e8315a6859460f90f2e9ae30d8b877f30ad984f37216
MD5 2dc7f23dc00e24971deb1dd206eb93ce
BLAKE2b-256 94b07a1b73f7513eec7118c15dca0d66bc25e65c210a56a87e6f159928f9b8a9

See more details on using hashes here.

File details

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

File metadata

  • Download URL: wrenchcl-6.0.1-py3-none-any.whl
  • Upload date:
  • Size: 65.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 21de11f43b0f25ac9c6c212530adb5a05cf97fb9c63b78c92e3d149acb256e01
MD5 f7ada8d50c2b7a26161c81c446c36b13
BLAKE2b-256 7b04fddb0bc5d6f83d875db08aa6dbd36929e3e82f5138e399dc7edbcab0b5c2

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