Comprehensive library for seamless integration with AWS, OpenAI, and utility tools.
Project description
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")
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file wrenchcl-5.2.0.tar.gz.
File metadata
- Download URL: wrenchcl-5.2.0.tar.gz
- Upload date:
- Size: 172.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.12 {"installer":{"name":"uv","version":"0.11.12","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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aa9e533156465c3777f93bfc9281477f712796aa4e305712c1abd1e1f8182aea
|
|
| MD5 |
bfd016b7d963021916f77b578a8420b9
|
|
| BLAKE2b-256 |
3dc30a9bf16dc3d21bab98454cc114f87845135e497d6ba8e8ddbe313431adfc
|
File details
Details for the file wrenchcl-5.2.0-py3-none-any.whl.
File metadata
- Download URL: wrenchcl-5.2.0-py3-none-any.whl
- Upload date:
- Size: 89.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.12 {"installer":{"name":"uv","version":"0.11.12","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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b7ee6b9fa7837ffebdab9a9f41b6a8294f63b36e42a0238634f08997d5c6a824
|
|
| MD5 |
1839f03b64eec78581c53d46033f6e71
|
|
| BLAKE2b-256 |
95bcc00986514ec5070028923e3f589d92e07646ece2a189d892ed7e20e88558
|