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 docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ services:
volumes:
- ./:/app
working_dir: /app
command: ["sh", "install_compile.sh"]
command: ["sh", "install_compile.sh", "12"]

x86_64_builder:
image: gcc:latest
container_name: x86_64_builder
volumes:
- ./:/app
working_dir: /app
command: ["sh", "install_compile.sh"]
command: ["sh", "install_compile.sh", "12"]
25 changes: 24 additions & 1 deletion install_compile.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,27 @@

apt-get update && apt-get install -y python3 curl cmake python3-dev
#!/usr/bin/env bash
set -euo pipefail

# Simple installer: pass a suffix (e.g. 12 or 13) to install python3.X
# Usage: ./install_compile.sh [12]

SUFFIX="${1:-}"

apt-get update
apt-get install -y --no-install-recommends curl cmake build-essential

if [ -n "$SUFFIX" ]; then
PYPKG="python3.$SUFFIX"
PYDEV="python3.$SUFFIX-dev"
echo "Installing ${PYPKG} and ${PYDEV}"
apt-get install -y --no-install-recommends ${PYPKG} ${PYDEV} || (
echo "Failed to install ${PYPKG}. Falling back to system python3." && apt-get install -y --no-install-recommends python3 python3-dev
)
else
echo "No suffix provided. Installing system python3 and headers."
apt-get install -y --no-install-recommends python3 python3-dev
fi

curl -LsSf https://astral.sh/uv/install.sh | sh

sh compile.sh
9 changes: 3 additions & 6 deletions src/detectmateperformance/_core/_type/element.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,11 @@


std::string postProcessTemp(const std::string& input){
std::string pattern = "\\bVAR\\b";
std::regex re(pattern);
std::string result = std::regex_replace(input, re, "<*>");
return result;
return input; // For now it will be save like this
}

std::deque<std::string> postProcessVars(const std::string& input_vars) {
return preprocessing(input_vars);
std::string postProcessVars(const std::string& input_vars) {
return input_vars; // For now it will be save like this
}

ParsedElement::ParsedElement(
Expand Down
4 changes: 2 additions & 2 deletions src/detectmateperformance/_core/_type/element.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@

std::string postProcessTemp(const std::string& input);

std::deque<std::string> postProcessVars(const std::string& input_vars);
std::string postProcessVars(const std::string& input_vars);

class ParsedElement {

public:
int event_id;
std::string log_template;
std::deque<std::string> variables;
std::string variables;

ParsedElement(
int event_id, std::string log_template, std::string variables
Expand Down
4 changes: 2 additions & 2 deletions src/detectmateperformance/_core/_type/parsed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ std::vector<std::string> ParsedMessages::getAllElemts() {
return templates;
}

std::vector<std::deque<std::string>> ParsedMessages::getAllVar() {
std::vector<std::deque<std::string>> vars(this->size());
std::vector<std::string> ParsedMessages::getAllVar() {
std::vector<std::string> vars(this->size());

for (int i = 0; i < this->size(); i++) {
vars[i] = this->getElemWithVar(i).variables;
Expand Down
2 changes: 1 addition & 1 deletion src/detectmateperformance/_core/_type/parsed.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class ParsedMessages {

std::vector<int> getAllIDs();
std::vector<std::string> getAllElemts();
std::vector<std::deque<std::string>> getAllVar();
std::vector<std::string> getAllVar();

int size();
std::pair<int, int> shape();
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
10 changes: 9 additions & 1 deletion src/detectmateperformance/pipeline_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@ def add_parsed(df: pl.DataFrame, results: ParsedLogs) -> pl.DataFrame:
return df


def postprocessing(df: pl.DataFrame) -> pl.DataFrame:
df = df.with_columns(pl.col("Templates").str.replace_all("VAR", "<*>"))
if "ParamList" in df.columns:
df = df.with_columns(pl.col("ParamList").str.split(by=" "))
return df


def run_batches(
func: Callable[[list[str], bool, int], ParsedLogs],
table: pl.DataFrame,
Expand All @@ -62,7 +69,8 @@ def run_batches(
df = pl.concat([df, add_parsed(df=table[i-batch: i], results=results)])
del results

return df
print(">>> Postprocessing results")
return postprocessing(df)


def run_full_pipeline(
Expand Down
11 changes: 9 additions & 2 deletions src/detectmateperformance/types_.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class ParsedLogElement:
def __init__(self, parsed_ele: ParsedElement) -> None:
self.event_id: int = parsed_ele.event_id
self.log_template: str = parsed_ele.log_template
self.variables: list[str] = parsed_ele.variables
self.variables: str = parsed_ele.variables

def to_dict(self) -> dict[str, Any]:
return {
Expand All @@ -57,6 +57,13 @@ def to_dict(self) -> dict[str, Any]:
"ParamList": self.variables,
}

def postprocess_to_dict(self) -> dict[str, Any]:
return {
"EventID": self.event_id,
"Template": self.log_template.replace("VAR", "<*>"),
"ParamList": self.variables.split(" ") if self.variables != "" else [],
}


class ParsedLogs:
def __init__(
Expand Down Expand Up @@ -85,7 +92,7 @@ def __getitem__(self, idx: int) -> dict[str, Any]:
result = ParsedLogElement(self.inst.get_elem_with_var(idx))
else:
result = ParsedLogElement(self.inst.get_elem(idx))
return result.to_dict()
return result.postprocess_to_dict()

def __setitem__(self, idx: int, values: str | tuple[str, str]) -> str:
if self.with_vars:
Expand Down
28 changes: 14 additions & 14 deletions tests/test_c/test_message.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ TEST(TreeMatchTest, MatchString) {

ParsedMessages* result2 = matcher->match_string("hi general mr. and mrs. kenobi");
EXPECT_EQ(result2->size(), 1);
EXPECT_EQ(result2->getElem(0).log_template, "hi general <*> kenobi");
EXPECT_EQ(result2->getElem(0).log_template, "hi general VAR kenobi");

ParsedMessages* result3 = matcher->match_string("hi random guy");
EXPECT_EQ(result3->size(), 1);
Expand All @@ -250,15 +250,15 @@ TEST(TreeMatchTest, MatchStringWithVar) {
MatchTree* matcher = new MatchTree(temp);

ParsedElement result1 = matcher->match_string_with_var("hi there")->getElemWithVar(0);
std::deque<std::string> expected1 = {};
std::string expected1 = "";
EXPECT_EQ(result1.log_template, "hi there");
EXPECT_EQ(result1.variables, expected1);

ParsedElement result2 = matcher->match_string_with_var(
"hi general mr. and mrs. kenobi"
)->getElemWithVar(0);
std::deque<std::string> expected2 = {"mr", "and", "mrs"};
EXPECT_EQ(result2.log_template, "hi general <*> kenobi");
std::string expected2 = "mr and mrs";
EXPECT_EQ(result2.log_template, "hi general VAR kenobi");
EXPECT_EQ(result2.variables, expected2);

ParsedElement result3 = matcher->match_string_with_var(
Expand All @@ -269,8 +269,8 @@ TEST(TreeMatchTest, MatchStringWithVar) {
ParsedElement result4 = matcher->match_string_with_var(
"load 1213 asd from 112 bye"
)->getElemWithVar(0);
std::deque<std::string> expected4 = {"1213", "asd", "112", "bye"};
EXPECT_EQ(result4.log_template, "load <*> from <*>");
std::string expected4 = "1213 asd 112 bye";
EXPECT_EQ(result4.log_template, "load VAR from VAR");
EXPECT_EQ(result4.variables, expected4);

delete matcher;
Expand Down Expand Up @@ -321,12 +321,12 @@ TEST(TreeMatchTest, MatchStringBatchVar) {
std::vector<std::string> msg_ex = {
"hi there", "hi general <*> kenobi", "template not found", "load <*> from <*>"
};
std::vector<std::string> ex_msg_ex = {
"hi there", "hi general VAR kenobi", "template not found", "load VAR from VAR"
};
std::vector<std::string> vector_vars = {
"", "mr and mrs", "", "1213 asd 112 bye"
};
std::vector<std::deque<std::string>> ex_vector_vars = {
{}, {"mr", "and", "mrs"}, {}, {"1213", "asd", "112", "bye"}
};

Templates* temp2 = new Templates(sequences);
ParsedMessages* expected = new ParsedMessages(temp2, 4);
Expand All @@ -347,8 +347,8 @@ TEST(TreeMatchTest, MatchStringBatchVar) {
if (msg_ex[i] == "template not found")
EXPECT_EQ(-1, aux.event_id);

EXPECT_EQ(msg_ex[i], aux.log_template);
EXPECT_EQ(aux.variables, ex_vector_vars[i]);
EXPECT_EQ(ex_msg_ex[i], aux.log_template);
EXPECT_EQ(aux.variables, vector_vars[i]);
}

delete matcher;
Expand All @@ -367,7 +367,7 @@ TEST(ParsedMessagesTest, HardCases1) {

ParsedMessages* result1 = matcher->match_string(log);
EXPECT_EQ(result1->size(), 1);
EXPECT_EQ(result1->getElem(0).log_template, "<*> floating point alignment exceptions");
EXPECT_EQ(result1->getElem(0).log_template, "VAR floating point alignment exceptions");

}

Expand All @@ -383,7 +383,7 @@ TEST(ParsedMessagesTest, HardCases2) {

ParsedMessages* result1 = matcher->match_string(log);
EXPECT_EQ(result1->size(), 1);
EXPECT_EQ(result1->getElem(0).log_template, "<*> Exception writing block <*> to mirror <*>");
EXPECT_EQ(result1->getElem(0).log_template, "VAR Exception writing block VAR to mirror VAR");

}

Expand All @@ -399,7 +399,7 @@ TEST(ParsedMessagesTest, HardCases3) {

ParsedMessages* result1 = matcher->match_string(log);
EXPECT_EQ(result1->size(), 1);
EXPECT_EQ(result1->getElem(0).log_template, "rts kernel terminated for reason <*>");
EXPECT_EQ(result1->getElem(0).log_template, "rts kernel terminated for reason VAR");

}

Expand Down
26 changes: 13 additions & 13 deletions tests/test_c/test_type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,25 +48,25 @@ TEST(ParsedMessagesTest, ParsedElementtest) {
ParsedElement* parsed = new ParsedElement(
0, "VAR template VAR VAR", "var1 var2 var3"
);
std::deque<std::string> expected = {"var1", "var2", "var3"};
std::string expected = "var1 var2 var3";

EXPECT_EQ(parsed->event_id, 0);
EXPECT_EQ(parsed->log_template, "<*> template <*> <*>");
EXPECT_EQ(parsed->log_template, "VAR template VAR VAR");
EXPECT_EQ(parsed->variables, expected);

ParsedElement* parsed2 = new ParsedElement(
0, "VAR template VAR VAR"
);
std::deque<std::string> expected2 = {};
std::string expected2 = "";

EXPECT_EQ(parsed2->event_id, 0);
EXPECT_EQ(parsed2->log_template, "<*> template <*> <*>");
EXPECT_EQ(parsed2->log_template, "VAR template VAR VAR");
EXPECT_EQ(parsed2->variables, expected2);

ParsedElement* parsed3 = new ParsedElement(
-1, "template not found", "5 1 2"
);
std::deque<std::string> expected3 = {"5", "1", "2"};
std::string expected3 = "5 1 2";

EXPECT_EQ(parsed3->event_id, -1);
EXPECT_EQ(parsed3->log_template, "template not found");
Expand All @@ -75,7 +75,7 @@ TEST(ParsedMessagesTest, ParsedElementtest) {
ParsedElement* parsed4 = new ParsedElement(
-1, "template not found"
);
std::deque<std::string> expected4 = {};
std::string expected4 = "";

EXPECT_EQ(parsed4->event_id, -1);
EXPECT_EQ(parsed4->log_template, "template not found");
Expand Down Expand Up @@ -107,8 +107,8 @@ TEST(ParsedMessagesTest, GetNext) {
parsed.setElem(2, "Goodbye VAR");
parsed.setElem(3, "random thing");

std::string temp1 = "Hello <*> world <*>";
std::string temp2 = "Goodbye <*>";
std::string temp1 = "Hello VAR world VAR";
std::string temp2 = "Goodbye VAR";
std::string temp3 = "template not found";

EXPECT_EQ(parsed.getElem(0).log_template, temp1);
Expand Down Expand Up @@ -155,11 +155,11 @@ TEST(ParsedMessagesTest, GetNextWithVar) {
parsed.setElemWithVar(2, "Goodbye VAR", var2);
parsed.setElemWithVar(3, "random thing", var1);

std::string temp1 = "Hello <*> world <*>";
std::string temp2 = "Goodbye <*>";
std::string temp1 = "Hello VAR world VAR";
std::string temp2 = "Goodbye VAR";
std::string temp3 = "template not found";
std::deque<std::string> evar1 = {};
std::deque<std::string> evar2 = {"a", "b"};
std::string evar1 = "";
std::string evar2 = "a b";

EXPECT_EQ(parsed.getElemWithVar(0).log_template, temp1);
EXPECT_EQ(parsed.getElemWithVar(0).variables, evar1);
Expand All @@ -184,7 +184,7 @@ TEST(ParsedMessagesTest, GetAllVar) {
parsed.setElemWithVar(2, "Goodbye VAR", var2);
parsed.setElemWithVar(3, "random thing", var1);

std::vector<std::deque<std::string>> result = parsed.getAllVar();
std::vector<std::string> result = parsed.getAllVar();

for (int i = 0; i < result.size(); i++) {
EXPECT_EQ(parsed.getElemWithVar(i).variables, result[i]);
Expand Down
4 changes: 2 additions & 2 deletions tests/test_python/test_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def test_get_all_templates(self):
parsed[0] = "Hello VAR world VAR"
parsed[1] = "ciaoo bellaaa"

expected = ["Hello <*> world <*>", "template not found"]
expected = ["Hello VAR world VAR", "template not found"]
assert parsed.get_all_templates() == expected

def test_add_elements_with_vars(self):
Expand All @@ -83,7 +83,7 @@ def test_get_all_variables(self):
parsed[0] = ("Hello VAR world VAR", "")
parsed[1] = ("ciaoo bellaaa", "a b c")

expected = [[], ["a", "b", "c"]]
expected = ["", "a b c"]
assert parsed.get_all_vars() == expected

def test_add_elements_shape_(self):
Expand Down
Loading