Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/publish-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ jobs:
with:
fetch-depth: 0

- name: Set up uv (Python 3.12)
- name: Set up uv (Python 3.13)
uses: astral-sh/setup-uv@v5
with:
python-version: "3.12"
python-version: "3.13"
enable-cache: true

- name: Install dependencies
Expand Down
7 changes: 2 additions & 5 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up uv (Python 3.12)
- name: Set up uv (Python 3.13)
uses: astral-sh/setup-uv@v6.6.0
with:
python-version: "3.12"
python-version: "3.13"
activate-environment: true
enable-cache: true

Expand All @@ -26,8 +26,5 @@ jobs:
- name: Run pre-commit with prek
run: uv run --dev prek run -a

- name: Compile
run: sh compile.sh

- name: Test with pytest
run: uv run --dev pytest -s
2 changes: 1 addition & 1 deletion .python-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.12
3.13
10 changes: 5 additions & 5 deletions compile.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@

# Update python dependencies
uv sync
$HOME/.local/bin/uv sync

# Remove old build
rm -rf build
rm src/detectmateperformance/_core/*.so
mkdir build

# Run cmake and build
Expand All @@ -16,10 +15,11 @@ cd ..
# Move compiled C++ code
mkdir lib
cp build/bind_class* src/detectmateperformance/lib/
chmod 775 src/detectmateperformance/lib/*

# Install package
uv pip uninstall detectmateperformance
uv pip install --no-cache-dir .
$HOME/.local/bin/uv pip uninstall detectmateperformance
$HOME/.local/bin/uv pip install --no-cache-dir .

# Run tests
uv run pytest
$HOME/.local/bin/uv run pytest
25 changes: 25 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
services:
arm64_builder:
image: arm64v8/gcc:latest
container_name: arm64_builder
platform: linux/arm64
volumes:
- ./:/app
working_dir: /app
command: >
sh -c "
apt-get update && apt-get install -y python3 curl cmake python3-dev &&
curl -LsSf https://astral.sh/uv/install.sh | sh &&
sh compile.sh"

x86_64_builder:
image: gcc:latest
container_name: x86_64_builder
volumes:
- ./:/app
working_dir: /app
command: >
sh -c "
apt-get update && apt-get install -y python3 curl cmake python3-dev &&
curl -LsSf https://astral.sh/uv/install.sh | sh &&
sh compile.sh"
59 changes: 50 additions & 9 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,76 @@

`DetectMate Performance` is a library that performs high-performance operations in DetectMate. While the `DetectMate Library` runs everything in a streaming manner, `DetectMate Performance` allows you to process data in batches as well.

It combines C++ functionality with [`Polars`](https://pola.rs/) DataFrames.
It combines C++ functionality with [`Polars`](https://pola.rs/) DataFrames. Currently the library supports:

| | Python 3.12 | Python 3.13|
|--|----|---|
**x86_64** | Yes | Yes |
**arch64** | No | Yes |
**amd64** | No | No |

## Installation

[`CMake`](https://cmake.org/) allows to build the C++ code:

```bash
sudo apt-get install cmake
```
## Installation

Intall python dependencies:

```bash
pip install uv
uv sync
prek install

```
## Compilation

Only need it if the library does not have binaries to your setup. The code can be compiled directly in your machine or with a Docker simulator.

The binaries can be found in `src/detectmateperformance/lib` and they follow the next format:

```
bind_class.cpython-<PYTHON_VERSION>-<ARCHITECTURE>-<OS>.so
```

### Witout Docker

Install [`CMake`](https://cmake.org/) allows to build the C++ code:

```bash
sudo apt-get install cmake
```

Compile the code, make sure that all unit tests are green:
Compile the code to run in your machine, make sure that all unit tests pass:

```bash
sh compile.sh
```

### With Docker

Using `Docker` as a simulator simplifies the pipeline an allows compiling the code for multiple architecutres. For more information about Docker cross-compilation check [here](https://docs.docker.com/build/building/multi-platform/).

Install:

```
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
```

To compile all the binaries:

```
docker compose up
```

To compile a single type of binary select one from the docker compose file:

```
docker compose up arm64_builder
```

## Run unit tests
To run the C++ and Python unit tests:

```bash
pytest
uv run pytest
```

### To do a local instalation in a different venv
Expand Down
99 changes: 99 additions & 0 deletions docs/types.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@

# Types

DetectMatePerformance use standard type classes in all its methods.

## LogTemplates

Log templates is a class that manage all the log templates in the code.

```python
class LogTemplates:
def __init__(self, templates: list[str]): pass

def __len__(self) -> int: pass

def shape(self) -> tuple[int, int]: pass

def get_next(self) -> list[str]: pass

def __eq__(self, other: object) -> bool: pass

def __str__(self) -> str: pass

@classmethod
def from_file(cls, path: str) -> "LogTemplates": pass
```

Usage example:

```python
from detectmateperformance.types_ import LogTemplates

log_temp = LogTemplates.from_file(path_temp)
```

## ParsedLogs

Class that contains all the parsed logs.

```python
class ParsedLogs:
def __init__(
self, templates: LogTemplates, n: int, with_vars: bool = False
) -> None:
pass

@classmethod
def from_cls(
cls, inst: Parsed, with_vars: bool = False
) -> "ParsedLogs":
pass

def __len__(self) -> int: pass

def shape(self) -> tuple[int, int]: pass

def __str__(self) -> str: pass

def __getitem__(self, idx: int) -> str | tuple[str, str]: pass

def __setitem__(self, idx: int, values: str | tuple[str, str]) -> str:
pass

def get_all_events_ids(self) -> list[int]: pass

def get_all_templates(self) -> list[str]: pass

def get_all_vars(self) -> list[str] | None: pass
```

Usage example without variables:

```python
from detectmateperformance.types_ import ParsedLogs

parsed = ParsedLogs(LogTemplates(templates), 5)
assert parsed.shape() == (5, 0)

parsed[0] = "Hello VAR world VAR"
parsed[3] = "ciaoo bellaaa"

assert parsed[0] == "Hello VAR world VAR"
assert parsed[3] == "template not found"
```

Usage example with variables:

```python
from detectmateperformance.types_ import ParsedLogs

parsed = ParsedLogs(LogTemplates(templates), 5, with_vars=True)
assert parsed.shape() == (5, 0)

parsed[0] = ("Hello VAR world VAR", "")
parsed[3] = ("ciaoo bellaaa", "a b c")

assert parsed[0] == ("Hello VAR world VAR", "")
assert parsed[3] == ("template not found", "a b c")
```
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ nav:
- Methods:
- TreeMatcher: tree_matcher.md
- Auxiliar:
- Types: types.md
- Metrics: metrics.md
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ build-backend = "setuptools.build_meta"
name = "detectmateperformance"
version = "0.1.0"
description = "A Python package for DetectMate performance evaluation."
requires-python = ">=3.12"
requires-python = ">=3.13"
dependencies = [
"levenshtein>=0.27.3",
"numpy>=2.4.3",
Expand Down
Binary file not shown.
Binary file not shown.
Loading
Loading