Metadata-Version: 2.4
Name: detectmatelibrary
Version: 0.3.2
Summary: DetectMate Library for log processing components
Author: André García Gómez, Viktor Beck, Thorina Boenke, Wolfgang Hotwagner, Anna Erdi, Ernst Leierzopf
License-Expression: EUPL-1.2
Project-URL: Homepage, https://ait-detectmate.github.io/DetectMateLibrary/latest
Project-URL: Repository, https://github.com/ait-detectmate/DetectMateLibrary
Requires-Python: >=3.12
Description-Content-Type: text/markdown
License-File: LICENSE.md
Requires-Dist: protobuf>=6.32.1
Requires-Dist: pydantic>=2.13.3
Requires-Dist: pyyaml>=6.0.3
Requires-Dist: regex>=2025.11.3
Requires-Dist: openai>=2.26.0
Requires-Dist: tenacity>=9.1.4
Requires-Dist: scipy>=1.17.1
Requires-Dist: scikit-learn>=1.8.0
Requires-Dist: tiktoken>=0.12.0
Requires-Dist: numpy>=2.3.2
Requires-Dist: pandas>=2.3.2
Requires-Dist: polars>=1.40.1
Requires-Dist: detectmateperformance>=0.1.0
Requires-Dist: msgpack>=1.0.0
Requires-Dist: fsspec>=2024.1.0
Requires-Dist: pyarrow>=24.0.0
Provides-Extra: polars-rtcompat
Requires-Dist: polars[rtcompat]>=1.38.1; extra == "polars-rtcompat"
Dynamic: license-file

# DetectMateLibrary

Main library to run the different components in DetectMate.

## Main structure

The library contains the next components:

* **Parsers**: parse the logs received from the reader.
* **Detectors**: return alerts if anomalies are detected.
* **Alert Aggregation**: aggregate the alerts produced by the detectors.
* **Schemas**: standard data classes use in DetectMate.
```
 +--------+     +-----------+    +-------------------+
 | Parser | --> |  Detector | -> | Alert Aggregation |
 +--------+     +-----------+    +-------------------+
```
## Developer setup:

### Step 1: Install python dependencies
Set up the dev environment and install pre-commit hooks:

```bash
uv sync --dev
uv run prek install
```

### Step 2: Install Protobuf dependencies

To install in Linux do:

```bash
sudo apt install -y protobuf-compiler
protoc --version
```

This dependency is only needed if a proto file is modified. To compile the proto file do:
```bash
protoc --proto_path=src/detectmatelibrary/schemas/ --python_out=src/detectmatelibrary/schemas/ src/detectmatelibrary/schemas/schemas.proto
```

### Step 3: Run unit tests
Run the tests:

```bash
uv run pytest -q
```

Run the tests with coverage (add --cov-report=html to generate an HTML report):

```bash
uv run pytest --cov=. --cov-report=term-missing
```

## Workspace generator (`mate create`)

DetectMateLibrary includes a small CLI helper to bootstrap standalone workspaces
for custom parsers and detectors. This is useful if you want to develop and test
components in isolation while still using the same library and schemas.

### Usage

The CLI entry point is `mate` with a `create` command:

```bash
mate create --type <parser|detector> --name <workspace_name> --dir <target_dir>
```

| Option   | Description                                                                                                                                                                   |
|----------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `--type` | Component type to generate:<br>- `parser`: CoreParser-based template<br>- `detector`: CoreDetector-based template                                                             |
| `--name` | Name of the component and package:<br>- Creates package dir: `<target_dir>/<name>/`<br>- Creates main file: `<name>.py`<br>- Derives class names: `<Name>` and `<Name>Config` |
| `--dir`  | Directory where the workspace will be created                                                                                                                                 |


### What gets generated

For example:

```bash
mate create --type parser --name custom_parser --dir ./workspaces/custom_parser
```

will create:

```text
workspaces/custom_parser/          # workspace root
├── custom_parser/                 # Python package
│   ├── __init__.py
│   └── custom_parser.py           # CoreParser-based template
├── tests/
│   └── test_custom_parser.py      # generated from template to test custom_parser
├── data.json                      # example data to run the code
├── LICENSE.md                     # copied from main project
├── .gitignore                     # copied from main project
├── .pre-commit-config.yaml        # copied from main project
├── pyproject.toml                 # minimal project + dev extras
└── README.md                      # setup instructions
```

## Documentation

- [Project Documentation](https://ait-detectmate.github.io/DetectMateLibrary/latest/)

## Contribution

We're happily taking patches and other contributions. Please see the following links for how to get started:

- [GitHub Workflow](https://ait-detectmate.github.io/DetectMateLibrary/latest/contribution/)

If you encounter any bugs, please create an issue on [Github](https://github.com/ait-detectmate/DetectMateLibrary/issues).

## License

[EUPL-1.2](https://github.com/ait-detectmate/DetectMateLibrary/blob/main/LICENSE.md)
