Wrench Code Library
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")
Release files for WrenchCL 6.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| wrenchcl-6.4.0.tar.gz | 159.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| wrenchcl-6.4.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 229.2 kB
Release files / wrenchcl-6.4.0.tar.gz
| Download URL | wrenchcl-6.4.0.tar.gz |
|---|---|
| Size | 159.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a336fa4cd4c2d2d7ba4f2d5dccecc99ccac8f47591f63150866f2c45f965a29b
|
|
BLAKE2b-256 checksum How to use checksums |
4ea279c9d9fa222c83b5c575b4981b181cd43eceda7e69be0eb8d8517719b230
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.3 {"installer":{"name":"uv","version":"0.12.3","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}
|
Release files / wrenchcl-6.4.0-py3-none-any.whl
| Download URL | wrenchcl-6.4.0-py3-none-any.whl |
|---|---|
| Size | 69.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7bee041ae07d2f71f9c9b51925e804044eb65d716cad975d24b9469753f05ae4
|
|
BLAKE2b-256 checksum How to use checksums |
af86dba0b34729cc57b892bd74c7ce287b172c812f3bc37598fdc95c39255c7a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.3 {"installer":{"name":"uv","version":"0.12.3","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}
|