@@ -35,6 +35,7 @@ def __str__(self) -> str:
3535
3636class BadNodeUrlException (_BaseException ):
3737 def __init__ (self , node_url : str ):
38+ super ().__init__ ()
3839 self .message = "Bad node url: {}" .format (node_url )
3940
4041
@@ -43,16 +44,19 @@ def __init__(self, node_url: str):
4344
4445class ModelExistedException (_BaseException ):
4546 def __init__ (self , model_id : str ):
47+ super ().__init__ ()
4648 self .message = "Model {} already exists" .format (model_id )
4749
4850
4951class ModelNotExistException (_BaseException ):
5052 def __init__ (self , model_id : str ):
51- self .message = "Model {} is not exists" .format (model_id )
53+ super ().__init__ ()
54+ self .message = "Model {} does not exist" .format (model_id )
5255
5356
5457class InvalidModelUriException (_BaseException ):
5558 def __init__ (self , msg : str ):
59+ super ().__init__ ()
5660 self .message = (
5761 "Model registration failed because the specified uri is invalid: {}" .format (
5862 msg
@@ -62,74 +66,41 @@ def __init__(self, msg: str):
6266
6367class BuiltInModelDeletionException (_BaseException ):
6468 def __init__ (self , model_id : str ):
69+ super ().__init__ ()
6570 self .message = "Cannot delete built-in model: {}" .format (model_id )
6671
6772
6873class BadConfigValueException (_BaseException ):
6974 def __init__ (self , config_name : str , config_value , hint : str = "" ):
75+ super ().__init__ ()
7076 self .message = "Bad value [{0}] for config {1}. {2}" .format (
7177 config_value , config_name , hint
7278 )
7379
7480
75- class MissingConfigException (_BaseException ):
76- def __init__ (self , config_name : str ):
77- self .message = "Missing config: {}" .format (config_name )
78-
79-
80- class MissingOptionException (_BaseException ):
81- def __init__ (self , config_name : str ):
82- self .message = "Missing task option: {}" .format (config_name )
83-
84-
85- class RedundantOptionException (_BaseException ):
86- def __init__ (self , option_name : str ):
87- self .message = "Redundant task option: {}" .format (option_name )
88-
89-
90- class WrongTypeConfigException (_BaseException ):
91- def __init__ (self , config_name : str , expected_type : str ):
92- self .message = "Wrong type for config: {0}, expected: {1}" .format (
93- config_name , expected_type
94- )
95-
96-
97- class UnsupportedException (_BaseException ):
98- def __init__ (self , msg : str ):
99- self .message = "{0} is not supported in current version" .format (msg )
100-
101-
102- class InvalidUriException (_BaseException ):
103- def __init__ (self , uri : str ):
104- self .message = "Invalid uri: {}, there are no {} or {} under this uri." .format (
105- uri , MODEL_WEIGHTS_FILE_IN_PT , MODEL_CONFIG_FILE_IN_YAML
106- )
107-
108-
109- class InvalidWindowArgumentException (_BaseException ):
110- def __init__ (self , window_interval , window_step , dataset_length ):
111- self .message = f"Invalid inference input: window_interval { window_interval } , window_step { window_step } , dataset_length { dataset_length } "
112-
113-
11481class InferenceModelInternalException (_BaseException ):
11582 def __init__ (self , msg : str ):
83+ super ().__init__ ()
11684 self .message = "Inference model internal error: {0}" .format (msg )
11785
11886
11987class BuiltInModelNotSupportException (_BaseException ):
12088 def __init__ (self , msg : str ):
89+ super ().__init__ ()
12190 self .message = "Built-in model not support: {0}" .format (msg )
12291
12392
12493class WrongAttributeTypeException (_BaseException ):
12594 def __init__ (self , attribute_name : str , expected_type : str ):
95+ super ().__init__ ()
12696 self .message = "Wrong type for attribute: {0}, expected: {1}" .format (
12797 attribute_name , expected_type
12898 )
12999
130100
131101class NumericalRangeException (_BaseException ):
132102 def __init__ (self , attribute_name : str , value , min_value , max_value ):
103+ super ().__init__ ()
133104 self .message = (
134105 "Attribute {0} expect value between {1} and {2}, got {3} instead." .format (
135106 attribute_name , min_value , max_value , value
@@ -139,33 +110,17 @@ def __init__(self, attribute_name: str, value, min_value, max_value):
139110
140111class StringRangeException (_BaseException ):
141112 def __init__ (self , attribute_name : str , value : str , expect_value ):
113+ super ().__init__ ()
142114 self .message = "Attribute {0} expect value in {1}, got {2} instead." .format (
143115 attribute_name , expect_value , value
144116 )
145117
146118
147119class ListRangeException (_BaseException ):
148120 def __init__ (self , attribute_name : str , value : list , expected_type : str ):
121+ super ().__init__ ()
149122 self .message = (
150123 "Attribute {0} expect value type list[{1}], got {2} instead." .format (
151124 attribute_name , expected_type , value
152125 )
153126 )
154-
155-
156- class AttributeNotSupportException (_BaseException ):
157- def __init__ (self , model_name : str , attribute_name : str ):
158- self .message = "Attribute {0} is not supported in model {1}" .format (
159- attribute_name , model_name
160- )
161-
162-
163- # This is used to extract the key message in RuntimeError instead of the traceback message
164- def runtime_error_extractor (error_message ):
165- pattern = re .compile (r"RuntimeError: (.+)" )
166- match = pattern .search (error_message )
167-
168- if match :
169- return match .group (1 )
170- else :
171- return ""
0 commit comments