Skip to content

Commit 911c58d

Browse files
committed
Merge branch 'master' of https://github.com/apache/iotdb into pipe-api
2 parents 774dfdb + ca26dd3 commit 911c58d

File tree

10 files changed

+328
-83
lines changed

10 files changed

+328
-83
lines changed

integration-test/src/test/java/org/apache/iotdb/ainode/it/AINodeConcurrentForecastIT.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,9 @@
3636
import java.sql.Connection;
3737
import java.sql.SQLException;
3838
import java.sql.Statement;
39+
import java.util.Arrays;
40+
import java.util.List;
3941

40-
import static org.apache.iotdb.ainode.utils.AINodeTestUtils.BUILTIN_LTSM_MAP;
4142
import static org.apache.iotdb.ainode.utils.AINodeTestUtils.checkModelNotOnSpecifiedDevice;
4243
import static org.apache.iotdb.ainode.utils.AINodeTestUtils.checkModelOnSpecifiedDevice;
4344
import static org.apache.iotdb.ainode.utils.AINodeTestUtils.concurrentInference;
@@ -48,6 +49,11 @@ public class AINodeConcurrentForecastIT {
4849

4950
private static final Logger LOGGER = LoggerFactory.getLogger(AINodeConcurrentForecastIT.class);
5051

52+
private static final List<AINodeTestUtils.FakeModelInfo> MODEL_LIST =
53+
Arrays.asList(
54+
new AINodeTestUtils.FakeModelInfo("sundial", "sundial", "builtin", "active"),
55+
new AINodeTestUtils.FakeModelInfo("timer_xl", "timer", "builtin", "active"));
56+
5157
private static final String FORECAST_TABLE_FUNCTION_SQL_TEMPLATE =
5258
"SELECT * FROM FORECAST(model_id=>'%s', targets=>(SELECT time,s FROM root.AI) ORDER BY time, output_length=>%d)";
5359

@@ -78,7 +84,7 @@ private static void prepareDataForTableModel() throws SQLException {
7884

7985
@Test
8086
public void concurrentGPUForecastTest() throws SQLException, InterruptedException {
81-
for (AINodeTestUtils.FakeModelInfo modelInfo : BUILTIN_LTSM_MAP.values()) {
87+
for (AINodeTestUtils.FakeModelInfo modelInfo : MODEL_LIST) {
8288
concurrentGPUForecastTest(modelInfo);
8389
}
8490
}

iotdb-api/pipe-api/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@
3535
<version>${tsfile.version}</version>
3636
<scope>provided</scope>
3737
</dependency>
38+
<dependency>
39+
<groupId>junit</groupId>
40+
<artifactId>junit</artifactId>
41+
<scope>test</scope>
42+
</dependency>
3843
</dependencies>
3944
<profiles>
4045
<profile>

iotdb-api/pipe-api/src/main/java/org/apache/iotdb/pipe/api/customizer/parameter/PipeParameters.java

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -367,24 +367,35 @@ public PipeParameters addOrReplaceEquivalentAttributesWithClone(final PipeParame
367367

368368
private static class KeyReducer {
369369

370-
private static final Set<String> PREFIXES = new HashSet<>();
370+
private static final Set<String> FIRST_PREFIXES = new HashSet<>();
371+
private static final Set<String> SECOND_PREFIXES = new HashSet<>();
371372

372373
static {
373-
PREFIXES.add("extractor.");
374-
PREFIXES.add("source.");
375-
PREFIXES.add("processor.");
376-
PREFIXES.add("connector.");
377-
PREFIXES.add("sink.");
374+
FIRST_PREFIXES.add("extractor.");
375+
FIRST_PREFIXES.add("source.");
376+
FIRST_PREFIXES.add("processor.");
377+
FIRST_PREFIXES.add("connector.");
378+
FIRST_PREFIXES.add("sink.");
379+
380+
SECOND_PREFIXES.add("opcua.");
378381
}
379382

380-
static String reduce(final String key) {
383+
static String reduce(String key) {
381384
if (key == null) {
382385
return null;
383386
}
384-
final String lowerCaseKey = key.toLowerCase();
385-
for (final String prefix : PREFIXES) {
387+
String lowerCaseKey = key.toLowerCase();
388+
for (final String prefix : FIRST_PREFIXES) {
389+
if (lowerCaseKey.startsWith(prefix)) {
390+
key = key.substring(prefix.length());
391+
lowerCaseKey = lowerCaseKey.substring(prefix.length());
392+
break;
393+
}
394+
}
395+
for (final String prefix : SECOND_PREFIXES) {
386396
if (lowerCaseKey.startsWith(prefix)) {
387-
return key.substring(prefix.length());
397+
key = key.substring(prefix.length());
398+
break;
388399
}
389400
}
390401
return key;
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
package org.apache.iotdb.pipe.api.customizer.parameter;
21+
22+
import org.junit.Assert;
23+
import org.junit.Test;
24+
25+
import java.util.HashMap;
26+
27+
public class PipeParametersTest {
28+
29+
@Test
30+
public void keyReducerTest() {
31+
final PipeParameters parameters = new PipeParameters(new HashMap<>());
32+
parameters.addAttribute("sink.opcua.with-quality", "false");
33+
34+
Assert.assertEquals(false, parameters.getBoolean("with-quality"));
35+
Assert.assertEquals(false, parameters.getBoolean("opcua.with-quality"));
36+
37+
// Invalid
38+
parameters.addAttribute("sink.source.opcua.value-name", "false");
39+
parameters.addAttribute("opcua.sink.value-name", "false");
40+
Assert.assertNull(parameters.getString("value-name"));
41+
}
42+
}

iotdb-core/ainode/iotdb/ainode/core/model/model_info.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ def __repr__(self):
116116
"AutoConfig": "configuration_timer.TimerConfig",
117117
"AutoModelForCausalLM": "modeling_timer.TimerForPrediction",
118118
},
119+
_transformers_registered=True,
119120
),
120121
"sundial": ModelInfo(
121122
model_id="sundial",
@@ -128,5 +129,6 @@ def __repr__(self):
128129
"AutoConfig": "configuration_sundial.SundialConfig",
129130
"AutoModelForCausalLM": "modeling_sundial.SundialForPrediction",
130131
},
132+
_transformers_registered=True,
131133
),
132134
}

iotdb-core/ainode/iotdb/ainode/core/model/model_storage.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,12 @@ def _callback_model_download_result(self, future, model_id: str):
196196
if os.path.exists(config_path):
197197
with open(config_path, "r", encoding="utf-8") as f:
198198
config = json.load(f)
199-
if model_info.model_type == "":
200-
model_info.model_type = config.get("model_type", "")
201-
model_info.auto_map = config.get("auto_map", None)
199+
model_info.model_type = config.get(
200+
"model_type", model_info.model_type
201+
)
202+
model_info.auto_map = config.get(
203+
"auto_map", model_info.auto_map
204+
)
202205
logger.info(
203206
f"Model {model_id} downloaded successfully and is ready to use."
204207
)

0 commit comments

Comments
 (0)