|
| 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 | +This is `sz-sdk-python`, the Senzing Python SDK containing abstract base classes from which concrete implementations (Core and gRPC) are derived. The package is published to PyPI as `senzing`. |
| 8 | + |
| 9 | +## Development Commands |
| 10 | + |
| 11 | +### Setup and Dependencies |
| 12 | + |
| 13 | +```bash |
| 14 | +# Create virtual environment and install all development dependencies |
| 15 | +make dependencies-for-development |
| 16 | + |
| 17 | +# Install package dependencies only |
| 18 | +make dependencies |
| 19 | +``` |
| 20 | + |
| 21 | +### Linting |
| 22 | + |
| 23 | +```bash |
| 24 | +# Run all linters (pylint, mypy, bandit, black, flake8, isort) |
| 25 | +make lint |
| 26 | + |
| 27 | +# Run individual linters |
| 28 | +make pylint |
| 29 | +make mypy |
| 30 | +make black |
| 31 | +make flake8 |
| 32 | +make isort |
| 33 | +make bandit |
| 34 | +``` |
| 35 | + |
| 36 | +### Testing |
| 37 | + |
| 38 | +```bash |
| 39 | +# Run full test suite (requires Senzing C library installed) |
| 40 | +make clean setup test |
| 41 | + |
| 42 | +# Run unit tests only |
| 43 | +pytest tests/ --verbose --capture=no |
| 44 | + |
| 45 | +# Run a single test file |
| 46 | +pytest tests/szengine_test.py --verbose |
| 47 | + |
| 48 | +# Run a specific test |
| 49 | +pytest tests/szengine_test.py::test_add_record --verbose |
| 50 | + |
| 51 | +# Run tests with coverage |
| 52 | +make coverage |
| 53 | +``` |
| 54 | + |
| 55 | +### Build and Package |
| 56 | + |
| 57 | +```bash |
| 58 | +make package # Build wheel file |
| 59 | +make publish-test # Publish to Test PyPI |
| 60 | +``` |
| 61 | + |
| 62 | +### Documentation |
| 63 | + |
| 64 | +```bash |
| 65 | +make documentation # Build and view Sphinx docs |
| 66 | +``` |
| 67 | + |
| 68 | +## Architecture |
| 69 | + |
| 70 | +### Package Structure |
| 71 | + |
| 72 | +- `src/senzing/` - Main package with abstract base classes defining the SDK interface |
| 73 | +- `src/senzing_mock/` - Mock implementations for testing |
| 74 | +- `src/senzing_truthset/` - Sample test data (customers, references, watchlist) |
| 75 | + |
| 76 | +### Core Abstract Classes |
| 77 | + |
| 78 | +The SDK defines abstract base classes that implementations must fulfill: |
| 79 | + |
| 80 | +- **SzAbstractFactory** - Factory pattern for creating SDK objects. Concrete implementations: |
| 81 | + - `SzAbstractFactoryCore` (in sz-sdk-python-core) |
| 82 | + - `SzAbstractFactoryGrpc` (in sz-sdk-python-grpc) |
| 83 | + |
| 84 | +- **SzEngine** - Main entity resolution engine with methods like: |
| 85 | + - `add_record()`, `delete_record()` - Record management |
| 86 | + - `get_entity_by_*()` - Entity retrieval |
| 87 | + - `find_path_by_*()`, `find_network_by_*()` - Relationship discovery |
| 88 | + - `why_*()` - Explain entity resolution decisions |
| 89 | + - `search_by_attributes()` - Search functionality |
| 90 | + |
| 91 | +- **SzConfig** - Configuration management |
| 92 | +- **SzConfigManager** - Configuration versioning and registry |
| 93 | +- **SzDiagnostic** - System diagnostics |
| 94 | +- **SzProduct** - License and version info |
| 95 | + |
| 96 | +### Error Hierarchy |
| 97 | + |
| 98 | +`src/senzing/szerror.py` contains the exception hierarchy (auto-generated): |
| 99 | + |
| 100 | +- `SzError` - Base exception |
| 101 | +- `SzBadInputError` - User input errors (SzNotFoundError, SzUnknownDataSourceError) |
| 102 | +- `SzRetryableError` - Transient errors that can be retried |
| 103 | +- `SzUnrecoverableError` - Fatal errors (SzDatabaseError, SzLicenseError) |
| 104 | + |
| 105 | +### Engine Flags |
| 106 | + |
| 107 | +`SzEngineFlags` in `szengineflags.py` controls what information is returned from SDK methods. |
| 108 | + |
| 109 | +## Code Style |
| 110 | + |
| 111 | +- Line length: 120 characters (black, flake8) |
| 112 | +- Type hints: Required (`mypy --strict`) |
| 113 | +- Import sorting: isort with black profile |
| 114 | +- Security: bandit for security checks (B101 skipped for assert usage) |
| 115 | + |
| 116 | +## Testing Approach |
| 117 | + |
| 118 | +Tests use pytest with mock implementations from `senzing_mock`. The mock classes implement all abstract methods with minimal return values, allowing interface verification without requiring the actual Senzing engine. |
| 119 | + |
| 120 | +- Tests in `tests/` verify the abstract interface. |
| 121 | +- Tests in `examples/` serve as both documentation and integration tests. |
| 122 | + |
| 123 | +## Prerequisites |
| 124 | + |
| 125 | +The Senzing C library must be installed at `/opt/senzing/er/lib` for running tests against actual implementations. |
0 commit comments