Skip to content

Commit

Permalink
Catch CFL-r tool output parsing errors
Browse files Browse the repository at this point in the history
  • Loading branch information
IlyaMuravjov committed Mar 5, 2024
1 parent b2fc1c6 commit 3f1dd41
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
20 changes: 19 additions & 1 deletion cli/runners/all_pairs_cflr_tool_runner.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import re
import shlex
import subprocess
import traceback
from abc import ABC, abstractmethod
from dataclasses import dataclass
from pathlib import Path
Expand Down Expand Up @@ -67,7 +68,24 @@ def run(self) -> CflrToolRunResult:
stdout=subprocess.PIPE,
text=True,
)
return self.parse_results(process)
return self.safe_parse_results(process)

def safe_parse_results(self, process: subprocess.CompletedProcess[str]) -> CflrToolRunResult:
try:
return self.parse_results(process)
except Exception:
print(
" Failed to parse results\n"
" (interpreting as incompatible CFL-r tool error)"
)
print("=====")
print("stdout:\n" + process.stdout)
print("=====")
print("stderr:\n" + process.stderr)
print("=====")
traceback.print_exc()
print("=====")
raise IncompatibleCflrToolError()

@abstractmethod
def parse_results(self, process: subprocess.CompletedProcess[str]) -> CflrToolRunResult:
Expand Down
2 changes: 1 addition & 1 deletion cli/runners/gigascale_algo_all_pairs_cflr_tool_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def run(self) -> CflrToolRunResult:
expect eof
"""
)
return self.parse_results(process)
return self.safe_parse_results(process)

def parse_results(self, process: subprocess.CompletedProcess[str]) -> CflrToolRunResult:
# parses a table like this:
Expand Down

0 comments on commit 3f1dd41

Please sign in to comment.