Copilot commented on code in PR #16895:
URL: https://github.com/apache/iotdb/pull/16895#discussion_r2609224181
##########
iotdb-core/ainode/iotdb/ainode/core/model/model_storage.py:
##########
@@ -481,41 +474,40 @@ def delete_model(self, model_id: str) -> None:
model_info = category_dict[model_id]
category_value = cat_value
break
-
if not model_info:
logger.warning(f"Model {model_id} does not exist, cannot
delete")
- return
-
+ raise ModelNotExistException(model_id)
if model_info.category == ModelCategory.BUILTIN:
- raise BuiltInModelDeletionError(model_id)
+ logger.warning(f"Model {model_id} is builtin, cannot delete")
+ raise BuiltInModelDeletionException(model_id)
model_info.state = ModelStates.DROPPING
model_path = os.path.join(
self._models_dir, model_info.category.value, model_id
)
- if model_path.exists():
+ if os.path.exists(model_path):
try:
shutil.rmtree(model_path)
- logger.info(f"Deleted model directory: {model_path}")
+ logger.info(f"Model directory is deleted: {model_path}")
except Exception as e:
logger.error(f"Failed to delete model directory
{model_path}: {e}")
- raise
-
- if category_value and model_id in self._models[category_value]:
- del self._models[category_value][model_id]
- logger.info(f"Model {model_id} has been removed from storage")
-
- return
+ raise e
+ del self._models[category_value][model_id]
Review Comment:
If the shutil.rmtree operation fails (line 489-493), an exception is raised
but the model remains in DROPPING state in the _models dictionary. The model is
never removed from the dictionary in this failure case, potentially leaving the
system in an inconsistent state. Consider either reverting the state or
removing the model from the dictionary even if file deletion fails, with
appropriate error handling.
##########
iotdb-core/ainode/iotdb/ainode/core/manager/model_manager.py:
##########
@@ -16,12 +16,16 @@
# under the License.
#
-from typing import Any, List, Optional
+from typing import List, Optional
Review Comment:
Import of 'List' is not used.
```suggestion
from typing import Optional
```
##########
iotdb-core/ainode/iotdb/ainode/core/model/utils.py:
##########
@@ -96,3 +104,28 @@ def ensure_init_file(dir_path: str):
if not os.path.exists(init_file):
with open(init_file, "w"):
pass
+
+
+def _fetch_model_from_local(source_path: str, storage_path: str):
+ logger.info(f"Copying model from local path: {source_path} ->
{storage_path}")
+ source_dir = Path(source_path)
+ storage_dir = Path(storage_path)
+ for file in source_dir.iterdir():
+ if file.is_file():
+ shutil.copy2(file, storage_dir / file.name)
+
+
Review Comment:
The _fetch_model_from_local function doesn't validate that source_path
exists or is a directory before attempting to iterate over it. This could lead
to unclear error messages if the path doesn't exist. Consider adding validation
with InvalidModelUriException similar to how the old implementation handled
this.
```suggestion
if not source_dir.exists():
raise InvalidModelUriException(f"Source path does not exist:
{source_path}")
if not source_dir.is_dir():
raise InvalidModelUriException(f"Source path is not a directory:
{source_path}")
storage_dir = Path(storage_path)
for file in source_dir.iterdir():
if file.is_file():
shutil.copy2(file, storage_dir / file.name)
```
##########
iotdb-core/ainode/iotdb/ainode/core/exception.py:
##########
@@ -33,85 +33,102 @@ def __str__(self) -> str:
return self.message
-class BadNodeUrlError(_BaseError):
+class BadNodeUrlException(_BaseException):
def __init__(self, node_url: str):
self.message = "Bad node url: {}".format(node_url)
Review Comment:
This class does not call [_BaseException.__init__](1) during initialization.
([BadNodeUrlException.__init__](2) may be missing a call to a base class
__init__)
```suggestion
self.message = "Bad node url: {}".format(node_url)
super().__init__(self.message)
```
##########
iotdb-core/ainode/iotdb/ainode/core/exception.py:
##########
@@ -33,85 +33,102 @@ def __str__(self) -> str:
return self.message
-class BadNodeUrlError(_BaseError):
+class BadNodeUrlException(_BaseException):
def __init__(self, node_url: str):
self.message = "Bad node url: {}".format(node_url)
-class ModelNotExistError(_BaseError):
+# ==================== Model Management ====================
+
+
+class ModelExistedException(_BaseException):
+ def __init__(self, model_id: str):
+ self.message = "Model {} already exists".format(model_id)
+
+
+class ModelNotExistException(_BaseException):
+ def __init__(self, model_id: str):
+ self.message = "Model {} is not exists".format(model_id)
+
+
+class InvalidModelUriException(_BaseException):
def __init__(self, msg: str):
- self.message = "Model is not exists: {} ".format(msg)
+ self.message = (
+ "Model registration failed because the specified uri is invalid:
{}".format(
+ msg
+ )
+ )
+
+
+class BuiltInModelDeletionException(_BaseException):
+ def __init__(self, model_id: str):
+ self.message = "Cannot delete built-in model: {}".format(model_id)
-class BadConfigValueError(_BaseError):
+class BadConfigValueException(_BaseException):
def __init__(self, config_name: str, config_value, hint: str = ""):
self.message = "Bad value [{0}] for config {1}. {2}".format(
config_value, config_name, hint
)
-class MissingConfigError(_BaseError):
+class MissingConfigException(_BaseException):
def __init__(self, config_name: str):
self.message = "Missing config: {}".format(config_name)
-class MissingOptionError(_BaseError):
+class MissingOptionException(_BaseException):
def __init__(self, config_name: str):
Review Comment:
This class does not call [_BaseException.__init__](1) during initialization.
([MissingOptionException.__init__](2) may be missing a call to a base class
__init__)
```suggestion
def __init__(self, config_name: str):
super().__init__()
```
##########
iotdb-core/ainode/iotdb/ainode/core/exception.py:
##########
@@ -33,85 +33,102 @@ def __str__(self) -> str:
return self.message
-class BadNodeUrlError(_BaseError):
+class BadNodeUrlException(_BaseException):
def __init__(self, node_url: str):
self.message = "Bad node url: {}".format(node_url)
-class ModelNotExistError(_BaseError):
+# ==================== Model Management ====================
+
+
+class ModelExistedException(_BaseException):
+ def __init__(self, model_id: str):
+ self.message = "Model {} already exists".format(model_id)
+
+
+class ModelNotExistException(_BaseException):
+ def __init__(self, model_id: str):
+ self.message = "Model {} is not exists".format(model_id)
+
+
+class InvalidModelUriException(_BaseException):
def __init__(self, msg: str):
- self.message = "Model is not exists: {} ".format(msg)
+ self.message = (
+ "Model registration failed because the specified uri is invalid:
{}".format(
+ msg
+ )
+ )
+
+
+class BuiltInModelDeletionException(_BaseException):
+ def __init__(self, model_id: str):
+ self.message = "Cannot delete built-in model: {}".format(model_id)
-class BadConfigValueError(_BaseError):
+class BadConfigValueException(_BaseException):
def __init__(self, config_name: str, config_value, hint: str = ""):
self.message = "Bad value [{0}] for config {1}. {2}".format(
config_value, config_name, hint
)
-class MissingConfigError(_BaseError):
+class MissingConfigException(_BaseException):
def __init__(self, config_name: str):
self.message = "Missing config: {}".format(config_name)
-class MissingOptionError(_BaseError):
+class MissingOptionException(_BaseException):
def __init__(self, config_name: str):
self.message = "Missing task option: {}".format(config_name)
-class RedundantOptionError(_BaseError):
+class RedundantOptionException(_BaseException):
def __init__(self, option_name: str):
self.message = "Redundant task option: {}".format(option_name)
-class WrongTypeConfigError(_BaseError):
+class WrongTypeConfigException(_BaseException):
def __init__(self, config_name: str, expected_type: str):
self.message = "Wrong type for config: {0}, expected: {1}".format(
config_name, expected_type
)
-class UnsupportedError(_BaseError):
+class UnsupportedException(_BaseException):
def __init__(self, msg: str):
self.message = "{0} is not supported in current version".format(msg)
-class InvalidUriError(_BaseError):
+class InvalidUriException(_BaseException):
def __init__(self, uri: str):
self.message = "Invalid uri: {}, there are no {} or {} under this
uri.".format(
uri, MODEL_WEIGHTS_FILE_IN_PT, MODEL_CONFIG_FILE_IN_YAML
)
-class InvalidWindowArgumentError(_BaseError):
+class InvalidWindowArgumentException(_BaseException):
def __init__(self, window_interval, window_step, dataset_length):
self.message = f"Invalid inference input: window_interval
{window_interval}, window_step {window_step}, dataset_length {dataset_length}"
-class InferenceModelInternalError(_BaseError):
+class InferenceModelInternalException(_BaseException):
def __init__(self, msg: str):
self.message = "Inference model internal error: {0}".format(msg)
-class BuiltInModelNotSupportError(_BaseError):
+class BuiltInModelNotSupportException(_BaseException):
def __init__(self, msg: str):
self.message = "Built-in model not support: {0}".format(msg)
-class BuiltInModelDeletionError(_BaseError):
- def __init__(self, model_id: str):
- self.message = "Cannot delete built-in model: {0}".format(model_id)
-
-
-class WrongAttributeTypeError(_BaseError):
+class WrongAttributeTypeException(_BaseException):
def __init__(self, attribute_name: str, expected_type: str):
self.message = "Wrong type for attribute: {0}, expected: {1}".format(
attribute_name, expected_type
)
-class NumericalRangeException(_BaseError):
+class NumericalRangeException(_BaseException):
def __init__(self, attribute_name: str, value, min_value, max_value):
Review Comment:
This class does not call [_BaseException.__init__](1) during initialization.
([NumericalRangeException.__init__](2) may be missing a call to a base class
__init__)
```suggestion
def __init__(self, attribute_name: str, value, min_value, max_value):
super().__init__()
```
##########
iotdb-core/ainode/iotdb/ainode/core/exception.py:
##########
@@ -120,14 +137,14 @@ def __init__(self, attribute_name: str, value, min_value,
max_value):
)
-class StringRangeException(_BaseError):
+class StringRangeException(_BaseException):
Review Comment:
This class does not call [_BaseException.__init__](1) during initialization.
([StringRangeException.__init__](2) may be missing a call to a base class
__init__)
##########
iotdb-core/ainode/iotdb/ainode/core/exception.py:
##########
@@ -33,85 +33,102 @@ def __str__(self) -> str:
return self.message
-class BadNodeUrlError(_BaseError):
+class BadNodeUrlException(_BaseException):
def __init__(self, node_url: str):
self.message = "Bad node url: {}".format(node_url)
-class ModelNotExistError(_BaseError):
+# ==================== Model Management ====================
+
+
+class ModelExistedException(_BaseException):
+ def __init__(self, model_id: str):
Review Comment:
This class does not call [_BaseException.__init__](1) during initialization.
([ModelExistedException.__init__](2) may be missing a call to a base class
__init__)
```suggestion
def __init__(self, model_id: str):
super().__init__()
```
##########
iotdb-core/ainode/iotdb/ainode/core/exception.py:
##########
@@ -33,85 +33,102 @@ def __str__(self) -> str:
return self.message
-class BadNodeUrlError(_BaseError):
+class BadNodeUrlException(_BaseException):
def __init__(self, node_url: str):
self.message = "Bad node url: {}".format(node_url)
-class ModelNotExistError(_BaseError):
+# ==================== Model Management ====================
+
+
+class ModelExistedException(_BaseException):
+ def __init__(self, model_id: str):
+ self.message = "Model {} already exists".format(model_id)
+
+
+class ModelNotExistException(_BaseException):
+ def __init__(self, model_id: str):
+ self.message = "Model {} is not exists".format(model_id)
Review Comment:
The error message has a grammatical error: "Model {} is not exists" should
be "Model {} does not exist".
```suggestion
self.message = "Model {} does not exist".format(model_id)
```
##########
iotdb-core/ainode/iotdb/ainode/core/exception.py:
##########
@@ -33,85 +33,102 @@ def __str__(self) -> str:
return self.message
-class BadNodeUrlError(_BaseError):
+class BadNodeUrlException(_BaseException):
def __init__(self, node_url: str):
self.message = "Bad node url: {}".format(node_url)
-class ModelNotExistError(_BaseError):
+# ==================== Model Management ====================
+
+
+class ModelExistedException(_BaseException):
+ def __init__(self, model_id: str):
+ self.message = "Model {} already exists".format(model_id)
+
+
+class ModelNotExistException(_BaseException):
+ def __init__(self, model_id: str):
+ self.message = "Model {} is not exists".format(model_id)
+
+
+class InvalidModelUriException(_BaseException):
def __init__(self, msg: str):
Review Comment:
This class does not call [_BaseException.__init__](1) during initialization.
([InvalidModelUriException.__init__](2) may be missing a call to a base class
__init__)
```suggestion
def __init__(self, msg: str):
super().__init__()
```
##########
iotdb-core/ainode/iotdb/ainode/core/model/model_storage.py:
##########
@@ -233,12 +239,23 @@ def _process_user_defined_model_directory(self,
model_dir: str, model_id: str):
# ==================== Registration Methods ====================
- def register_model(self, model_id: str, uri: str) -> bool:
+ def register_model(self, model_id: str, uri: str):
"""
- Supported URI formats:
- - repo://<huggingface_repo_id> (Maybe in the future)
- - file://<local_path>
+ Register a user-defined model from a given URI.
+ Args:
+ model_id (str): Unique identifier for the model.
+ uri (str): URI to fetch the model from.
+ Supported URI formats:
+ - file://<local_path>
+ - repo://<huggingface_repo_id> (Maybe in the future)
+ Raises:
+ ModelExistedError: If the model_id already exists.
+ InvalidModelUriError: If the URI format is invalid.
Review Comment:
The docstring mentions "ModelExistedError" and "InvalidModelUriError" but
the actual exception names are "ModelExistedException" and
"InvalidModelUriException". The docstring should be updated to reflect the
correct exception class names.
```suggestion
ModelExistedException: If the model_id already exists.
InvalidModelUriException: If the URI format is invalid.
```
##########
iotdb-core/ainode/iotdb/ainode/core/exception.py:
##########
@@ -33,85 +33,102 @@ def __str__(self) -> str:
return self.message
-class BadNodeUrlError(_BaseError):
+class BadNodeUrlException(_BaseException):
def __init__(self, node_url: str):
self.message = "Bad node url: {}".format(node_url)
-class ModelNotExistError(_BaseError):
+# ==================== Model Management ====================
+
+
+class ModelExistedException(_BaseException):
+ def __init__(self, model_id: str):
+ self.message = "Model {} already exists".format(model_id)
+
+
+class ModelNotExistException(_BaseException):
+ def __init__(self, model_id: str):
+ self.message = "Model {} is not exists".format(model_id)
+
+
+class InvalidModelUriException(_BaseException):
def __init__(self, msg: str):
- self.message = "Model is not exists: {} ".format(msg)
+ self.message = (
+ "Model registration failed because the specified uri is invalid:
{}".format(
+ msg
+ )
+ )
+
+
+class BuiltInModelDeletionException(_BaseException):
+ def __init__(self, model_id: str):
+ self.message = "Cannot delete built-in model: {}".format(model_id)
-class BadConfigValueError(_BaseError):
+class BadConfigValueException(_BaseException):
def __init__(self, config_name: str, config_value, hint: str = ""):
self.message = "Bad value [{0}] for config {1}. {2}".format(
config_value, config_name, hint
)
-class MissingConfigError(_BaseError):
+class MissingConfigException(_BaseException):
def __init__(self, config_name: str):
self.message = "Missing config: {}".format(config_name)
-class MissingOptionError(_BaseError):
+class MissingOptionException(_BaseException):
def __init__(self, config_name: str):
self.message = "Missing task option: {}".format(config_name)
-class RedundantOptionError(_BaseError):
+class RedundantOptionException(_BaseException):
def __init__(self, option_name: str):
self.message = "Redundant task option: {}".format(option_name)
-class WrongTypeConfigError(_BaseError):
+class WrongTypeConfigException(_BaseException):
def __init__(self, config_name: str, expected_type: str):
Review Comment:
This class does not call [_BaseException.__init__](1) during initialization.
([WrongTypeConfigException.__init__](2) may be missing a call to a base class
__init__)
```suggestion
def __init__(self, config_name: str, expected_type: str):
super().__init__()
```
##########
iotdb-core/ainode/iotdb/ainode/core/exception.py:
##########
@@ -33,85 +33,102 @@ def __str__(self) -> str:
return self.message
-class BadNodeUrlError(_BaseError):
+class BadNodeUrlException(_BaseException):
def __init__(self, node_url: str):
self.message = "Bad node url: {}".format(node_url)
-class ModelNotExistError(_BaseError):
+# ==================== Model Management ====================
+
+
+class ModelExistedException(_BaseException):
+ def __init__(self, model_id: str):
+ self.message = "Model {} already exists".format(model_id)
+
+
+class ModelNotExistException(_BaseException):
+ def __init__(self, model_id: str):
Review Comment:
This class does not call [_BaseException.__init__](1) during initialization.
([ModelNotExistException.__init__](2) may be missing a call to a base class
__init__)
```suggestion
def __init__(self, model_id: str):
super().__init__()
```
##########
iotdb-core/ainode/iotdb/ainode/core/exception.py:
##########
@@ -33,85 +33,102 @@ def __str__(self) -> str:
return self.message
-class BadNodeUrlError(_BaseError):
+class BadNodeUrlException(_BaseException):
def __init__(self, node_url: str):
self.message = "Bad node url: {}".format(node_url)
-class ModelNotExistError(_BaseError):
+# ==================== Model Management ====================
+
+
+class ModelExistedException(_BaseException):
+ def __init__(self, model_id: str):
+ self.message = "Model {} already exists".format(model_id)
+
+
+class ModelNotExistException(_BaseException):
+ def __init__(self, model_id: str):
+ self.message = "Model {} is not exists".format(model_id)
+
+
+class InvalidModelUriException(_BaseException):
def __init__(self, msg: str):
- self.message = "Model is not exists: {} ".format(msg)
+ self.message = (
+ "Model registration failed because the specified uri is invalid:
{}".format(
+ msg
+ )
+ )
+
+
+class BuiltInModelDeletionException(_BaseException):
Review Comment:
This class does not call [_BaseException.__init__](1) during initialization.
([BuiltInModelDeletionException.__init__](2) may be missing a call to a base
class __init__)
##########
iotdb-core/ainode/iotdb/ainode/core/exception.py:
##########
@@ -33,85 +33,102 @@ def __str__(self) -> str:
return self.message
-class BadNodeUrlError(_BaseError):
+class BadNodeUrlException(_BaseException):
def __init__(self, node_url: str):
self.message = "Bad node url: {}".format(node_url)
-class ModelNotExistError(_BaseError):
+# ==================== Model Management ====================
+
+
+class ModelExistedException(_BaseException):
+ def __init__(self, model_id: str):
+ self.message = "Model {} already exists".format(model_id)
+
+
+class ModelNotExistException(_BaseException):
+ def __init__(self, model_id: str):
+ self.message = "Model {} is not exists".format(model_id)
+
+
+class InvalidModelUriException(_BaseException):
def __init__(self, msg: str):
- self.message = "Model is not exists: {} ".format(msg)
+ self.message = (
+ "Model registration failed because the specified uri is invalid:
{}".format(
+ msg
+ )
+ )
+
+
+class BuiltInModelDeletionException(_BaseException):
+ def __init__(self, model_id: str):
+ self.message = "Cannot delete built-in model: {}".format(model_id)
-class BadConfigValueError(_BaseError):
+class BadConfigValueException(_BaseException):
def __init__(self, config_name: str, config_value, hint: str = ""):
self.message = "Bad value [{0}] for config {1}. {2}".format(
config_value, config_name, hint
)
-class MissingConfigError(_BaseError):
+class MissingConfigException(_BaseException):
def __init__(self, config_name: str):
self.message = "Missing config: {}".format(config_name)
-class MissingOptionError(_BaseError):
+class MissingOptionException(_BaseException):
def __init__(self, config_name: str):
self.message = "Missing task option: {}".format(config_name)
-class RedundantOptionError(_BaseError):
+class RedundantOptionException(_BaseException):
def __init__(self, option_name: str):
self.message = "Redundant task option: {}".format(option_name)
-class WrongTypeConfigError(_BaseError):
+class WrongTypeConfigException(_BaseException):
def __init__(self, config_name: str, expected_type: str):
self.message = "Wrong type for config: {0}, expected: {1}".format(
config_name, expected_type
)
-class UnsupportedError(_BaseError):
+class UnsupportedException(_BaseException):
def __init__(self, msg: str):
self.message = "{0} is not supported in current version".format(msg)
-class InvalidUriError(_BaseError):
+class InvalidUriException(_BaseException):
def __init__(self, uri: str):
Review Comment:
This class does not call [_BaseException.__init__](1) during initialization.
([InvalidUriException.__init__](2) may be missing a call to a base class
__init__)
```suggestion
def __init__(self, uri: str):
super().__init__()
```
##########
iotdb-core/ainode/iotdb/ainode/core/exception.py:
##########
@@ -33,85 +33,102 @@ def __str__(self) -> str:
return self.message
-class BadNodeUrlError(_BaseError):
+class BadNodeUrlException(_BaseException):
def __init__(self, node_url: str):
self.message = "Bad node url: {}".format(node_url)
-class ModelNotExistError(_BaseError):
+# ==================== Model Management ====================
+
+
+class ModelExistedException(_BaseException):
+ def __init__(self, model_id: str):
+ self.message = "Model {} already exists".format(model_id)
+
+
+class ModelNotExistException(_BaseException):
+ def __init__(self, model_id: str):
+ self.message = "Model {} is not exists".format(model_id)
+
+
+class InvalidModelUriException(_BaseException):
def __init__(self, msg: str):
- self.message = "Model is not exists: {} ".format(msg)
+ self.message = (
+ "Model registration failed because the specified uri is invalid:
{}".format(
+ msg
+ )
+ )
+
+
+class BuiltInModelDeletionException(_BaseException):
+ def __init__(self, model_id: str):
+ self.message = "Cannot delete built-in model: {}".format(model_id)
-class BadConfigValueError(_BaseError):
+class BadConfigValueException(_BaseException):
def __init__(self, config_name: str, config_value, hint: str = ""):
Review Comment:
This class does not call [_BaseException.__init__](1) during initialization.
([BadConfigValueException.__init__](2) may be missing a call to a base class
__init__)
```suggestion
def __init__(self, config_name: str, config_value, hint: str = ""):
super().__init__()
```
##########
iotdb-core/ainode/iotdb/ainode/core/exception.py:
##########
@@ -33,85 +33,102 @@ def __str__(self) -> str:
return self.message
-class BadNodeUrlError(_BaseError):
+class BadNodeUrlException(_BaseException):
def __init__(self, node_url: str):
self.message = "Bad node url: {}".format(node_url)
-class ModelNotExistError(_BaseError):
+# ==================== Model Management ====================
+
+
+class ModelExistedException(_BaseException):
+ def __init__(self, model_id: str):
+ self.message = "Model {} already exists".format(model_id)
+
+
+class ModelNotExistException(_BaseException):
+ def __init__(self, model_id: str):
+ self.message = "Model {} is not exists".format(model_id)
+
+
+class InvalidModelUriException(_BaseException):
def __init__(self, msg: str):
- self.message = "Model is not exists: {} ".format(msg)
+ self.message = (
+ "Model registration failed because the specified uri is invalid:
{}".format(
+ msg
+ )
+ )
+
+
+class BuiltInModelDeletionException(_BaseException):
+ def __init__(self, model_id: str):
+ self.message = "Cannot delete built-in model: {}".format(model_id)
-class BadConfigValueError(_BaseError):
+class BadConfigValueException(_BaseException):
def __init__(self, config_name: str, config_value, hint: str = ""):
self.message = "Bad value [{0}] for config {1}. {2}".format(
config_value, config_name, hint
)
-class MissingConfigError(_BaseError):
+class MissingConfigException(_BaseException):
def __init__(self, config_name: str):
self.message = "Missing config: {}".format(config_name)
-class MissingOptionError(_BaseError):
+class MissingOptionException(_BaseException):
def __init__(self, config_name: str):
self.message = "Missing task option: {}".format(config_name)
-class RedundantOptionError(_BaseError):
+class RedundantOptionException(_BaseException):
def __init__(self, option_name: str):
Review Comment:
This class does not call [_BaseException.__init__](1) during initialization.
([RedundantOptionException.__init__](2) may be missing a call to a base class
__init__)
```suggestion
def __init__(self, option_name: str):
super().__init__()
```
##########
iotdb-core/ainode/iotdb/ainode/core/exception.py:
##########
@@ -33,85 +33,102 @@ def __str__(self) -> str:
return self.message
-class BadNodeUrlError(_BaseError):
+class BadNodeUrlException(_BaseException):
def __init__(self, node_url: str):
self.message = "Bad node url: {}".format(node_url)
-class ModelNotExistError(_BaseError):
+# ==================== Model Management ====================
+
+
+class ModelExistedException(_BaseException):
+ def __init__(self, model_id: str):
+ self.message = "Model {} already exists".format(model_id)
+
+
+class ModelNotExistException(_BaseException):
+ def __init__(self, model_id: str):
+ self.message = "Model {} is not exists".format(model_id)
+
+
+class InvalidModelUriException(_BaseException):
def __init__(self, msg: str):
- self.message = "Model is not exists: {} ".format(msg)
+ self.message = (
+ "Model registration failed because the specified uri is invalid:
{}".format(
+ msg
+ )
+ )
+
+
+class BuiltInModelDeletionException(_BaseException):
+ def __init__(self, model_id: str):
+ self.message = "Cannot delete built-in model: {}".format(model_id)
-class BadConfigValueError(_BaseError):
+class BadConfigValueException(_BaseException):
def __init__(self, config_name: str, config_value, hint: str = ""):
self.message = "Bad value [{0}] for config {1}. {2}".format(
config_value, config_name, hint
)
-class MissingConfigError(_BaseError):
+class MissingConfigException(_BaseException):
def __init__(self, config_name: str):
Review Comment:
This class does not call [_BaseException.__init__](1) during initialization.
([MissingConfigException.__init__](2) may be missing a call to a base class
__init__)
```suggestion
def __init__(self, config_name: str):
super().__init__()
```
##########
iotdb-core/ainode/iotdb/ainode/core/exception.py:
##########
@@ -33,85 +33,102 @@ def __str__(self) -> str:
return self.message
-class BadNodeUrlError(_BaseError):
+class BadNodeUrlException(_BaseException):
def __init__(self, node_url: str):
self.message = "Bad node url: {}".format(node_url)
-class ModelNotExistError(_BaseError):
+# ==================== Model Management ====================
+
+
+class ModelExistedException(_BaseException):
+ def __init__(self, model_id: str):
+ self.message = "Model {} already exists".format(model_id)
+
+
+class ModelNotExistException(_BaseException):
+ def __init__(self, model_id: str):
+ self.message = "Model {} is not exists".format(model_id)
+
+
+class InvalidModelUriException(_BaseException):
def __init__(self, msg: str):
- self.message = "Model is not exists: {} ".format(msg)
+ self.message = (
+ "Model registration failed because the specified uri is invalid:
{}".format(
+ msg
+ )
+ )
+
+
+class BuiltInModelDeletionException(_BaseException):
+ def __init__(self, model_id: str):
+ self.message = "Cannot delete built-in model: {}".format(model_id)
-class BadConfigValueError(_BaseError):
+class BadConfigValueException(_BaseException):
def __init__(self, config_name: str, config_value, hint: str = ""):
self.message = "Bad value [{0}] for config {1}. {2}".format(
config_value, config_name, hint
)
-class MissingConfigError(_BaseError):
+class MissingConfigException(_BaseException):
def __init__(self, config_name: str):
self.message = "Missing config: {}".format(config_name)
-class MissingOptionError(_BaseError):
+class MissingOptionException(_BaseException):
def __init__(self, config_name: str):
self.message = "Missing task option: {}".format(config_name)
-class RedundantOptionError(_BaseError):
+class RedundantOptionException(_BaseException):
def __init__(self, option_name: str):
self.message = "Redundant task option: {}".format(option_name)
-class WrongTypeConfigError(_BaseError):
+class WrongTypeConfigException(_BaseException):
def __init__(self, config_name: str, expected_type: str):
self.message = "Wrong type for config: {0}, expected: {1}".format(
config_name, expected_type
)
-class UnsupportedError(_BaseError):
+class UnsupportedException(_BaseException):
def __init__(self, msg: str):
self.message = "{0} is not supported in current version".format(msg)
-class InvalidUriError(_BaseError):
+class InvalidUriException(_BaseException):
def __init__(self, uri: str):
self.message = "Invalid uri: {}, there are no {} or {} under this
uri.".format(
uri, MODEL_WEIGHTS_FILE_IN_PT, MODEL_CONFIG_FILE_IN_YAML
)
-class InvalidWindowArgumentError(_BaseError):
+class InvalidWindowArgumentException(_BaseException):
def __init__(self, window_interval, window_step, dataset_length):
Review Comment:
This class does not call [_BaseException.__init__](1) during initialization.
([InvalidWindowArgumentException.__init__](2) may be missing a call to a base
class __init__)
```suggestion
def __init__(self, window_interval, window_step, dataset_length):
super().__init__()
```
##########
iotdb-core/ainode/iotdb/ainode/core/exception.py:
##########
@@ -33,85 +33,102 @@ def __str__(self) -> str:
return self.message
-class BadNodeUrlError(_BaseError):
+class BadNodeUrlException(_BaseException):
def __init__(self, node_url: str):
self.message = "Bad node url: {}".format(node_url)
-class ModelNotExistError(_BaseError):
+# ==================== Model Management ====================
+
+
+class ModelExistedException(_BaseException):
+ def __init__(self, model_id: str):
+ self.message = "Model {} already exists".format(model_id)
+
+
+class ModelNotExistException(_BaseException):
+ def __init__(self, model_id: str):
+ self.message = "Model {} is not exists".format(model_id)
+
+
+class InvalidModelUriException(_BaseException):
def __init__(self, msg: str):
- self.message = "Model is not exists: {} ".format(msg)
+ self.message = (
+ "Model registration failed because the specified uri is invalid:
{}".format(
+ msg
+ )
+ )
+
+
+class BuiltInModelDeletionException(_BaseException):
+ def __init__(self, model_id: str):
+ self.message = "Cannot delete built-in model: {}".format(model_id)
-class BadConfigValueError(_BaseError):
+class BadConfigValueException(_BaseException):
def __init__(self, config_name: str, config_value, hint: str = ""):
self.message = "Bad value [{0}] for config {1}. {2}".format(
config_value, config_name, hint
)
-class MissingConfigError(_BaseError):
+class MissingConfigException(_BaseException):
def __init__(self, config_name: str):
self.message = "Missing config: {}".format(config_name)
-class MissingOptionError(_BaseError):
+class MissingOptionException(_BaseException):
def __init__(self, config_name: str):
self.message = "Missing task option: {}".format(config_name)
-class RedundantOptionError(_BaseError):
+class RedundantOptionException(_BaseException):
def __init__(self, option_name: str):
self.message = "Redundant task option: {}".format(option_name)
-class WrongTypeConfigError(_BaseError):
+class WrongTypeConfigException(_BaseException):
def __init__(self, config_name: str, expected_type: str):
self.message = "Wrong type for config: {0}, expected: {1}".format(
config_name, expected_type
)
-class UnsupportedError(_BaseError):
+class UnsupportedException(_BaseException):
def __init__(self, msg: str):
self.message = "{0} is not supported in current version".format(msg)
-class InvalidUriError(_BaseError):
+class InvalidUriException(_BaseException):
def __init__(self, uri: str):
self.message = "Invalid uri: {}, there are no {} or {} under this
uri.".format(
uri, MODEL_WEIGHTS_FILE_IN_PT, MODEL_CONFIG_FILE_IN_YAML
)
-class InvalidWindowArgumentError(_BaseError):
+class InvalidWindowArgumentException(_BaseException):
def __init__(self, window_interval, window_step, dataset_length):
self.message = f"Invalid inference input: window_interval
{window_interval}, window_step {window_step}, dataset_length {dataset_length}"
-class InferenceModelInternalError(_BaseError):
+class InferenceModelInternalException(_BaseException):
def __init__(self, msg: str):
Review Comment:
This class does not call [_BaseException.__init__](1) during initialization.
([InferenceModelInternalException.__init__](2) may be missing a call to a base
class __init__)
```suggestion
def __init__(self, msg: str):
super().__init__()
```
##########
iotdb-core/ainode/iotdb/ainode/core/exception.py:
##########
@@ -120,14 +137,14 @@ def __init__(self, attribute_name: str, value, min_value,
max_value):
)
-class StringRangeException(_BaseError):
+class StringRangeException(_BaseException):
def __init__(self, attribute_name: str, value: str, expect_value):
self.message = "Attribute {0} expect value in {1}, got {2}
instead.".format(
attribute_name, expect_value, value
)
-class ListRangeException(_BaseError):
+class ListRangeException(_BaseException):
def __init__(self, attribute_name: str, value: list, expected_type: str):
Review Comment:
This class does not call [_BaseException.__init__](1) during initialization.
([ListRangeException.__init__](2) may be missing a call to a base class
__init__)
```suggestion
def __init__(self, attribute_name: str, value: list, expected_type: str):
super().__init__()
```
##########
iotdb-core/ainode/iotdb/ainode/core/exception.py:
##########
@@ -33,85 +33,102 @@ def __str__(self) -> str:
return self.message
-class BadNodeUrlError(_BaseError):
+class BadNodeUrlException(_BaseException):
def __init__(self, node_url: str):
self.message = "Bad node url: {}".format(node_url)
-class ModelNotExistError(_BaseError):
+# ==================== Model Management ====================
+
+
+class ModelExistedException(_BaseException):
+ def __init__(self, model_id: str):
+ self.message = "Model {} already exists".format(model_id)
+
+
+class ModelNotExistException(_BaseException):
+ def __init__(self, model_id: str):
+ self.message = "Model {} is not exists".format(model_id)
+
+
+class InvalidModelUriException(_BaseException):
def __init__(self, msg: str):
- self.message = "Model is not exists: {} ".format(msg)
+ self.message = (
+ "Model registration failed because the specified uri is invalid:
{}".format(
+ msg
+ )
+ )
+
+
+class BuiltInModelDeletionException(_BaseException):
+ def __init__(self, model_id: str):
+ self.message = "Cannot delete built-in model: {}".format(model_id)
-class BadConfigValueError(_BaseError):
+class BadConfigValueException(_BaseException):
def __init__(self, config_name: str, config_value, hint: str = ""):
self.message = "Bad value [{0}] for config {1}. {2}".format(
config_value, config_name, hint
)
-class MissingConfigError(_BaseError):
+class MissingConfigException(_BaseException):
def __init__(self, config_name: str):
self.message = "Missing config: {}".format(config_name)
-class MissingOptionError(_BaseError):
+class MissingOptionException(_BaseException):
def __init__(self, config_name: str):
self.message = "Missing task option: {}".format(config_name)
-class RedundantOptionError(_BaseError):
+class RedundantOptionException(_BaseException):
def __init__(self, option_name: str):
self.message = "Redundant task option: {}".format(option_name)
-class WrongTypeConfigError(_BaseError):
+class WrongTypeConfigException(_BaseException):
def __init__(self, config_name: str, expected_type: str):
self.message = "Wrong type for config: {0}, expected: {1}".format(
config_name, expected_type
)
-class UnsupportedError(_BaseError):
+class UnsupportedException(_BaseException):
Review Comment:
This class does not call [_BaseException.__init__](1) during initialization.
([UnsupportedException.__init__](2) may be missing a call to a base class
__init__)
##########
iotdb-core/ainode/iotdb/ainode/core/exception.py:
##########
@@ -33,85 +33,102 @@ def __str__(self) -> str:
return self.message
-class BadNodeUrlError(_BaseError):
+class BadNodeUrlException(_BaseException):
def __init__(self, node_url: str):
self.message = "Bad node url: {}".format(node_url)
-class ModelNotExistError(_BaseError):
+# ==================== Model Management ====================
+
+
+class ModelExistedException(_BaseException):
+ def __init__(self, model_id: str):
+ self.message = "Model {} already exists".format(model_id)
+
+
+class ModelNotExistException(_BaseException):
+ def __init__(self, model_id: str):
+ self.message = "Model {} is not exists".format(model_id)
+
+
+class InvalidModelUriException(_BaseException):
def __init__(self, msg: str):
- self.message = "Model is not exists: {} ".format(msg)
+ self.message = (
+ "Model registration failed because the specified uri is invalid:
{}".format(
+ msg
+ )
+ )
+
+
+class BuiltInModelDeletionException(_BaseException):
+ def __init__(self, model_id: str):
+ self.message = "Cannot delete built-in model: {}".format(model_id)
-class BadConfigValueError(_BaseError):
+class BadConfigValueException(_BaseException):
def __init__(self, config_name: str, config_value, hint: str = ""):
self.message = "Bad value [{0}] for config {1}. {2}".format(
config_value, config_name, hint
)
-class MissingConfigError(_BaseError):
+class MissingConfigException(_BaseException):
def __init__(self, config_name: str):
self.message = "Missing config: {}".format(config_name)
-class MissingOptionError(_BaseError):
+class MissingOptionException(_BaseException):
def __init__(self, config_name: str):
self.message = "Missing task option: {}".format(config_name)
-class RedundantOptionError(_BaseError):
+class RedundantOptionException(_BaseException):
def __init__(self, option_name: str):
self.message = "Redundant task option: {}".format(option_name)
-class WrongTypeConfigError(_BaseError):
+class WrongTypeConfigException(_BaseException):
def __init__(self, config_name: str, expected_type: str):
self.message = "Wrong type for config: {0}, expected: {1}".format(
config_name, expected_type
)
-class UnsupportedError(_BaseError):
+class UnsupportedException(_BaseException):
def __init__(self, msg: str):
self.message = "{0} is not supported in current version".format(msg)
-class InvalidUriError(_BaseError):
+class InvalidUriException(_BaseException):
def __init__(self, uri: str):
self.message = "Invalid uri: {}, there are no {} or {} under this
uri.".format(
uri, MODEL_WEIGHTS_FILE_IN_PT, MODEL_CONFIG_FILE_IN_YAML
)
-class InvalidWindowArgumentError(_BaseError):
+class InvalidWindowArgumentException(_BaseException):
def __init__(self, window_interval, window_step, dataset_length):
self.message = f"Invalid inference input: window_interval
{window_interval}, window_step {window_step}, dataset_length {dataset_length}"
-class InferenceModelInternalError(_BaseError):
+class InferenceModelInternalException(_BaseException):
def __init__(self, msg: str):
self.message = "Inference model internal error: {0}".format(msg)
-class BuiltInModelNotSupportError(_BaseError):
+class BuiltInModelNotSupportException(_BaseException):
def __init__(self, msg: str):
Review Comment:
This class does not call [_BaseException.__init__](1) during initialization.
([BuiltInModelNotSupportException.__init__](2) may be missing a call to a base
class __init__)
```suggestion
def __init__(self, msg: str):
super().__init__()
```
##########
iotdb-core/ainode/iotdb/ainode/core/exception.py:
##########
@@ -33,85 +33,102 @@ def __str__(self) -> str:
return self.message
-class BadNodeUrlError(_BaseError):
+class BadNodeUrlException(_BaseException):
def __init__(self, node_url: str):
self.message = "Bad node url: {}".format(node_url)
-class ModelNotExistError(_BaseError):
+# ==================== Model Management ====================
+
+
+class ModelExistedException(_BaseException):
+ def __init__(self, model_id: str):
+ self.message = "Model {} already exists".format(model_id)
+
+
+class ModelNotExistException(_BaseException):
+ def __init__(self, model_id: str):
+ self.message = "Model {} is not exists".format(model_id)
+
+
+class InvalidModelUriException(_BaseException):
def __init__(self, msg: str):
- self.message = "Model is not exists: {} ".format(msg)
+ self.message = (
+ "Model registration failed because the specified uri is invalid:
{}".format(
+ msg
+ )
+ )
+
+
+class BuiltInModelDeletionException(_BaseException):
+ def __init__(self, model_id: str):
+ self.message = "Cannot delete built-in model: {}".format(model_id)
-class BadConfigValueError(_BaseError):
+class BadConfigValueException(_BaseException):
def __init__(self, config_name: str, config_value, hint: str = ""):
self.message = "Bad value [{0}] for config {1}. {2}".format(
config_value, config_name, hint
)
-class MissingConfigError(_BaseError):
+class MissingConfigException(_BaseException):
def __init__(self, config_name: str):
self.message = "Missing config: {}".format(config_name)
-class MissingOptionError(_BaseError):
+class MissingOptionException(_BaseException):
def __init__(self, config_name: str):
self.message = "Missing task option: {}".format(config_name)
-class RedundantOptionError(_BaseError):
+class RedundantOptionException(_BaseException):
def __init__(self, option_name: str):
self.message = "Redundant task option: {}".format(option_name)
-class WrongTypeConfigError(_BaseError):
+class WrongTypeConfigException(_BaseException):
def __init__(self, config_name: str, expected_type: str):
self.message = "Wrong type for config: {0}, expected: {1}".format(
config_name, expected_type
)
-class UnsupportedError(_BaseError):
+class UnsupportedException(_BaseException):
def __init__(self, msg: str):
self.message = "{0} is not supported in current version".format(msg)
-class InvalidUriError(_BaseError):
+class InvalidUriException(_BaseException):
def __init__(self, uri: str):
self.message = "Invalid uri: {}, there are no {} or {} under this
uri.".format(
uri, MODEL_WEIGHTS_FILE_IN_PT, MODEL_CONFIG_FILE_IN_YAML
)
-class InvalidWindowArgumentError(_BaseError):
+class InvalidWindowArgumentException(_BaseException):
def __init__(self, window_interval, window_step, dataset_length):
self.message = f"Invalid inference input: window_interval
{window_interval}, window_step {window_step}, dataset_length {dataset_length}"
-class InferenceModelInternalError(_BaseError):
+class InferenceModelInternalException(_BaseException):
def __init__(self, msg: str):
self.message = "Inference model internal error: {0}".format(msg)
-class BuiltInModelNotSupportError(_BaseError):
+class BuiltInModelNotSupportException(_BaseException):
def __init__(self, msg: str):
self.message = "Built-in model not support: {0}".format(msg)
-class BuiltInModelDeletionError(_BaseError):
- def __init__(self, model_id: str):
- self.message = "Cannot delete built-in model: {0}".format(model_id)
-
-
-class WrongAttributeTypeError(_BaseError):
+class WrongAttributeTypeException(_BaseException):
def __init__(self, attribute_name: str, expected_type: str):
Review Comment:
This class does not call [_BaseException.__init__](1) during initialization.
([WrongAttributeTypeException.__init__](2) may be missing a call to a base
class __init__)
```suggestion
def __init__(self, attribute_name: str, expected_type: str):
super().__init__()
```
##########
iotdb-core/ainode/iotdb/ainode/core/exception.py:
##########
@@ -136,7 +153,7 @@ def __init__(self, attribute_name: str, value: list,
expected_type: str):
)
-class AttributeNotSupportError(_BaseError):
+class AttributeNotSupportException(_BaseException):
Review Comment:
This class does not call [_BaseException.__init__](1) during initialization.
([AttributeNotSupportException.__init__](2) may be missing a call to a base
class __init__)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]