This is an automated email from the ASF dual-hosted git repository.
yongzao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/master by this push:
new 95fb59e6220 [AINode] Fix circular import bug (#16137)
95fb59e6220 is described below
commit 95fb59e6220baa1b07cfbdfb294cfc7fc3379195
Author: Yongzao <[email protected]>
AuthorDate: Mon Aug 11 11:11:05 2025 +0800
[AINode] Fix circular import bug (#16137)
---
iotdb-core/ainode/ainode/core/constant.py | 2 +-
.../ainode/ainode/core/manager/model_manager.py | 3 +-
.../ainode/core/model/built_in_model_factory.py | 3 +-
iotdb-core/ainode/ainode/core/model/model_enums.py | 70 ++++++++++++++++++++++
.../ainode/ainode/core/model/model_factory.py | 2 +-
iotdb-core/ainode/ainode/core/model/model_info.py | 59 ++----------------
.../ainode/ainode/core/model/model_storage.py | 10 ++--
iotdb-core/ainode/ainode/core/model/uri_utils.py | 3 +-
8 files changed, 90 insertions(+), 62 deletions(-)
diff --git a/iotdb-core/ainode/ainode/core/constant.py
b/iotdb-core/ainode/ainode/core/constant.py
index 009f66caaf5..5a55b4d283b 100644
--- a/iotdb-core/ainode/ainode/core/constant.py
+++ b/iotdb-core/ainode/ainode/core/constant.py
@@ -21,7 +21,7 @@ import os
from enum import Enum
from typing import List
-from ainode.core.model.model_info import BuiltInModelType
+from ainode.core.model.model_enums import BuiltInModelType
from ainode.thrift.common.ttypes import TEndPoint
AINODE_VERSION_INFO = "UNKNOWN"
diff --git a/iotdb-core/ainode/ainode/core/manager/model_manager.py
b/iotdb-core/ainode/ainode/core/manager/model_manager.py
index d149c816568..69b163afd97 100644
--- a/iotdb-core/ainode/ainode/core/manager/model_manager.py
+++ b/iotdb-core/ainode/ainode/core/manager/model_manager.py
@@ -26,7 +26,8 @@ from ainode.core.exception import (
InvalidUriError,
)
from ainode.core.log import Logger
-from ainode.core.model.model_info import BuiltInModelType, ModelInfo,
ModelStates
+from ainode.core.model.model_enums import BuiltInModelType, ModelStates
+from ainode.core.model.model_info import ModelInfo
from ainode.core.model.model_storage import ModelStorage
from ainode.core.rpc.status import get_status
from ainode.core.util.decorator import singleton
diff --git a/iotdb-core/ainode/ainode/core/model/built_in_model_factory.py
b/iotdb-core/ainode/ainode/core/model/built_in_model_factory.py
index 6ac708ebebf..f1bf4952fe2 100644
--- a/iotdb-core/ainode/ainode/core/model/built_in_model_factory.py
+++ b/iotdb-core/ainode/ainode/core/model/built_in_model_factory.py
@@ -44,7 +44,8 @@ from ainode.core.exception import (
WrongAttributeTypeError,
)
from ainode.core.log import Logger
-from ainode.core.model.model_info import TIMER_REPO_ID, BuiltInModelType
+from ainode.core.model.model_enums import BuiltInModelType
+from ainode.core.model.model_info import TIMER_REPO_ID
from ainode.core.model.sundial import modeling_sundial
from ainode.core.model.timerxl import modeling_timer
diff --git a/iotdb-core/ainode/ainode/core/model/model_enums.py
b/iotdb-core/ainode/ainode/core/model/model_enums.py
new file mode 100644
index 00000000000..348f9924316
--- /dev/null
+++ b/iotdb-core/ainode/ainode/core/model/model_enums.py
@@ -0,0 +1,70 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+from enum import Enum
+from typing import List
+
+
+class BuiltInModelType(Enum):
+ # forecast models
+ ARIMA = "Arima"
+ HOLTWINTERS = "HoltWinters"
+ EXPONENTIAL_SMOOTHING = "ExponentialSmoothing"
+ NAIVE_FORECASTER = "NaiveForecaster"
+ STL_FORECASTER = "StlForecaster"
+
+ # anomaly detection models
+ GAUSSIAN_HMM = "GaussianHmm"
+ GMM_HMM = "GmmHmm"
+ STRAY = "Stray"
+
+ # large time series models (LTSM)
+ TIMER_XL = "Timer-XL"
+ # sundial
+ SUNDIAL = "Timer-Sundial"
+
+ @classmethod
+ def values(cls) -> List[str]:
+ return [item.value for item in cls]
+
+ @staticmethod
+ def is_built_in_model(model_type: str) -> bool:
+ """
+ Check if the given model type corresponds to a built-in model.
+ """
+ return model_type in BuiltInModelType.values()
+
+
+class ModelFileType(Enum):
+ SAFETENSORS = "safetensors"
+ PYTORCH = "pytorch"
+ UNKNOWN = "unknown"
+
+
+class ModelCategory(Enum):
+ BUILT_IN = "BUILT-IN"
+ FINE_TUNED = "FINE-TUNED"
+ USER_DEFINED = "USER-DEFINED"
+
+
+class ModelStates(Enum):
+ ACTIVE = "ACTIVE"
+ INACTIVE = "INACTIVE"
+ LOADING = "LOADING"
+ DROPPING = "DROPPING"
+ TRAINING = "TRAINING"
+ FAILED = "FAILED"
diff --git a/iotdb-core/ainode/ainode/core/model/model_factory.py
b/iotdb-core/ainode/ainode/core/model/model_factory.py
index 0b21b56593f..5bbcf321644 100644
--- a/iotdb-core/ainode/ainode/core/model/model_factory.py
+++ b/iotdb-core/ainode/ainode/core/model/model_factory.py
@@ -28,7 +28,7 @@ from ainode.core.constant import (
)
from ainode.core.exception import BadConfigValueError, InvalidUriError
from ainode.core.log import Logger
-from ainode.core.model.model_info import ModelFileType
+from ainode.core.model.model_enums import ModelFileType
from ainode.core.model.uri_utils import (
UriType,
download_file,
diff --git a/iotdb-core/ainode/ainode/core/model/model_info.py
b/iotdb-core/ainode/ainode/core/model/model_info.py
index 7d8a5418bbf..6226179dbcb 100644
--- a/iotdb-core/ainode/ainode/core/model/model_info.py
+++ b/iotdb-core/ainode/ainode/core/model/model_info.py
@@ -17,8 +17,6 @@
#
import glob
import os
-from enum import Enum
-from typing import List
from ainode.core.constant import (
MODEL_CONFIG_FILE_IN_JSON,
@@ -26,42 +24,12 @@ from ainode.core.constant import (
MODEL_WEIGHTS_FILE_IN_PT,
MODEL_WEIGHTS_FILE_IN_SAFETENSORS,
)
-
-
-class BuiltInModelType(Enum):
- # forecast models
- ARIMA = "Arima"
- HOLTWINTERS = "HoltWinters"
- EXPONENTIAL_SMOOTHING = "ExponentialSmoothing"
- NAIVE_FORECASTER = "NaiveForecaster"
- STL_FORECASTER = "StlForecaster"
-
- # anomaly detection models
- GAUSSIAN_HMM = "GaussianHmm"
- GMM_HMM = "GmmHmm"
- STRAY = "Stray"
-
- # large time series models (LTSM)
- TIMER_XL = "Timer-XL"
- # sundial
- SUNDIAL = "Timer-Sundial"
-
- @classmethod
- def values(cls) -> List[str]:
- return [item.value for item in cls]
-
- @staticmethod
- def is_built_in_model(model_type: str) -> bool:
- """
- Check if the given model type corresponds to a built-in model.
- """
- return model_type in BuiltInModelType.values()
-
-
-class ModelFileType(Enum):
- SAFETENSORS = "safetensors"
- PYTORCH = "pytorch"
- UNKNOWN = "unknown"
+from ainode.core.model.model_enums import (
+ BuiltInModelType,
+ ModelCategory,
+ ModelFileType,
+ ModelStates,
+)
def get_model_file_type(model_path: str) -> ModelFileType:
@@ -96,21 +64,6 @@ def get_built_in_model_type(model_type: str) ->
BuiltInModelType:
return BuiltInModelType(model_type)
-class ModelCategory(Enum):
- BUILT_IN = "BUILT-IN"
- FINE_TUNED = "FINE-TUNED"
- USER_DEFINED = "USER-DEFINED"
-
-
-class ModelStates(Enum):
- ACTIVE = "ACTIVE"
- INACTIVE = "INACTIVE"
- LOADING = "LOADING"
- DROPPING = "DROPPING"
- TRAINING = "TRAINING"
- FAILED = "FAILED"
-
-
class ModelInfo:
def __init__(
self,
diff --git a/iotdb-core/ainode/ainode/core/model/model_storage.py
b/iotdb-core/ainode/ainode/core/model/model_storage.py
index a87834a1a18..ebfa9211811 100644
--- a/iotdb-core/ainode/ainode/core/model/model_storage.py
+++ b/iotdb-core/ainode/ainode/core/model/model_storage.py
@@ -42,15 +42,17 @@ from ainode.core.model.built_in_model_factory import (
download_built_in_ltsm_from_hf_if_necessary,
fetch_built_in_model,
)
+from ainode.core.model.model_enums import (
+ BuiltInModelType,
+ ModelCategory,
+ ModelFileType,
+ ModelStates,
+)
from ainode.core.model.model_factory import fetch_model_by_uri
from ainode.core.model.model_info import (
BUILT_IN_LTSM_MAP,
BUILT_IN_MACHINE_LEARNING_MODEL_MAP,
- BuiltInModelType,
- ModelCategory,
- ModelFileType,
ModelInfo,
- ModelStates,
get_built_in_model_type,
get_model_file_type,
)
diff --git a/iotdb-core/ainode/ainode/core/model/uri_utils.py
b/iotdb-core/ainode/ainode/core/model/uri_utils.py
index 1f162212ead..de2fb2a1848 100644
--- a/iotdb-core/ainode/ainode/core/model/uri_utils.py
+++ b/iotdb-core/ainode/ainode/core/model/uri_utils.py
@@ -30,7 +30,8 @@ from ainode.core.constant import (
)
from ainode.core.exception import UnsupportedError
from ainode.core.log import Logger
-from ainode.core.model.model_info import ModelFileType, get_model_file_type
+from ainode.core.model.model_enums import ModelFileType
+from ainode.core.model.model_info import get_model_file_type
HTTP_PREFIX = "http://"
HTTPS_PREFIX = "https://"