use of org.opensearch.ml.common.transport.execute.MLExecuteTaskRequest in project ml-commons by opensearch-project.
the class RestMLExecuteAction method getRequest.
/**
* Creates a MLExecuteTaskRequest from a RestRequest
*
* @param request RestRequest
* @return MLExecuteTaskRequest
*/
@VisibleForTesting
MLExecuteTaskRequest getRequest(RestRequest request) throws IOException {
String algorithm = getAlgorithm(request);
XContentParser parser = request.contentParser();
ensureExpectedToken(XContentParser.Token.START_OBJECT, parser.nextToken(), parser);
Input input = parser.namedObject(Input.class, algorithm, null);
return new MLExecuteTaskRequest(input);
}
use of org.opensearch.ml.common.transport.execute.MLExecuteTaskRequest in project ml-commons by opensearch-project.
the class MachineLearningNodeClient method execute.
@Override
public void execute(Input input, ActionListener<Output> listener) {
MLExecuteTaskRequest executeTaskRequest = MLExecuteTaskRequest.builder().input(input).build();
client.execute(MLExecuteTaskAction.INSTANCE, executeTaskRequest, ActionListener.wrap(response -> {
listener.onResponse(MLExecuteTaskResponse.fromActionResponse(response).getOutput());
}, listener::onFailure));
}
use of org.opensearch.ml.common.transport.execute.MLExecuteTaskRequest in project ml-commons by opensearch-project.
the class TransportExecuteTaskAction method doExecute.
@Override
protected void doExecute(Task task, ActionRequest request, ActionListener<MLExecuteTaskResponse> listener) {
MLExecuteTaskRequest mlPredictionTaskRequest = MLExecuteTaskRequest.fromActionRequest(request);
mlExecuteTaskRunner.run(mlPredictionTaskRequest, transportService, listener);
}
Aggregations