• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2020 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"""Profiler error code and messages."""
16from enum import unique, Enum
17
18_GENERAL_MASK = 0b00001 << 7
19_PARSER_MASK = 0b00010 << 7
20_ANALYSER_MASK = 0b00011 << 7
21
22
23class ProfilerMgrErrors(Enum):
24    """Enum definition for profiler errors"""
25
26
27@unique
28class ProfilerErrors(ProfilerMgrErrors):
29    """Profiler error codes."""
30    # general error code
31    PARAM_VALUE_ERROR = 0 | _GENERAL_MASK
32    PATH_ERROR = 1 | _GENERAL_MASK
33    PARAM_TYPE_ERROR = 2 | _GENERAL_MASK
34    DIR_NOT_FOUND_ERROR = 3 | _GENERAL_MASK
35    FILE_NOT_FOUND_ERROR = 4 | _GENERAL_MASK
36    IO_ERROR = 5 | _GENERAL_MASK
37
38    # parser error code
39    DEVICE_ID_MISMATCH_ERROR = 0 | _PARSER_MASK
40    RAW_FILE_ERROR = 1 | _PARSER_MASK
41    STEP_NUM_NOT_SUPPORTED_ERROR = 2 | _PARSER_MASK
42    JOB_ID_MISMATCH_ERROR = 3 | _PARSER_MASK
43
44    # analyser error code
45    COLUMN_NOT_EXIST_ERROR = 0 | _ANALYSER_MASK
46    ANALYSER_NOT_EXIST_ERROR = 1 | _ANALYSER_MASK
47    DEVICE_ID_ERROR = 2 | _ANALYSER_MASK
48    OP_TYPE_ERROR = 3 | _ANALYSER_MASK
49    GROUP_CONDITION_ERROR = 4 | _ANALYSER_MASK
50    SORT_CONDITION_ERROR = 5 | _ANALYSER_MASK
51    FILTER_CONDITION_ERROR = 6 | _ANALYSER_MASK
52    COLUMN_NOT_SUPPORT_SORT_ERROR = 7 | _ANALYSER_MASK
53    PIPELINE_OP_NOT_EXIST_ERROR = 8 | _ANALYSER_MASK
54
55
56@unique
57class ProfilerErrorMsg(Enum):
58    """Profiler error messages."""
59    # general error msg
60    PARAM_VALUE_ERROR = 'Param value error. {}'
61    PATH_ERROR = 'Path error. {}'
62    PARAM_TYPE_ERROR = 'Param type error. {}'
63    DIR_NOT_FOUND_ERROR = 'The dir <{}> not found.'
64    FILE_NOT_FOUND_ERROR = 'The file <{}> not found.'
65    IO_ERROR = 'Read or write file fail.'
66
67    # parser error msg
68    DEVICE_ID_MISMATCH_ERROR = 'The device ID mismatch.'
69    RAW_FILE_ERROR = 'Raw file error. {}'
70    STEP_NUM_NOT_SUPPORTED_ERROR = 'The step num must be in {}'
71    JOB_ID_MISMATCH_ERROR = 'The job id in the parameter is not the same as ' \
72                            'in the training trace file. '
73
74    # analyser error msg
75    COLUMN_NOT_EXIST_ERROR = 'The column {} does not exist.'
76    ANALYSER_NOT_EXIST_ERROR = 'The analyser {} does not exist.'
77    DEIVICE_ID_ERROR = 'The device_id in search_condition error, {}'
78    FILTER_CONDITION_ERROR = 'The filter_condition in search_condition error, {}'
79    OP_TYPE_ERROR = 'The op_type in search_condition error, {}'
80    GROUP_CONDITION_ERROR = 'The group_condition in search_condition error, {}'
81    SORT_CONDITION_ERROR = 'The sort_condition in search_condition error, {}'
82    COLUMN_NOT_SUPPORT_SORT_ERROR = 'The column {} does not support to sort.'
83    PIPELINE_OP_NOT_EXIST_ERROR = 'The minddata pipeline operator {} does not exist.'
84