Search in sources :

Example 1 with MLExecuteTaskRequest

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);
}
Also used : Input(org.opensearch.ml.common.parameter.Input) MLExecuteTaskRequest(org.opensearch.ml.common.transport.execute.MLExecuteTaskRequest) XContentParser(org.opensearch.common.xcontent.XContentParser) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 2 with MLExecuteTaskRequest

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));
}
Also used : MLOutput(org.opensearch.ml.common.parameter.MLOutput) FieldDefaults(lombok.experimental.FieldDefaults) MLModelDeleteRequest(org.opensearch.ml.common.transport.model.MLModelDeleteRequest) RequiredArgsConstructor(lombok.RequiredArgsConstructor) MLInput(org.opensearch.ml.common.parameter.MLInput) MLTrainAndPredictionTaskAction(org.opensearch.ml.common.transport.trainpredict.MLTrainAndPredictionTaskAction) Input(org.opensearch.ml.common.parameter.Input) Function(java.util.function.Function) MLPredictionTaskRequest(org.opensearch.ml.common.transport.prediction.MLPredictionTaskRequest) Output(org.opensearch.ml.common.parameter.Output) AccessLevel(lombok.AccessLevel) MLPredictionTaskAction(org.opensearch.ml.common.transport.prediction.MLPredictionTaskAction) DeleteResponse(org.opensearch.action.delete.DeleteResponse) SearchRequest(org.opensearch.action.search.SearchRequest) ActionListener(org.opensearch.action.ActionListener) ActionResponse(org.opensearch.action.ActionResponse) SearchResponse(org.opensearch.action.search.SearchResponse) MLModel(org.opensearch.ml.common.parameter.MLModel) MLModelGetResponse(org.opensearch.ml.common.transport.model.MLModelGetResponse) MLTaskResponse(org.opensearch.ml.common.transport.MLTaskResponse) MLExecuteTaskAction(org.opensearch.ml.common.transport.execute.MLExecuteTaskAction) MLModelDeleteAction(org.opensearch.ml.common.transport.model.MLModelDeleteAction) NodeClient(org.opensearch.client.node.NodeClient) MLModelGetRequest(org.opensearch.ml.common.transport.model.MLModelGetRequest) MLModelSearchAction(org.opensearch.ml.common.transport.model.MLModelSearchAction) MLExecuteTaskRequest(org.opensearch.ml.common.transport.execute.MLExecuteTaskRequest) MLTrainingTaskAction(org.opensearch.ml.common.transport.training.MLTrainingTaskAction) MLModelGetAction(org.opensearch.ml.common.transport.model.MLModelGetAction) MLExecuteTaskResponse(org.opensearch.ml.common.transport.execute.MLExecuteTaskResponse) MLTrainingTaskRequest(org.opensearch.ml.common.transport.training.MLTrainingTaskRequest) MLExecuteTaskRequest(org.opensearch.ml.common.transport.execute.MLExecuteTaskRequest)

Example 3 with MLExecuteTaskRequest

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);
}
Also used : MLExecuteTaskRequest(org.opensearch.ml.common.transport.execute.MLExecuteTaskRequest)

Aggregations

MLExecuteTaskRequest (org.opensearch.ml.common.transport.execute.MLExecuteTaskRequest)3 Input (org.opensearch.ml.common.parameter.Input)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 Function (java.util.function.Function)1 AccessLevel (lombok.AccessLevel)1 RequiredArgsConstructor (lombok.RequiredArgsConstructor)1 FieldDefaults (lombok.experimental.FieldDefaults)1 ActionListener (org.opensearch.action.ActionListener)1 ActionResponse (org.opensearch.action.ActionResponse)1 DeleteResponse (org.opensearch.action.delete.DeleteResponse)1 SearchRequest (org.opensearch.action.search.SearchRequest)1 SearchResponse (org.opensearch.action.search.SearchResponse)1 NodeClient (org.opensearch.client.node.NodeClient)1 XContentParser (org.opensearch.common.xcontent.XContentParser)1 MLInput (org.opensearch.ml.common.parameter.MLInput)1 MLModel (org.opensearch.ml.common.parameter.MLModel)1 MLOutput (org.opensearch.ml.common.parameter.MLOutput)1 Output (org.opensearch.ml.common.parameter.Output)1 MLTaskResponse (org.opensearch.ml.common.transport.MLTaskResponse)1 MLExecuteTaskAction (org.opensearch.ml.common.transport.execute.MLExecuteTaskAction)1