提交 51e2cb3a 编写于 作者: M mindspore-ci-bot 提交者: Gitee

!33 catch DecodeError when parsing, enhance sorting when TypeError

Merge pull request !33 from luopengting/enhance_parse_and_sort
...@@ -105,10 +105,14 @@ class ExpressionType(enum.Enum): ...@@ -105,10 +105,14 @@ class ExpressionType(enum.Enum):
cls.LE.value, cls.GE.value]: cls.LE.value, cls.GE.value]:
return False return False
if except_key == cls.IN.value: try:
state = operator.contains(except_value, actual_value) if except_key == cls.IN.value:
else: state = operator.contains(except_value, actual_value)
state = getattr(operator, except_key)(actual_value, except_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 return state
...@@ -280,8 +284,12 @@ class Querier: ...@@ -280,8 +284,12 @@ class Querier:
elif value2 is None: elif value2 is None:
cmp_result = 1 cmp_result = 1
else: 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 return cmp_result
self._parse_fail_summary_logs() self._parse_fail_summary_logs()
......
...@@ -18,6 +18,7 @@ from collections import namedtuple ...@@ -18,6 +18,7 @@ from collections import namedtuple
from enum import Enum from enum import Enum
from google.protobuf.json_format import MessageToDict 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.proto_files.mindinsight_lineage_pb2 import LineageEvent
from mindinsight.datavisual.utils import crc32 from mindinsight.datavisual.utils import crc32
...@@ -202,7 +203,7 @@ class LineageSummaryAnalyzer(SummaryAnalyzer): ...@@ -202,7 +203,7 @@ class LineageSummaryAnalyzer(SummaryAnalyzer):
analyzer = cls(file_path) analyzer = cls(file_path)
try: try:
lineage_info = analyzer.get_latest_info() 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.error("Failed to get lineage information.")
log.exception(err) log.exception(err)
raise LineageSummaryAnalyzeException() raise LineageSummaryAnalyzeException()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册