Browse Source

catch DecodeError in proto decode, enhance sorting when TypeError

tags/v0.2.0-alpha
luopengting 5 years ago
parent
commit
28aeae03d0
2 changed files with 16 additions and 7 deletions
  1. +14
    -6
      mindinsight/lineagemgr/querier/querier.py
  2. +2
    -1
      mindinsight/lineagemgr/summary/lineage_summary_analyzer.py

+ 14
- 6
mindinsight/lineagemgr/querier/querier.py View File

@@ -105,10 +105,14 @@ class ExpressionType(enum.Enum):
cls.LE.value, cls.GE.value]:
return False

if except_key == cls.IN.value:
state = operator.contains(except_value, actual_value)
else:
state = getattr(operator, except_key)(actual_value, except_value)
try:
if except_key == cls.IN.value:
state = operator.contains(except_value, actual_value)
else:
state = getattr(operator, except_key)(actual_value, except_value)
except TypeError:
# actual_value can not compare with except_value
return False
return state


@@ -280,8 +284,12 @@ class Querier:
elif value2 is None:
cmp_result = 1
else:
cmp_result = (value1 > value2) - (value1 < value2)

try:
cmp_result = (value1 > value2) - (value1 < value2)
except TypeError:
type1 = str(type(value1))
type2 = str(type(value2))
cmp_result = (type1 > type2) - (type1 < type2)
return cmp_result

self._parse_fail_summary_logs()


+ 2
- 1
mindinsight/lineagemgr/summary/lineage_summary_analyzer.py View File

@@ -18,6 +18,7 @@ from collections import namedtuple
from enum import Enum

from google.protobuf.json_format import MessageToDict
from google.protobuf.message import DecodeError

from mindinsight.datavisual.proto_files.mindinsight_lineage_pb2 import LineageEvent
from mindinsight.datavisual.utils import crc32
@@ -202,7 +203,7 @@ class LineageSummaryAnalyzer(SummaryAnalyzer):
analyzer = cls(file_path)
try:
lineage_info = analyzer.get_latest_info()
except (MindInsightException, IOError) as err:
except (MindInsightException, IOError, DecodeError) as err:
log.error("Failed to get lineage information.")
log.exception(err)
raise LineageSummaryAnalyzeException()


Loading…
Cancel
Save