Browse Source

!17 Add error code for MaxCountExceededError, change exception used in summary_watcher

Merge pull request !17 from luopengting/summary_watcher
tags/v0.2.0-alpha
mindspore-ci-bot Gitee 6 years ago
parent
commit
bf31095f5e
4 changed files with 10 additions and 10 deletions
  1. +4
    -4
      mindinsight/datavisual/common/exceptions.py
  2. +3
    -3
      mindinsight/datavisual/data_transform/summary_watcher.py
  3. +2
    -2
      mindinsight/datavisual/utils/tools.py
  4. +1
    -1
      mindinsight/utils/constant.py

+ 4
- 4
mindinsight/datavisual/common/exceptions.py View File

@@ -83,10 +83,10 @@ class NodeNotInGraphError(MindInsightException):
http_code=400)


class MaxCountExceededException(MindInsightException):
class MaxCountExceededError(MindInsightException):
"""Count is out of limit."""
def __init__(self):
error_msg = "Count is out of limit."
super(MaxCountExceededException, self).__init__(DataVisualErrors.NODE_NOT_IN_GRAPH_ERROR,
error_msg,
http_code=400)
super(MaxCountExceededError, self).__init__(DataVisualErrors.MAX_COUNT_EXCEEDED_ERROR,
error_msg,
http_code=400)

+ 3
- 3
mindinsight/datavisual/data_transform/summary_watcher.py View File

@@ -22,7 +22,7 @@ from pathlib import Path
from mindinsight.datavisual.common.log import logger
from mindinsight.datavisual.common.validation import Validation
from mindinsight.datavisual.utils.tools import Counter
from mindinsight.utils.exceptions import ParamValueError
from mindinsight.datavisual.common.exceptions import MaxCountExceededError
from mindinsight.utils.exceptions import FileSystemPermissionError
@@ -87,7 +87,7 @@ class SummaryWatcher:
break
try:
counter.add()
except ParamValueError:
except MaxCountExceededError:
logger.info('Stop further scanning due to overall is False and '
'number of scanned files exceeds upper limit.')
break
@@ -132,7 +132,7 @@ class SummaryWatcher:
break
try:
counter.add()
except ParamValueError:
except MaxCountExceededError:
logger.info('Stop further scanning due to overall is False and '
'number of scanned files exceeds upper limit.')
break


+ 2
- 2
mindinsight/datavisual/utils/tools.py View File

@@ -20,7 +20,7 @@ import os
from numbers import Number
from urllib.parse import unquote

from mindinsight.datavisual.common.exceptions import MaxCountExceededException
from mindinsight.datavisual.common.exceptions import MaxCountExceededError
from mindinsight.utils import exceptions

_IMG_EXT_TO_MIMETYPE = {
@@ -165,5 +165,5 @@ class Counter:
def add(self, value=1):
"""Add value."""
if self._max_count is not None and self._count + value > self._max_count:
raise MaxCountExceededException()
raise MaxCountExceededError()
self._count += value

+ 1
- 1
mindinsight/utils/constant.py View File

@@ -50,7 +50,7 @@ class DataVisualErrors(Enum):
"""Enum definition for datavisual errors."""
RESTFUL_API_NOT_EXIST = 1
REQUEST_METHOD_NOT_ALLOWED = 2
SUMMARY_LOG_CONTENT_INVALID = 3
MAX_COUNT_EXCEEDED_ERROR = 3
CRC_FAILED = 4
TRAIN_JOB_NOT_EXIST = 5
SUMMARY_LOG_PATH_INVALID = 6


Loading…
Cancel
Save