dsl_exception.py 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. #
  2. # Copyright 2019 The FATE Authors. All Rights Reserved.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. #
  16. class BaseDSLException(Exception):
  17. def __init__(self, msg):
  18. self.msg = msg
  19. class DSLNotExistError(BaseDSLException):
  20. def __str__(self):
  21. return "There are no dsl, please check if the role and party id are correct"
  22. class SubmitConfNotExistError(Exception):
  23. def __str__(self):
  24. return "SubMitConf is None, does not exist"
  25. class ComponentFieldNotExistError(Exception):
  26. def __str__(self):
  27. return "No components filed in dsl, please have a check!"
  28. class ModuleException(Exception):
  29. def __init__(self, component=None, module=None, input=None, output_model=None,
  30. output_data=None, other_info=None, value_type=None):
  31. self.component = component
  32. self.module = module
  33. self.input = input
  34. self.output_data = output_data
  35. self.output_model = output_model
  36. self.other_info = other_info
  37. self.value_type = value_type
  38. class ComponentNotExistError(ModuleException):
  39. def __str__(self):
  40. return "Component {} does not exist, please have a check".format(self.component)
  41. class ModuleFieldNotExistError(ModuleException):
  42. def __str__(self):
  43. return "Component {}, module field does not exist in dsl, please have a check".format(self.component)
  44. class ModuleNotExistError(ModuleException):
  45. def __str__(self):
  46. return "Component {}, module {} does not exist under the fold federatedml.setting_conf".format(self.component,
  47. self.module)
  48. class ModuleConfigError(ModuleException):
  49. def __str__(self):
  50. return "Component {}, module {} config error, message is {}".format(self.component, self.module,
  51. self.other_info[0])
  52. class DataNotExistInSubmitConfError(BaseDSLException):
  53. def __str__(self):
  54. return "{} does not exist in submit conf's data, please check!".format(self.msg)
  55. class DefaultRuntimeConfNotExistError(ModuleException):
  56. def __str__(self):
  57. return "Default runtime conf of component {}, module {}, does not exist".format(self.component, self.module)
  58. class DefaultRuntimeConfNotJsonError(ModuleException):
  59. def __str__(self):
  60. return "Default runtime conf of component {}, module {} should be json format file, but error occur: {}".format(self.component, self.module, self.other_info)
  61. class InputComponentNotExistError(ModuleException):
  62. def __str__(self):
  63. return "Component {}'s {} input {} does not exist".format(self.component, self.value_type, self.input)
  64. class InputNameNotExistError(ModuleException):
  65. def __str__(self):
  66. return "Component {}' s {} input {}'s output {} does not exist".format(self.component,
  67. self.input,
  68. self.value_type,
  69. self.other_info)
  70. class ComponentInputTypeError(ModuleException):
  71. def __str__(self):
  72. return "Input of component {} should be dict".format(self.component)
  73. class ComponentOutputTypeError(ModuleException):
  74. def __str__(self):
  75. return "Output of component {} should be dict, but {} does not match".format(self.component, self.other_info)
  76. class ComponentInputDataTypeError(ModuleException):
  77. def __str__(self):
  78. return "Component {}'s input data type should be dict".format(self.component)
  79. class ComponentInputValueTypeError(ModuleException):
  80. def __str__(self):
  81. return "Component {}'s input {} type should be list, but {} not match".format(self.component,
  82. self.value_type,
  83. self.other_info)
  84. class ComponentOutputKeyTypeError(ModuleException):
  85. def __str__(self):
  86. return "Component {}'s output key {} value type should be list".format(self.component,
  87. self.other_info)
  88. class ParameterException(Exception):
  89. def __init__(self, parameter, role=None, msg=None):
  90. self.parameter = parameter
  91. self.role = role
  92. self.msg = msg
  93. class ParamClassNotExistError(ModuleException):
  94. def __str__(self):
  95. return "Component {}, module {}'s param class {} does not exist".format(self.component, self.module,
  96. self.other_info)
  97. class RoleParameterNotListError(ParameterException):
  98. def __str__(self):
  99. return "Role {} role parameter {} should be list".format(self.role, self.parameter)
  100. class RoleParameterNotConsistencyError(ParameterException):
  101. def __str__(self):
  102. return "Role {} role parameter {} should be a list of same length with roles".format(self.role, self.parameter)
  103. class ParameterCheckError(ModuleException):
  104. def __str__(self):
  105. return "Component {}, module {}, does not pass component check, error msg is {}".format(self.component,
  106. self.module,
  107. self.other_info)
  108. class RedundantParameterError(ParameterCheckError):
  109. def __str__(self):
  110. return "Component {}, module {}, has redundant parameter {}".format(self.component,
  111. self.module,
  112. self.other_info)
  113. class ComponentDuplicateError(ModuleException):
  114. def __str__(self):
  115. return "Component {} is duplicated, running before".format(self.component)
  116. class DegreeNotZeroError(ModuleException):
  117. def __str__(self):
  118. return "Component {}' in degree should be zero for topological sort".format(self.component)
  119. class ModeError(BaseDSLException):
  120. def __str__(self):
  121. return "dsl' s mode should be train or predict"
  122. class LoopError(Exception):
  123. def __init__(self, components=None):
  124. self.components = components
  125. def __str__(self):
  126. if self.components is not None:
  127. return "{} form a loop".format("->".join(self.components))
  128. else:
  129. return "component relationship forms a dependency loop"
  130. class NamingError(ModuleException):
  131. def __str__(self):
  132. return "Component's name should be format of name_index, index is start from 0 " + \
  133. "and be consecutive for same module, {} is error".format(self.component)
  134. class NamingIndexError(ModuleException):
  135. def __str__(self):
  136. return "Component {}'s index should be an integer start from 0".format(self.component)
  137. class NamingFormatError(ModuleException):
  138. def __str__(self):
  139. return "Component name {}'is not illegal, it should be consits of letter, digit, '-' and '_'".format(self.component)
  140. class ComponentMultiMappingError(ModuleException):
  141. def __str__(self):
  142. return "Component prefix {} should be used for only one module, but another".format(self.component)
  143. class DeployComponentNotExistError(BaseDSLException):
  144. def __init__(self, msg):
  145. self.msg = msg
  146. def __str__(self):
  147. return "components {} not exist in training dsl, can not deploy!!!".format(self.msg)