Installation
Requirements
- Python 3.12 or newer. If you don't have it, uv can install it for you:
uv python install 3.12. - uv (recommended) or pip.
- git, to get the source code.
Install from source
It is recommended to use uv for installation. Clone the repository and install it from the project root:
git clone https://github.com/ait-detectmate/DetectMateLibrary.git
cd DetectMateLibrary
uv sync
(If you prefer pip/venv, create a virtualenv first.)
Changes to the source tree are then reflected immediately. To install DetectMate as a library into a different environment instead:
uv pip install --no-cache-dir <directory_detectmatelibrary>
Optional dependencies
Not every feature needs the same dependencies, so DetectMate uses optional extras: you install only what you need.
| Extra | Installs | When you need it |
|---|---|---|
llm |
openai, tenacity, scipy, scikit-learn, tiktoken, pandas |
Using the LogBatcherParser (LLM-based log parsing). |
alertbert |
torch, tensordict, scikit-learn, scipy |
Using the AlertBERTAggregation. |
full |
All of the above. | Installing every optional extra at once. |
To have a closer look at all the dependencies, see Optional dependencies.
Install an extra with uv sync:
uv sync --extra dataframes
Or with uv pip install / pip when installing as a library:
uv pip install "detectmatelibrary[llm]"
Combine multiple extras if needed:
uv sync --extra llm --extra palertbert
Or install everything at once with the full extra:
uv pip install "detectmatelibrary[full]"
Developer setup
Only needed for development
Only follow these steps if you are contributing to DetectMate.
Step 1: Install Python development dependencies & pre-commit hooks
- Install dev dependencies (testing, linters, formatters). The
devgroup also pulls in thefullextra, so every optional dependency (LLM, dataframes, polars-rtcompat) is installed too:
uv sync --dev
- Install pre-commit hooks (this repository uses
prekto run pre-commit tooling):
uv run --dev prek install
Notes:
- Ensure
uvis available in PATH. If not, use your system Python + virtualenv and thenuv sync --dev. - Run the pre-commit hooks locally with
uv run --dev prek run -abefore committing to catch style/typing issues early.
Step 2: Install Protobuf toolchain (only if you change proto files)
Purpose: compile .proto definitions into Python code.
- Install
protocon Debian/Ubuntu:
sudo apt-get update
sudo apt-get install -y protobuf-compiler
protoc --version
- Compile the project proto:
protoc \
--proto_path=src/detectmatelibrary/schemas/protobuf/ \
--python_out=src/detectmatelibrary/schemas/protobuf/ \
src/detectmatelibrary/schemas/protobuf/schemas.proto
Result: generated Python modules appear under src/detectmatelibrary/schemas/protobuf/. If you edit proto files, re-run this command and commit generated code if required by your workflow.
Step 3: Run unit tests
The full test suite covers dataframe and LLM-parser code, so all extras must be present. Since uv sync --dev already installs the full extra, run the fast tests with:
uv run --dev pytest -s
To run all unit tests, first start the database containers:
docker compose -f tests/test_schemas/compose.yaml up -d
and then run:
uv run pytest --run-ignored --run-ignored-mongo --run-ignored-redis
- Run tests with coverage (terminal summary):
uv run --dev pytest --cov=. --cov-report=term-missing
Tips:
- Run a single test or directory to speed iteration:
uv run --dev pytest tests/some_test.py::test_name -q
Troubleshooting
- If
uvis unavailable, use a Python virtualenv and thepip/pytestcommands directly. - If
protocis missing, install the system package or download a prebuilt binary for your OS. - Always run commands from the project root so file paths (
pyproject.toml,src/) resolve correctly.