|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +sz-python-tools is a collection of command-line utilities for the Senzing entity resolution platform (V4). This is a Senzing Garage project (experimental/tinkering), not production-ready software. |
| 8 | + |
| 9 | +## Common Commands |
| 10 | + |
| 11 | +```bash |
| 12 | +# Setup development environment (one-time) |
| 13 | +make dependencies-for-development |
| 14 | + |
| 15 | +# Run all linters (pylint, mypy, bandit, black, flake8, isort) |
| 16 | +make lint |
| 17 | + |
| 18 | +# Run individual linters |
| 19 | +make pylint |
| 20 | +make mypy |
| 21 | +make black |
| 22 | +make flake8 |
| 23 | +make isort |
| 24 | +make bandit |
| 25 | + |
| 26 | +# Run tests |
| 27 | +make test |
| 28 | + |
| 29 | +# Run tests with coverage (opens HTML report) |
| 30 | +make coverage |
| 31 | + |
| 32 | +# Clean build artifacts |
| 33 | +make clean |
| 34 | + |
| 35 | +# Build documentation |
| 36 | +make documentation |
| 37 | + |
| 38 | +# Build wheel package |
| 39 | +make package |
| 40 | +``` |
| 41 | + |
| 42 | +To run a single test file: |
| 43 | + |
| 44 | +```bash |
| 45 | +source .venv/bin/activate |
| 46 | +pytest tests/example_test.py |
| 47 | +``` |
| 48 | + |
| 49 | +## Architecture |
| 50 | + |
| 51 | +### Source Organization |
| 52 | + |
| 53 | +All source code is in `sz_tools/` directory. Each tool is a standalone executable Python script (no .py extension): |
| 54 | + |
| 55 | +**Interactive Shell Tools** (using Python's `cmd.Cmd`): |
| 56 | + |
| 57 | +- `sz_command` - Main CLI shell for Senzing engine operations |
| 58 | +- `sz_configtool` - Configuration management shell |
| 59 | +- `sz_explorer` - Entity/database explorer with prettytable output |
| 60 | + |
| 61 | +**Data Processing Tools**: |
| 62 | + |
| 63 | +- `sz_file_loader` - Multi-threaded data file loading (JSON/JSONL) |
| 64 | +- `sz_export` - Entity data export (CSV/JSONL) |
| 65 | +- `sz_snapshot` - Database state snapshots with multi-process support |
| 66 | +- `sz_audit` - Data comparison and auditing |
| 67 | +- `sz_json_analyzer` - JSON/JSONL file analysis |
| 68 | + |
| 69 | +**Project Management**: |
| 70 | + |
| 71 | +- `sz_create_project` - Create new Senzing project instances |
| 72 | +- `sz_update_project` - V3→V4 and V4→V4 project upgrades |
| 73 | +- `sz_setup_config` - Initialize Senzing configuration |
| 74 | + |
| 75 | +### Shared Modules |
| 76 | + |
| 77 | +- `_tool_helpers.py` - Comprehensive utilities: color theming (Colors class with ANSI codes), engine configuration, JSON formatting, terminal I/O, concurrent execution |
| 78 | +- `_project_helpers.py` - Project file management, version comparison (SzBuildDetails class), Senzing paths |
| 79 | +- `_sz_database.py` - Database abstraction layer supporting SQLite, PostgreSQL, Oracle, MSSQL, DB2, MySQL |
| 80 | + |
| 81 | +### Key Patterns |
| 82 | + |
| 83 | +- Color output uses the `Colors` class with themes: DEFAULT, LIGHT, DARK, TERMINAL |
| 84 | +- JSON parsing uses `orjson` if available, with fallback to standard `json` |
| 85 | +- Configuration stored in `sz_engine_config.ini` |
| 86 | +- Interactive shells provide command history via readline |
| 87 | + |
| 88 | +## Code Style |
| 89 | + |
| 90 | +- **Line length**: 120 characters (Black formatter) |
| 91 | +- **Import sorting**: isort with "black" profile |
| 92 | +- **Type hints**: Gradual typing (mypy configured with relaxed checking) |
| 93 | +- Python 3.10+ required |
| 94 | + |
| 95 | +## Dependencies |
| 96 | + |
| 97 | +Core runtime dependencies: |
| 98 | + |
| 99 | +- `senzing >= 4.0.2` |
| 100 | +- `senzing-core >= 1.0.0` |
| 101 | + |
| 102 | +Optional (with graceful fallbacks): |
| 103 | + |
| 104 | +- `orjson` - Fast JSON parsing |
| 105 | +- `prettytable` - ASCII table output |
| 106 | +- `pyclip` - Clipboard integration |
| 107 | +- `pygments` - Syntax highlighting |
| 108 | + |
| 109 | +## Environment |
| 110 | + |
| 111 | +The Senzing C library must be installed: |
| 112 | + |
| 113 | +- `/opt/senzing/er/lib` - Shared objects |
| 114 | +- `/opt/senzing/er/sdk/c` - SDK headers |
| 115 | +- `/etc/opt/senzing` - Configuration |
0 commit comments