You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

exceptions.py 6.2 kB

5 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. # Copyright 2019 Huawei Technologies Co., Ltd
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. # ============================================================================
  15. """Define custom exception."""
  16. from mindinsight.utils.constant import DataVisualErrors
  17. from mindinsight.utils.exceptions import MindInsightException
  18. class RestfulApiNotExist(MindInsightException):
  19. """404 not found."""
  20. def __init__(self):
  21. error_msg = '404 Not Found.'
  22. super(RestfulApiNotExist, self).__init__(DataVisualErrors.RESTFUL_API_NOT_EXIST,
  23. error_msg,
  24. http_code=404)
  25. class RequestMethodNotAllowed(MindInsightException):
  26. """Request method not allowed."""
  27. def __init__(self):
  28. error_msg = '405 Method Not Allowed.'
  29. super(RequestMethodNotAllowed, self).__init__(DataVisualErrors.REQUEST_METHOD_NOT_ALLOWED,
  30. error_msg,
  31. http_code=405)
  32. class PathNotDirectoryError(MindInsightException):
  33. """Raised when specified path do not exist."""
  34. def __init__(self, error_detail):
  35. """Initialize PathNotExistError"""
  36. error_msg = 'Specified path is not a directory. Detail: {}'.format(error_detail)
  37. super(PathNotDirectoryError, self).__init__(DataVisualErrors.PATH_NOT_DIRECTORY_ERROR,
  38. error_msg,
  39. http_code=400)
  40. class SummaryLogPathInvalid(MindInsightException):
  41. """No valid log file in the path."""
  42. def __init__(self):
  43. error_msg = 'No valid summary log file in path'
  44. super(SummaryLogPathInvalid, self).__init__(DataVisualErrors.SUMMARY_LOG_PATH_INVALID,
  45. error_msg,
  46. http_code=400)
  47. class CRCFailedError(MindInsightException):
  48. """CRC fail, record corrupted."""
  49. def __init__(self):
  50. error_msg = 'CRC Failed.'
  51. super(CRCFailedError, self).__init__(DataVisualErrors.CRC_FAILED,
  52. error_msg,
  53. http_code=400)
  54. class SummaryLogIsLoading(MindInsightException):
  55. """Data is loading."""
  56. def __init__(self, error_detail):
  57. error_msg = "Data is loading. Detail: %s" % error_detail
  58. super(SummaryLogIsLoading, self).__init__(DataVisualErrors.SUMMARY_LOG_IS_LOADING,
  59. error_msg,
  60. http_code=400)
  61. class NodeNotInGraphError(MindInsightException):
  62. """Can not find node in graph error."""
  63. def __init__(self):
  64. error_msg = "Can not find node in graph by given node name."
  65. super(NodeNotInGraphError, self).__init__(DataVisualErrors.NODE_NOT_IN_GRAPH_ERROR,
  66. error_msg,
  67. http_code=400)
  68. class MaxCountExceededError(MindInsightException):
  69. """Count is out of limit."""
  70. def __init__(self):
  71. error_msg = "Count is out of limit."
  72. super(MaxCountExceededError, self).__init__(DataVisualErrors.MAX_COUNT_EXCEEDED_ERROR,
  73. error_msg,
  74. http_code=400)
  75. class TrainJobNotExistError(MindInsightException):
  76. """Can not find the given train job."""
  77. def __init__(self, error_detail=None):
  78. if error_detail is None:
  79. error_msg = f"Train job is not exist."
  80. else:
  81. error_msg = f"Train job is not exist. Detail: {error_detail}"
  82. super(TrainJobNotExistError, self).__init__(DataVisualErrors.TRAIN_JOB_NOT_EXIST,
  83. error_msg,
  84. http_code=400)
  85. class PluginNotAvailableError(MindInsightException):
  86. """The given plugin is not available."""
  87. def __init__(self, error_detail):
  88. error_msg = f"Plugin is not available. Detail: {error_detail}"
  89. super(PluginNotAvailableError, self).__init__(DataVisualErrors.PLUGIN_NOT_AVAILABLE,
  90. error_msg,
  91. http_code=400)
  92. class GraphNotExistError(MindInsightException):
  93. """Can not found the given graph."""
  94. def __init__(self):
  95. error_msg = 'Graph is not exist.'
  96. super(GraphNotExistError, self).__init__(DataVisualErrors.GRAPH_NOT_EXIST,
  97. error_msg,
  98. http_code=400)
  99. class ImageNotExistError(MindInsightException):
  100. """Unable to get a image based on a given condition."""
  101. def __init__(self, error_detail):
  102. error_msg = f'Image is not exist. Detail: {error_detail}'
  103. super(ImageNotExistError, self).__init__(DataVisualErrors.IMAGE_NOT_EXIST,
  104. error_msg,
  105. http_code=400)
  106. class ScalarNotExistError(MindInsightException):
  107. """Unable to get scalar values based on a given condition."""
  108. def __init__(self, error_detail):
  109. error_msg = f'Scalar value is not exist. Detail: {error_detail}'
  110. super(ScalarNotExistError, self).__init__(DataVisualErrors.SCALAR_NOT_EXIST,
  111. error_msg,
  112. http_code=400)

MindInsight为MindSpore提供了简单易用的调优调试能力。在训练过程中,可以将标量、张量、图像、计算图、模型超参、训练耗时等数据记录到文件中,通过MindInsight可视化页面进行查看及分析。