forked from opensearch-project/ml-commons
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge update model API and model level throttling/quota (opensearch-p…
…roject#1624) * Update Model API (opensearch-project#1350) * Update Model API POC Signed-off-by: Sicheng Song <sicheng.song@outlook.com> * Using GetRequest to get model Signed-off-by: Sicheng Song <sicheng.song@outlook.com> * Finalize model update API Signed-off-by: Sicheng Song <sicheng.song@outlook.com> * Fix compile Signed-off-by: Sicheng Song <sicheng.song@outlook.com> * Fix compileTest Signed-off-by: Sicheng Song <sicheng.song@outlook.com> * Add Unit Test Cases for Update Model API Signed-off-by: Sicheng Song <sicheng.song@outlook.com> * Tune back test coverage thereshold Signed-off-by: Sicheng Song <sicheng.song@outlook.com> * Add more unit tests on Update model API Signed-off-by: Sicheng Song <sicheng.song@outlook.com> * Add unit test for TransportUpdateModelAction class Signed-off-by: Sicheng Song <sicheng.song@outlook.com> * Fix a test error Signed-off-by: Sicheng Song <sicheng.song@outlook.com> * Change exception thrown to failure response Signed-off-by: Sicheng Song <sicheng.song@outlook.com> * Move the function judgement to the outter block Signed-off-by: Sicheng Song <sicheng.song@outlook.com> * Check if model is undeployed before update model Signed-off-by: Sicheng Song <sicheng.song@outlook.com> * Add more unit test for update model API Signed-off-by: Sicheng Song <sicheng.song@outlook.com> * Fix unit test due to blocking java 11 CI workflow Signed-off-by: Sicheng Song <sicheng.song@outlook.com> * Enabling auto bumping model version during registering to a new model group and address reviewers' other concern Signed-off-by: Sicheng Song <sicheng.song@outlook.com> * Autobump new model groups' latest version when register to a new model Signed-off-by: Sicheng Song <sicheng.song@outlook.com> * Change the REST API method from POST to PUT Signed-off-by: Sicheng Song <sicheng.song@outlook.com> * Change the update REST API endpoint Signed-off-by: Sicheng Song <sicheng.song@outlook.com> --------- Signed-off-by: Sicheng Song <sicheng.song@outlook.com> * Fix java compile when merging Signed-off-by: Sicheng Song <sicheng.song@outlook.com> * Fix model/connector update API to address security concern (opensearch-project#1595) * Fix model/connector update API to address appsec concern Signed-off-by: Sicheng Song <sicheng.song@outlook.com> * Fix compile and build failure Signed-off-by: Sicheng Song <sicheng.song@outlook.com> * Improve unit test coverage Signed-off-by: Sicheng Song <sicheng.song@outlook.com> * Fix spotless Signed-off-by: Sicheng Song <sicheng.song@outlook.com> * Merge update connector feature flag to remote inference feature flag Signed-off-by: Sicheng Song <sicheng.song@outlook.com> * Fix compile Signed-off-by: Sicheng Song <sicheng.song@outlook.com> * Fix exception status Signed-off-by: Sicheng Song <sicheng.song@outlook.com> * Keep fixing exception status Signed-off-by: Sicheng Song <sicheng.song@outlook.com> * Spotless fix Signed-off-by: Sicheng Song <sicheng.song@outlook.com> * Add UT on parsing exception Signed-off-by: Sicheng Song <sicheng.song@outlook.com> --------- Signed-off-by: Sicheng Song <sicheng.song@outlook.com> * return parsing exception 400 for parsing errors (opensearch-project#1603) add more ut in restupdateconnector Signed-off-by: Xun Zhang <xunzh@amazon.com> Signed-off-by: Sicheng Song <sicheng.song@outlook.com> * throttling and quota feature on single node cluster Signed-off-by: Sicheng Song <sicheng.song@outlook.com> * Fix java compile when merging Signed-off-by: Sicheng Song <sicheng.song@outlook.com> * Enabling in-place update on multi-node Signed-off-by: Sicheng Song <sicheng.song@outlook.com> * Fix confidential rotation in update internal connector Signed-off-by: Sicheng Song <sicheng.song@outlook.com> --------- Signed-off-by: Sicheng Song <sicheng.song@outlook.com> Signed-off-by: Xun Zhang <xunzh@amazon.com> Co-authored-by: Xun Zhang <xunzh@amazon.com> Signed-off-by: Sicheng Song <sicheng.song@outlook.com>
- Loading branch information
1 parent
1a31c5f
commit 7454b97
Showing
39 changed files
with
3,167 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
...on/src/main/java/org/opensearch/ml/common/transport/model/MLInPlaceUpdateModelAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.opensearch.ml.common.transport.model; | ||
|
||
import org.opensearch.action.ActionType; | ||
|
||
public class MLInPlaceUpdateModelAction extends ActionType<MLInPlaceUpdateModelNodesResponse> { | ||
public static final MLInPlaceUpdateModelAction INSTANCE = new MLInPlaceUpdateModelAction(); | ||
public static final String NAME = "cluster:admin/opensearch/ml/models/in_place_update"; | ||
|
||
private MLInPlaceUpdateModelAction() { super(NAME, MLInPlaceUpdateModelNodesResponse::new);} | ||
} |
32 changes: 32 additions & 0 deletions
32
...c/main/java/org/opensearch/ml/common/transport/model/MLInPlaceUpdateModelNodeRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.opensearch.ml.common.transport.model; | ||
|
||
import org.opensearch.action.support.nodes.BaseNodeRequest; | ||
import java.io.IOException; | ||
import lombok.Getter; | ||
import org.opensearch.core.common.io.stream.StreamInput; | ||
import org.opensearch.core.common.io.stream.StreamOutput; | ||
|
||
public class MLInPlaceUpdateModelNodeRequest extends BaseNodeRequest { | ||
@Getter | ||
private MLInPlaceUpdateModelNodesRequest mlInPlaceUpdateModelNodesRequest; | ||
|
||
public MLInPlaceUpdateModelNodeRequest(StreamInput in) throws IOException { | ||
super(in); | ||
this.mlInPlaceUpdateModelNodesRequest = new MLInPlaceUpdateModelNodesRequest(in); | ||
} | ||
|
||
public MLInPlaceUpdateModelNodeRequest(MLInPlaceUpdateModelNodesRequest request) { | ||
this.mlInPlaceUpdateModelNodesRequest = request; | ||
} | ||
|
||
@Override | ||
public void writeTo(StreamOutput out) throws IOException { | ||
super.writeTo(out); | ||
mlInPlaceUpdateModelNodesRequest.writeTo(out); | ||
} | ||
} |
67 changes: 67 additions & 0 deletions
67
.../main/java/org/opensearch/ml/common/transport/model/MLInPlaceUpdateModelNodeResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.opensearch.ml.common.transport.model; | ||
|
||
import lombok.Getter; | ||
import lombok.extern.log4j.Log4j2; | ||
import org.opensearch.action.support.nodes.BaseNodeResponse; | ||
import org.opensearch.cluster.node.DiscoveryNode; | ||
import org.opensearch.core.common.io.stream.StreamInput; | ||
import org.opensearch.core.common.io.stream.StreamOutput; | ||
import org.opensearch.core.xcontent.ToXContentFragment; | ||
import org.opensearch.core.xcontent.XContentBuilder; | ||
|
||
import java.io.IOException; | ||
import java.util.Map; | ||
|
||
@Getter | ||
@Log4j2 | ||
public class MLInPlaceUpdateModelNodeResponse extends BaseNodeResponse implements ToXContentFragment { | ||
private Map<String, String> modelUpdateStatus; | ||
|
||
public MLInPlaceUpdateModelNodeResponse(DiscoveryNode node, Map<String, String> modelUpdateStatus) { | ||
super(node); | ||
this.modelUpdateStatus = modelUpdateStatus; | ||
} | ||
|
||
public MLInPlaceUpdateModelNodeResponse(StreamInput in) throws IOException { | ||
super(in); | ||
if (in.readBoolean()) { | ||
this.modelUpdateStatus = in.readMap(StreamInput::readString, StreamInput::readString); | ||
} | ||
} | ||
|
||
public static MLInPlaceUpdateModelNodeResponse readStats(StreamInput in) throws IOException { | ||
return new MLInPlaceUpdateModelNodeResponse(in); | ||
} | ||
|
||
@Override | ||
public void writeTo(StreamOutput out) throws IOException { | ||
super.writeTo(out); | ||
|
||
if (!isEmpty()) { | ||
out.writeBoolean(true); | ||
out.writeMap(modelUpdateStatus, StreamOutput::writeString, StreamOutput::writeString); | ||
} else { | ||
out.writeBoolean(false); | ||
} | ||
} | ||
|
||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { | ||
builder.startObject("stats"); | ||
if (modelUpdateStatus != null && modelUpdateStatus.size() > 0) { | ||
for (Map.Entry<String, String> stat : modelUpdateStatus.entrySet()) { | ||
builder.field(stat.getKey(), stat.getValue()); | ||
} | ||
} | ||
builder.endObject(); | ||
return builder; | ||
} | ||
|
||
public boolean isEmpty() { | ||
return modelUpdateStatus == null || modelUpdateStatus.size() == 0; | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
.../main/java/org/opensearch/ml/common/transport/model/MLInPlaceUpdateModelNodesRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.opensearch.ml.common.transport.model; | ||
|
||
import lombok.Getter; | ||
import org.opensearch.action.support.nodes.BaseNodesRequest; | ||
import org.opensearch.cluster.node.DiscoveryNode; | ||
import org.opensearch.core.common.io.stream.StreamInput; | ||
import org.opensearch.core.common.io.stream.StreamOutput; | ||
import java.io.IOException; | ||
|
||
public class MLInPlaceUpdateModelNodesRequest extends BaseNodesRequest<MLInPlaceUpdateModelNodesRequest> { | ||
|
||
@Getter | ||
private String modelId; | ||
@Getter | ||
private boolean updatePredictorFlag; | ||
|
||
public MLInPlaceUpdateModelNodesRequest(StreamInput in) throws IOException { | ||
super(in); | ||
this.modelId = in.readString(); | ||
this.updatePredictorFlag = in.readBoolean(); | ||
} | ||
|
||
public MLInPlaceUpdateModelNodesRequest(String[] nodeIds, String modelId, boolean updatePredictorFlag) { | ||
super(nodeIds); | ||
this.modelId = modelId; | ||
this.updatePredictorFlag = updatePredictorFlag; | ||
} | ||
|
||
public MLInPlaceUpdateModelNodesRequest(DiscoveryNode[] nodeIds, String modelId, boolean updatePredictorFlag) { | ||
super(nodeIds); | ||
this.modelId = modelId; | ||
this.updatePredictorFlag = updatePredictorFlag; | ||
} | ||
|
||
public MLInPlaceUpdateModelNodesRequest(DiscoveryNode... nodes) { | ||
super(nodes); | ||
this.updatePredictorFlag = false; | ||
} | ||
|
||
@Override | ||
public void writeTo(StreamOutput out) throws IOException { | ||
super.writeTo(out); | ||
out.writeString(modelId); | ||
out.writeBoolean(updatePredictorFlag); | ||
} | ||
} |
Oops, something went wrong.