Skip to content

Commit 6763d59

Browse files
committed
Fix parser poc
Signed-off-by: Sicheng Song <sicheng.song@outlook.com>
1 parent f1a80ac commit 6763d59

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

ml-algorithms/src/main/java/org/opensearch/ml/engine/algorithms/remote/ConnectorUtils.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,8 @@ public static JSONObject wrapProperties(JSONObject jsonObject) {
311311
// Check if the nested object has any schema keyword field
312312
if (nestedObject.has("type") || nestedObject.has("properties") || nestedObject.has("description")) {
313313
newObject.put(key, nestedObject); // Leave as is, because it's likely a schema definition
314+
} else if (key.equals("properties")) {
315+
newObject.put(key, wrapProperties(nestedObject));
314316
} else {
315317
// Recurse to handle nested objects and wrap them with "properties"
316318
newObject.put(key, new JSONObject().put("properties", wrapProperties(nestedObject)));
@@ -330,7 +332,7 @@ private static JSONArray wrapPropertiesInArray(JSONArray jsonArray) {
330332
for (int i = 0; i < jsonArray.length(); i++) {
331333
Object item = jsonArray.get(i);
332334
if (item instanceof JSONObject) {
333-
newArray.put(processJsonObject((JSONObject) item));
335+
newArray.put(wrapProperties((JSONObject) item));
334336
} else if (item instanceof JSONArray) {
335337
newArray.put(wrapPropertiesInArray((JSONArray) item));
336338
} else {

ml-algorithms/src/main/java/org/opensearch/ml/engine/algorithms/remote/RemoteConnectorExecutor.java

+2
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,8 @@ private void validateInputSchema(MLInput mlInput) {
168168
String inputSchemaString = getConnector().getModelInterface().get("input");
169169
try {
170170
JSONObject inputSchemaObject = ConnectorUtils.processJsonObject(new JSONObject(inputSchemaString));
171+
System.out.println(mlInput.getParameters().toXContent(XContentFactory.jsonBuilder(), ToXContent.EMPTY_PARAMS).toString());
172+
System.out.println(mlInput.getInputDataset().toString());
171173
ConnectorUtils.validateSchema(inputSchemaObject.toString(), mlInput.toXContent(XContentFactory.jsonBuilder(), ToXContent.EMPTY_PARAMS).toString());
172174
} catch (IOException | JSONException e) {
173175
throw new IllegalArgumentException("Error validating input schema: " + e.getMessage());

0 commit comments

Comments
 (0)