Skip to content

Commit fc902af

Browse files
committed
debugging
Signed-off-by: Sicheng Song <sicheng.song@outlook.com>
1 parent f223c74 commit fc902af

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

plugin/src/main/java/org/opensearch/ml/action/prediction/TransportPredictionTaskAction.java

+7
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,14 @@ public void onResponse(MLModel mlModel) {
156156
)
157157
);
158158
} else {
159+
log.info("ModelId " + modelId + " is enabled for prediction in local layer.");
160+
log.info(mlPredictionTaskRequest.getMlInput().toXContent(XContentFactory.jsonBuilder(), ToXContent.EMPTY_PARAMS).toString());
161+
validateInputSchema(modelId, mlPredictionTaskRequest.getMlInput());
159162
executePredict(mlPredictionTaskRequest, wrappedListener, modelId);
160163
}
161164
} else {
165+
log.info("ModelId " + modelId + " is enabled for prediction in remote layer.");
166+
log.info(mlPredictionTaskRequest.getMlInput().toXContent(XContentFactory.jsonBuilder(), ToXContent.EMPTY_PARAMS).toString());
162167
validateInputSchema(modelId, mlPredictionTaskRequest.getMlInput());
163168
executePredict(mlPredictionTaskRequest, wrappedListener, modelId);
164169
}
@@ -234,8 +239,10 @@ private void executePredict(
234239
}
235240

236241
private void validateInputSchema(String modelId, MLInput mlInput) {
242+
log.info("Went to validate input schema");
237243
if (modelCacheHelper.getModelInterface(modelId) != null && modelCacheHelper.getModelInterface(modelId).get("input") != null) {
238244
String inputSchemaString = modelCacheHelper.getModelInterface(modelId).get("input");
245+
log.info(inputSchemaString);
239246
try {
240247
MLNodeUtils
241248
.validateSchema(

plugin/src/main/java/org/opensearch/ml/task/MLPredictTaskRunner.java

+5
Original file line numberDiff line numberDiff line change
@@ -380,12 +380,15 @@ private void runPredict(
380380
((MLPredictionOutput) output).setStatus(MLTaskState.COMPLETED.name());
381381
}
382382
if (output instanceof ModelTensorOutput) {
383+
log.info("ModelId " + modelId + " is completed for prediction.");
383384
// pick the first output tensor to validate the schema
384385
if (((ModelTensorOutput) output).getMlModelOutputs() != null
385386
&& !((ModelTensorOutput) output).getMlModelOutputs().isEmpty()) {
386387
ModelTensors modelTensors = ((ModelTensorOutput) output).getMlModelOutputs().get(0);
388+
log.info(modelTensors.toXContent(XContentFactory.jsonBuilder(), ToXContent.EMPTY_PARAMS).toString());
387389
if (modelTensors.getMlModelTensors() != null && !modelTensors.getMlModelTensors().isEmpty()) {
388390
ModelTensor modelTensorOutput = modelTensors.getMlModelTensors().get(0);
391+
log.info(modelTensorOutput.toXContent(XContentFactory.jsonBuilder(), ToXContent.EMPTY_PARAMS).toString());
389392
validateOutputSchema(modelId, modelTensorOutput);
390393
}
391394
}
@@ -447,8 +450,10 @@ private void handlePredictFailure(
447450
}
448451

449452
private void validateOutputSchema(String modelId, ModelTensor modelTensor) {
453+
log.info("Went to validate output schema");
450454
if (mlModelManager.getModelInterface(modelId) != null && mlModelManager.getModelInterface(modelId).get("output") != null) {
451455
String outputSchemaString = mlModelManager.getModelInterface(modelId).get("output");
456+
log.info(outputSchemaString);
452457
try {
453458
MLNodeUtils
454459
.validateSchema(

plugin/src/main/java/org/opensearch/ml/utils/MLNodeUtils.java

-2
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,9 @@ public static <T> void parseField(XContentParser parser, Set<T> set, Function<St
6767

6868
public static void validateSchema(String schemaString, String instanceString) throws IOException {
6969
ObjectMapper mapper = new ObjectMapper();
70-
System.out.println(schemaString);
7170
// parse the schema JSON as string
7271
JsonNode schemaNode = mapper.readTree(schemaString);
7372
JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaNode);
74-
System.out.println(instanceString);
7573
// JSON data to validate
7674
JsonNode jsonNode = mapper.readTree(instanceString);
7775

0 commit comments

Comments
 (0)