find cold code
Project description
README
Coldmod-py is a tracing library for collecting runtime data from python code, and a CLI for configuration and codemods.
It's implemented with, and test against, the Python version found in .python-version
.
Tracing is implemented using "sys.settrace" - built into CPython.
The CLI, which is implemented with Python Fire, can be used to inspect configuration and apply code mods.
Installation
pip install coldmod-py
Setup
The CLI and tracing require these environment variables to be set
COLDMOD_GRPC_HOST
COLDMOD_TLS_CA
COLDMOD_WEB_HOST
COLDMOD_API_KEY
COLDMOD_INSECURE
See Env.md for details on how these environment variables are used.
Tracing
- toml file
(two threads)
CLI
Cacheing
-
parsing is expensive so trace srcs are cached per file, key by a digest of the relative path+contents
-
if the file changes you get a cache miss
-
the cache can be cleared with the cli
-
Get into the poetry env:
poetry shell
-
Run a sample:
python -m coldmod_py.samples.trace_target_1
-
Test command:
pytest[-watch]
-
Run the cli:
python -m coldmod <tracefile> <sourcepath>
-
to debug just add
breakpoint()
Development
ENV
COLDMOD_GRPC_HOST
COLDMOD_WEB_HOST
COLDMOD_CA
COLDMOD_API_KEY
Editable install
CLI
The CLI is used to apply code mods and check trace configuration.
Installation
Man page:
insert generated man page here
pyright
run it with brew install, it uses node... so I don't want to make every install it as a dep
- vendors coldmod-msg
- coldmod-msg dependencies are a subset of coldmod-py dependencies
setting up in an app via editable install of local checkout
- checkout the __coldmod branch (has a pyproject.toml which has coldmod-py as an editable install)
- activate an env for the app (see __coldmod branch)
- in that shell, go to the root of the app
- poetry install
- pip install -r requirements.txt
- add a line to the entrypoint
import coldmod_py; coldmod_py.tracing.start()
- add a coldmod.toml
- start the app
- if coldmod-d isn't running the app should carry on and start but with no tracing
- start coldmod-d
- restart the app
TODO:
- sender architecture
- caching
- commands
- connect
- ignoring
- about coldmod.rootmarker
- what happens in the web UI we the heatmap is truncated because of ignore.
- limitations of Remove (references)
- strategies of tracing (settrace vs modding, version drift)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.