Skip to content

Commit e18d6ae

Browse files
Brad KinnardBrad Kinnard
authored andcommitted
fix(ci): resolve ruff lint errors and add libre2-dev for google-re2 build
- Fix 36 ruff lint errors (unused imports, E701, E402, F841, F541) - Add libre2-dev system dependency and pybind11 build deps to CI workflow - Use --no-build-isolation with CFLAGS for google-re2 compilation
1 parent 038b70e commit e18d6ae

15 files changed

Lines changed: 20 additions & 40 deletions

.github/workflows/ci.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,16 @@ jobs:
2121
with:
2222
python-version: ${{ matrix.python-version }}
2323

24+
- name: Install system dependencies
25+
run: |
26+
sudo apt-get update
27+
sudo apt-get install -y libre2-dev
28+
2429
- name: Install dependencies
2530
run: |
2631
python -m pip install --upgrade pip
27-
pip install ruff pytest
32+
pip install ruff pytest pybind11 setuptools wheel
33+
CFLAGS="-I$(python -c 'import pybind11; print(pybind11.get_include())')" pip install google-re2==1.0.0 --no-build-isolation
2834
pip install .[embed,demo]
2935
3036
- name: Lint with Ruff

benchmarks/run_benchmark.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
import sys
21
import time
32
import json
43
import random
54
import subprocess
6-
import os
75
from pathlib import Path
86

97
# Provide a sample schema for an Apache Access Log
@@ -99,11 +97,11 @@ def extract(text):
9997
import math
10098
std_dev = math.sqrt(variance)
10199

102-
print(f"\n======== WARM CACHE BENCHMARK (1000 lines) ========")
100+
print("\n======== WARM CACHE BENCHMARK (1000 lines) ========")
103101
print(f"Average total wall time: {avg_time:.2f}ms ± {std_dev:.2f}ms")
104102
print(f"Min: {min_time:.2f}ms, Max: {max_time:.2f}ms")
105103
print(f"Lines processed per second: {1000 / (avg_time / 1000):.2f} ops/sec")
106-
print(f"===================================================")
104+
print("===================================================")
107105

108106
schema_path.unlink()
109107

benchmarks/run_examples.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
import sys
21
import time
32
import json
43
import random
54
import subprocess
65
import math
7-
from pathlib import Path
86

97
# Schemas must be pre-created in examples/
108
SCHEMAS = {
@@ -165,7 +163,7 @@ def run_benchmark(name, schema_path, logs_str, true_log_len):
165163
print(f"\\n======== {name.upper()} WARM CACHE (1000 elements) ========")
166164
print(f"Avg Wall Time: {avg_time:.2f}ms ± {std_dev:.2f}ms")
167165
print(f"Throughput: {1000 / (avg_time / 1000):.2f} ops/sec")
168-
print(f"===========================================================\\n")
166+
print("===========================================================\\n")
169167

170168
if __name__ == "__main__":
171169
print("Generating logs (with random.seed(42))...")

symparse/cache_manager.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import logging
44
import hashlib
55
from pathlib import Path
6-
from typing import Optional, Any
6+
from typing import Optional
77
import portalocker
88

99
logger = logging.getLogger(__name__)
@@ -52,7 +52,8 @@ def _cosine_similarity(self, vec1: list[float], vec2: list[float]) -> float:
5252
dot = sum(a*b for a, b in zip(vec1, vec2))
5353
mag1 = math.sqrt(sum(a*a for a in vec1))
5454
mag2 = math.sqrt(sum(b*b for b in vec2))
55-
if mag1 * mag2 == 0: return 0.0
55+
if mag1 * mag2 == 0:
56+
return 0.0
5657
return dot / (mag1 * mag2)
5758

5859
def _get_embedding(self, text: str) -> list[float]:

symparse/compiler.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import logging
33
import ast
44
import re2
5-
from typing import Any
65
from symparse.ai_client import AIClient
76

87
logger = logging.getLogger(__name__)

symparse/demo.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import time
22
import sys
3-
import subprocess
43

54
def type_text(text, speed=0.03, newline=True):
65
for char in text:

symparse/engine.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import json
21
import logging
2+
from dataclasses import dataclass
33
from enum import Enum
44
from typing import Any, Dict
55

@@ -14,8 +14,6 @@ class GracefulDegradationMode(Enum):
1414
HALT = "halt"
1515
PASSTHROUGH = "passthrough"
1616

17-
from dataclasses import dataclass
18-
1917
@dataclass
2018
class EngineStats:
2119
fast_path_hits: int = 0

tests/test_ai_client.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import pytest
2-
from symparse.ai_client import AIClient, ConfidenceDegradationError
3-
import litellm
2+
from symparse.ai_client import AIClient
43
import os
54

65
def test_ai_client_extract_success():

tests/test_cache_manager.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
1-
import os
21
import json
32
import multiprocessing
4-
import pytest
5-
from pathlib import Path
63
from symparse.cache_manager import CacheManager
74

85
def test_cache_init_metadata(tmp_path):
9-
cm = CacheManager(cache_dir=tmp_path)
6+
CacheManager(cache_dir=tmp_path)
107
meta_file = tmp_path / "metadata.json"
118
assert meta_file.exists()
129

tests/test_cli.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import pytest
2-
from unittest.mock import patch
2+
from unittest.mock import patch, mock_open
33
import sys
44
import io
55
from symparse.cli import main
66

77
def test_cli_cache_list_clear(monkeypatch, capsys):
88
from symparse.cli import main
9-
import json
109

1110
# We can mock CacheManager.list_cache and clear_cache
1211
class DummyCache:
@@ -60,9 +59,6 @@ def test_run_command_no_stdin(capsys):
6059
assert "Error: No data piped into stdin." in captured.err
6160

6261

63-
64-
from unittest.mock import mock_open
65-
6662
def test_run_command_success(capsys):
6763
test_args = ["symparse", "run", "--schema", "dummy.json", "--compile"]
6864
dummy_schema = '{"type": "object", "properties": {"name": {"type": "string"}}}'

0 commit comments

Comments
 (0)