Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ public class AINodeCallInferenceIT {

private static final String CALL_INFERENCE_SQL_TEMPLATE =
"CALL INFERENCE(%s, \"SELECT s%d FROM root.AI LIMIT %d\", generateTime=true, outputLength=%d)";
private static final String CALL_INFERENCE_BY_DEFAULT_SQL_TEMPLATE =
"CALL INFERENCE(%s, \"SELECT s%d FROM root.AI LIMIT 256\")";
private static final int DEFAULT_INPUT_LENGTH = 256;
private static final int DEFAULT_OUTPUT_LENGTH = 48;

Expand All @@ -69,6 +71,7 @@ public void callInferenceTest() throws SQLException {
try (Connection connection = EnvFactory.getEnv().getConnection(BaseEnv.TREE_SQL_DIALECT);
Statement statement = connection.createStatement()) {
callInferenceTest(statement, modelInfo);
callInferenceByDefaultTest(statement, modelInfo);
}
}
}
Expand Down Expand Up @@ -96,4 +99,23 @@ public static void callInferenceTest(Statement statement, AINodeTestUtils.FakeMo
}
}
}

public static void callInferenceByDefaultTest(
Statement statement, AINodeTestUtils.FakeModelInfo modelInfo) throws SQLException {
// Invoke call inference for specified models, there should exist result.
for (int i = 0; i < 4; i++) {
String callInferenceSQL =
String.format(CALL_INFERENCE_BY_DEFAULT_SQL_TEMPLATE, modelInfo.getModelId(), i);
try (ResultSet resultSet = statement.executeQuery(callInferenceSQL)) {
ResultSetMetaData resultSetMetaData = resultSet.getMetaData();
checkHeader(resultSetMetaData, "output");
int count = 0;
while (resultSet.next()) {
count++;
}
// Ensure the call inference return results
Assert.assertTrue(count > 0);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,11 @@ def inference(self, req: TInferenceReq):
req,
data_getter=lambda r: r.dataset,
extract_attrs=lambda r: {
"output_length": int(r.inferenceAttributes.pop("outputLength", 96)),
"output_length": (
96
if r.inferenceAttributes is None
else int(r.inferenceAttributes.pop("outputLength", 96))
),
**(r.inferenceAttributes or {}),
},
resp_cls=TInferenceResp,
Expand Down
Loading