Skip to content
Draft
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
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ dependencies = [
"pyyaml>=6.0.3",
"regex>=2025.11.3",
"numpy>=2.3.2",
"detectmateperformance>=0.1.0",
"detectmateperformance>=0.1.6",
"msgpack>=1.0.0",
"fsspec>=2024.1.0",
"pyarrow>=24.0.0",
Expand Down
53 changes: 53 additions & 0 deletions src/detectmatelibrary/parsers/autoparser.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
from detectmatelibrary.common.parser import CoreParser, CoreParserConfig
from detectmatelibrary import schemas

from detectmateperformance.match_tree import TreeMatcher
from detectmateperformance.auto_parser import AutoParse


from typing import Any


class AutoParserConfig(CoreParserConfig):
method_type: str = "auto_parser"
num_use: int = 10


class AutoParser(CoreParser):
def __init__(
self,
name: str = "AutoParser",
config: AutoParserConfig | dict[str, Any] = AutoParserConfig()
) -> None:

if isinstance(config, dict):
config = AutoParserConfig.from_dict(config, name)
super().__init__(name=name, config=config)

self.config: AutoParserConfig
self.auto_gen = AutoParse(num_use=self.config.num_use)
self.tree_match: TreeMatcher | None = None

self.config_buffer: list[str] = []

def train(self, input_: schemas.LogSchema) -> None: # type: ignore
self.auto_gen.add(input_["log"])

def post_train(self) -> None:
self.tree_match = self.auto_gen.generate()

def parse(
self,
input_: schemas.LogSchema,
output_: schemas.ParserSchema
) -> None:

if self.tree_match is None:
output_["EventID"] = -1
output_["template"] = "templates not yet generated"
else:
parsed = self.tree_match.match_log(input_["log"], get_var=True)[0]

output_["EventID"] = parsed["EventID"]
output_["variables"].extend(parsed["ParamList"])
output_["template"] = parsed["Template"]
14 changes: 7 additions & 7 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading