From 254c8f9a49d86b9cbc0736fe1d91a351e2d05ae7 Mon Sep 17 00:00:00 2001 From: XianBW <36835909+XianBW@users.noreply.github.com> Date: Thu, 17 Oct 2024 20:22:39 +0800 Subject: [PATCH] fix problem of reading log file tags on Windows (#437) Co-authored-by: Bowen Xian (Shanghai Wicresoft Co Ltd) --- rdagent/log/storage.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rdagent/log/storage.py b/rdagent/log/storage.py index 870d83ed..0411a5ba 100644 --- a/rdagent/log/storage.py +++ b/rdagent/log/storage.py @@ -68,10 +68,10 @@ class FileStorage(Storage): def iter_msg(self, watch: bool = False) -> Generator[Message, None, None]: msg_l = [] for file in self.path.glob("**/*.log"): - tag = ".".join(str(file.relative_to(self.path)).replace("/", ".").split(".")[:-3]) + tag = ".".join(file.relative_to(self.path).as_posix().replace("/", ".").split(".")[:-3]) pid = file.parent.name - with file.open("r") as f: + with file.open("r", encoding="utf-8") as f: content = f.read() matches, next_matches = self.log_pattern.finditer(content), self.log_pattern.finditer(content) @@ -100,7 +100,7 @@ class FileStorage(Storage): msg_l.append(m) for file in self.path.glob("**/*.pkl"): - tag = ".".join(str(file.relative_to(self.path)).replace("/", ".").split(".")[:-3]) + tag = ".".join(file.relative_to(self.path).as_posix().replace("/", ".").split(".")[:-3]) pid = file.parent.name with file.open("rb") as f: