Skip to content

Commit 3cfcc75

Browse files
committed
[AINode] Fix cp errors
1 parent e70b66d commit 3cfcc75

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+2292
-4651
lines changed

.github/workflows/cluster-it-1c1d1a.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,6 @@ jobs:
4141

4242
steps:
4343
- uses: actions/checkout@v4
44-
- name: Build AINode
45-
shell: bash
46-
run: mvn clean package -DskipTests -P with-ainode
4744
- name: IT Test
4845
shell: bash
4946
run: |

iotdb-core/ainode/.flake8

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
#
18+
[flake8]
19+
ignore =
20+
E203,
21+
W503
22+
max-line-length=200
23+
exclude =
24+
.git,
25+
tests/*,
26+
iotdb/thrift/**/*
27+
extend-exclude =
28+
dist,
29+
build,
30+
venv
31+
show-source = True
32+
statistics = True
33+
format = %(path)s:%(row)d,%(col)d:%(code)s:%(text)s:https://lintlyci.github.io/Flake8Rules/rules/%(code)s.html

iotdb-core/ainode/build_binary.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
def get_venv_base_dir():
3232
"""
3333
Get the base directory for virtual environments outside the project.
34-
34+
3535
Returns:
3636
Path: Base directory path
3737
- Linux/macOS: ~/.cache/iotdb-ainode-build/
@@ -51,13 +51,13 @@ def get_venv_base_dir():
5151
def setup_venv():
5252
"""
5353
Create virtual environment outside the project directory.
54-
54+
5555
The virtual environment is created in a platform-specific location:
5656
- Linux/macOS: ~/.cache/iotdb-ainode-build/<project-name>/
5757
- Windows: %LOCALAPPDATA%\\iotdb-ainode-build\\<project-name>\\
58-
58+
5959
The same venv is reused across multiple builds of the same project.
60-
60+
6161
Returns:
6262
Path: Path to the virtual environment directory
6363
"""

iotdb-core/ainode/iotdb/Session.py

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,46 +18,48 @@
1818

1919
import logging
2020
import random
21-
import sys
2221
import struct
22+
import sys
2323
import warnings
24+
2425
from thrift.protocol import TBinaryProtocol, TCompactProtocol
2526
from thrift.transport import TSocket, TTransport
2627
from tzlocal import get_localzone_name
2728

2829
from iotdb.utils.SessionDataSet import SessionDataSet
30+
2931
from .template.Template import Template
3032
from .template.TemplateQueryType import TemplateQueryType
3133
from .thrift.common.ttypes import TEndPoint
3234
from .thrift.rpc.IClientRPCService import (
3335
Client,
34-
TSCreateTimeseriesReq,
36+
TSAppendSchemaTemplateReq,
37+
TSCloseSessionReq,
3538
TSCreateAlignedTimeseriesReq,
39+
TSCreateMultiTimeseriesReq,
40+
TSCreateSchemaTemplateReq,
41+
TSCreateTimeseriesReq,
42+
TSDropSchemaTemplateReq,
43+
TSExecuteStatementReq,
3644
TSInsertRecordReq,
45+
TSInsertRecordsOfOneDeviceReq,
46+
TSInsertRecordsReq,
3747
TSInsertStringRecordReq,
3848
TSInsertTabletReq,
39-
TSExecuteStatementReq,
40-
TSOpenSessionReq,
41-
TSCreateMultiTimeseriesReq,
42-
TSCloseSessionReq,
4349
TSInsertTabletsReq,
44-
TSInsertRecordsReq,
45-
TSInsertRecordsOfOneDeviceReq,
46-
TSCreateSchemaTemplateReq,
47-
TSDropSchemaTemplateReq,
48-
TSAppendSchemaTemplateReq,
50+
TSOpenSessionReq,
4951
TSPruneSchemaTemplateReq,
52+
TSQueryTemplateReq,
5053
TSSetSchemaTemplateReq,
5154
TSUnsetSchemaTemplateReq,
52-
TSQueryTemplateReq,
5355
)
5456
from .thrift.rpc.ttypes import (
5557
TSDeleteDataReq,
58+
TSInsertStringRecordsOfOneDeviceReq,
59+
TSLastDataQueryReq,
5660
TSProtocolVersion,
57-
TSSetTimeZoneReq,
5861
TSRawDataQueryReq,
59-
TSLastDataQueryReq,
60-
TSInsertStringRecordsOfOneDeviceReq,
62+
TSSetTimeZoneReq,
6163
)
6264
from .tsfile.utils.date_utils import parse_date_to_int
6365
from .utils import rpc_utils
@@ -245,6 +247,7 @@ def init_connection(self, endpoint):
245247
def __get_transport(self, endpoint):
246248
if self.__use_ssl:
247249
import ssl
250+
248251
from thrift.transport import TSSLSocket
249252

250253
if sys.version_info >= (3, 10):
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
#

iotdb-core/ainode/iotdb/ainode/core/ai_node.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,19 @@
2323
import psutil
2424

2525
from iotdb.ainode.core.config import AINodeDescriptor
26-
from ainode.core.constant import AINODE_SYSTEM_FILE_NAME
27-
from ainode.core.log import Logger
28-
from ainode.core.rpc.client import ClientManager
29-
from ainode.core.rpc.handler import AINodeRPCServiceHandler
30-
from ainode.core.rpc.service import AINodeRPCService
31-
from ainode.thrift.common.ttypes import (
26+
from iotdb.ainode.core.constant import AINODE_SYSTEM_FILE_NAME
27+
from iotdb.ainode.core.exception import MissingConfigError
28+
from iotdb.ainode.core.log import Logger
29+
from iotdb.ainode.core.rpc.client import ClientManager
30+
from iotdb.ainode.core.rpc.handler import AINodeRPCServiceHandler
31+
from iotdb.ainode.core.rpc.service import AINodeRPCService
32+
from iotdb.thrift.common.ttypes import (
3233
TAINodeConfiguration,
3334
TAINodeLocation,
3435
TEndPoint,
3536
TNodeResource,
3637
)
37-
from ainode.thrift.confignode.ttypes import TNodeVersionInfo
38+
from iotdb.thrift.confignode.ttypes import TNodeVersionInfo
3839

3940
logger = Logger()
4041

iotdb-core/ainode/iotdb/ainode/core/config.py

Lines changed: 73 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@
1717
#
1818
import os
1919
import re
20+
import threading
2021

21-
from ainode.core.constant import (
22+
from iotdb.ainode.core.constant import (
2223
AINODE_BUILD_INFO,
2324
AINODE_BUILTIN_MODELS_DIR,
2425
AINODE_CLUSTER_INGRESS_ADDRESS,
@@ -47,9 +48,9 @@
4748
AINODE_VERSION_INFO,
4849
)
4950
from iotdb.ainode.core.exception import BadNodeUrlError
50-
from ainode.core.log import Logger
51-
from ainode.core.util.decorator import singleton
52-
from ainode.thrift.common.ttypes import TEndPoint
51+
from iotdb.ainode.core.log import Logger
52+
from iotdb.ainode.core.util.decorator import singleton
53+
from iotdb.thrift.common.ttypes import TEndPoint
5354

5455
logger = Logger()
5556

@@ -101,15 +102,37 @@ def __init__(self):
101102
# Whether to enable compression for thrift
102103
self._ain_thrift_compression_enabled = AINODE_THRIFT_COMPRESSION_ENABLED
103104

105+
# use for ssl
106+
self._ain_cluster_ingress_ssl_enabled = False
107+
self._ain_internal_ssl_enabled = False
108+
self._ain_thrift_ssl_cert_file = None
109+
self._ain_thrift_ssl_key_file = None
110+
104111
# Cache number of model storage to avoid repeated loading
105112
self._ain_model_storage_cache_size = 30
106113

114+
# activation
115+
self._ain_activated = threading.Event()
116+
107117
def get_cluster_name(self) -> str:
108118
return self._cluster_name
109119

110120
def set_cluster_name(self, cluster_name: str) -> None:
111121
self._cluster_name = cluster_name
112122

123+
def is_activated(self) -> bool:
124+
return self._ain_activated.is_set()
125+
126+
def set_activated(self, is_activated: bool) -> None:
127+
if is_activated:
128+
if not self._ain_activated.is_set():
129+
logger.info("TimechoDB-AINode is activated.")
130+
self._ain_activated.set()
131+
else:
132+
if self._ain_activated.is_set():
133+
logger.info("TimechoDB-AINode is deactivated.")
134+
self._ain_activated.clear()
135+
113136
def get_version_info(self) -> str:
114137
return self._version_info
115138

@@ -218,6 +241,32 @@ def set_ain_thrift_compression_enabled(
218241
) -> None:
219242
self._ain_thrift_compression_enabled = ain_thrift_compression_enabled
220243

244+
def get_ain_cluster_ingress_ssl_enabled(self) -> bool:
245+
return self._ain_cluster_ingress_ssl_enabled
246+
247+
def set_ain_cluster_ingress_ssl_enabled(
248+
self, ain_cluster_ingress_ssl_enabled: int
249+
) -> None:
250+
self._ain_cluster_ingress_ssl_enabled = ain_cluster_ingress_ssl_enabled
251+
252+
def get_ain_internal_ssl_enabled(self) -> bool:
253+
return self._ain_internal_ssl_enabled
254+
255+
def set_ain_internal_ssl_enabled(self, ain_internal_ssl_enabled: int) -> None:
256+
self._ain_internal_ssl_enabled = ain_internal_ssl_enabled
257+
258+
def get_ain_thrift_ssl_cert_file(self) -> str:
259+
return self._ain_thrift_ssl_cert_file
260+
261+
def set_ain_thrift_ssl_cert_file(self, ain_thrift_ssl_cert_file: str) -> None:
262+
self._ain_thrift_ssl_cert_file = ain_thrift_ssl_cert_file
263+
264+
def get_ain_thrift_ssl_key_file(self) -> str:
265+
return self._ain_thrift_ssl_key_file
266+
267+
def set_ain_thrift_ssl_key_file(self, ain_thrift_ssl_key_file: str) -> None:
268+
self._ain_thrift_ssl_key_file = ain_thrift_ssl_key_file
269+
221270
def get_ain_model_storage_cache_size(self) -> int:
222271
return self._ain_model_storage_cache_size
223272

@@ -358,6 +407,26 @@ def _load_config_from_file(self) -> None:
358407
int(file_configs["ain_thrift_compression_enabled"])
359408
)
360409

410+
if "ain_cluster_ingress_ssl_enabled" in config_keys:
411+
self._config.set_ain_cluster_ingress_ssl_enabled(
412+
int(file_configs["ain_cluster_ingress_ssl_enabled"])
413+
)
414+
415+
if "ain_internal_ssl_enabled" in config_keys:
416+
self._config.set_ain_internal_ssl_enabled(
417+
int(file_configs["ain_internal_ssl_enabled"])
418+
)
419+
420+
if "ain_thrift_ssl_cert_file" in config_keys:
421+
self._config.set_ain_thrift_ssl_cert_file(
422+
file_configs["ain_thrift_ssl_cert_file"]
423+
)
424+
425+
if "ain_thrift_ssl_key_file" in config_keys:
426+
self._config.set_ain_thrift_ssl_key_file(
427+
file_configs["ain_thrift_ssl_key_file"]
428+
)
429+
361430
if "ain_logs_dir" in config_keys:
362431
log_dir = file_configs["ain_logs_dir"]
363432
self._config.set_ain_logs_dir(log_dir)

iotdb-core/ainode/iotdb/ainode/core/constant.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,14 @@
1515
# specific language governing permissions and limitations
1616
# under the License.
1717
#
18+
1819
import logging
1920
import os
2021
from enum import Enum
2122
from typing import List
2223

2324
from iotdb.ainode.core.model.model_enums import BuiltInModelType
24-
from ainode.thrift.common.ttypes import TEndPoint
25+
from iotdb.thrift.common.ttypes import TEndPoint
2526

2627
IOTDB_AINODE_HOME = os.getenv("IOTDB_AINODE_HOME", "")
2728
AINODE_VERSION_INFO = "UNKNOWN"
@@ -40,7 +41,7 @@
4041
AINODE_CLUSTER_INGRESS_ADDRESS = "127.0.0.1"
4142
AINODE_CLUSTER_INGRESS_PORT = 6667
4243
AINODE_CLUSTER_INGRESS_USERNAME = "root"
43-
AINODE_CLUSTER_INGRESS_PASSWORD = "root"
44+
AINODE_CLUSTER_INGRESS_PASSWORD = "TimechoDB@2021"
4445
AINODE_CLUSTER_INGRESS_TIME_ZONE = "UTC+8"
4546

4647
# RPC config
@@ -76,6 +77,9 @@
7677
INFERENCE_LOG_FILE_NAME_PREFIX_TEMPLATE = (
7778
"log_inference_rank_{}_" # example: log_inference_rank_0_all.log
7879
)
80+
TRAINING_LOG_FILE_NAME_PREFIX_TEMPLATE = (
81+
"log_training_rank_{}_" # example: log_training_rank_0_all.log
82+
)
7983

8084
# AINode model management
8185
MODEL_WEIGHTS_FILE_IN_SAFETENSORS = "model.safetensors"
@@ -96,6 +100,10 @@ class TSStatusCode(Enum):
96100
INVALID_INFERENCE_CONFIG = 1512
97101
INFERENCE_INTERNAL_ERROR = 1520
98102

103+
# Training status codes
104+
INVALID_TRAINING_CONFIG = 1550
105+
TRAINING_INTERNAL_ERROR = 1551
106+
99107
def get_status_code(self) -> int:
100108
return self.value
101109

iotdb-core/ainode/iotdb/ainode/core/exception.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@
1717
#
1818
import re
1919

20-
from ainode.core.constant import MODEL_CONFIG_FILE_IN_YAML, MODEL_WEIGHTS_FILE_IN_PT
20+
from iotdb.ainode.core.constant import (
21+
MODEL_CONFIG_FILE_IN_YAML,
22+
MODEL_WEIGHTS_FILE_IN_PT,
23+
)
2124

2225

2326
class _BaseError(Exception):

0 commit comments

Comments
 (0)