Skip to content

Commit f43e5e3

Browse files
committed
rename API/function/variable names (opensearch-project#822)
* rename API/function/variable names Signed-off-by: Yaliang Wu <ylwu@amazon.com> * remove deprecated fields from model index Signed-off-by: Yaliang Wu <ylwu@amazon.com> * fix some variable name Signed-off-by: Yaliang Wu <ylwu@amazon.com> --------- Signed-off-by: Yaliang Wu <ylwu@amazon.com>
1 parent a698632 commit f43e5e3

File tree

124 files changed

+2206
-2040
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

124 files changed

+2206
-2040
lines changed

common/src/main/java/org/opensearch/ml/common/CommonValue.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public class CommonValue {
1919
public static final String USER = "user";
2020
public static final String META = "_meta";
2121
public static final String SCHEMA_VERSION_FIELD = "schema_version";
22-
public static final String UNLOADED = "unloaded";
22+
public static final String UNDEPLOYED = "undeployed";
2323
public static final String NOT_FOUND = "not_found";
2424

2525
public static final String BOX_TYPE_KEY = "box_type";
@@ -116,13 +116,13 @@ public class CommonValue {
116116
+ MLModel.LAST_UPDATED_TIME_FIELD
117117
+ "\": {\"type\": \"date\", \"format\": \"strict_date_time||epoch_millis\"},\n"
118118
+ " \""
119-
+ MLModel.LAST_UPLOADED_TIME_FIELD
119+
+ MLModel.LAST_REGISTERED_TIME_FIELD
120120
+ "\": {\"type\": \"date\", \"format\": \"strict_date_time||epoch_millis\"},\n"
121121
+ " \""
122-
+ MLModel.LAST_LOADED_TIME_FIELD
122+
+ MLModel.LAST_DEPLOYED_TIME_FIELD
123123
+ "\": {\"type\": \"date\", \"format\": \"strict_date_time||epoch_millis\"},\n"
124124
+ " \""
125-
+ MLModel.LAST_UNLOADED_TIME_FIELD
125+
+ MLModel.LAST_UNDEPLOYED_TIME_FIELD
126126
+ "\": {\"type\": \"date\", \"format\": \"strict_date_time||epoch_millis\"},\n"
127127
+ USER_FIELD_MAPPING
128128
+ " }\n"

common/src/main/java/org/opensearch/ml/common/MLModel.java

Lines changed: 42 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,15 @@ public class MLModel implements ToXContentObject {
4747
public static final String MODEL_CONFIG_FIELD = "model_config";
4848
public static final String CREATED_TIME_FIELD = "created_time";
4949
public static final String LAST_UPDATED_TIME_FIELD = "last_updated_time";
50+
@Deprecated
5051
public static final String LAST_UPLOADED_TIME_FIELD = "last_uploaded_time";
52+
@Deprecated
5153
public static final String LAST_LOADED_TIME_FIELD = "last_loaded_time";
54+
@Deprecated
5255
public static final String LAST_UNLOADED_TIME_FIELD = "last_unloaded_time";
56+
public static final String LAST_REGISTERED_TIME_FIELD = "last_registered_time";
57+
public static final String LAST_DEPLOYED_TIME_FIELD = "last_deployed_time";
58+
public static final String LAST_UNDEPLOYED_TIME_FIELD = "last_undeployed_time";
5359

5460
public static final String MODEL_ID_FIELD = "model_id";
5561
public static final String CHUNK_NUMBER_FIELD = "chunk_number";
@@ -74,9 +80,9 @@ public class MLModel implements ToXContentObject {
7480
private MLModelConfig modelConfig;
7581
private Instant createdTime;
7682
private Instant lastUpdateTime;
77-
private Instant lastUploadedTime;
78-
private Instant lastLoadedTime;
79-
private Instant lastUnloadedTime;
83+
private Instant lastRegisteredTime;
84+
private Instant lastDeployedTime;
85+
private Instant lastUndeployedTime;
8086

8187
@Setter
8288
private String modelId; // model chunk doc only
@@ -101,9 +107,9 @@ public MLModel(String name,
101107
MLModelConfig modelConfig,
102108
Instant createdTime,
103109
Instant lastUpdateTime,
104-
Instant lastUploadedTime,
105-
Instant lastLoadedTime,
106-
Instant lastUnloadedTime,
110+
Instant lastRegisteredTime,
111+
Instant lastDeployedTime,
112+
Instant lastUndeployedTime,
107113
String modelId, Integer chunkNumber,
108114
Integer totalChunks,
109115
Integer planningWorkerNodeCount,
@@ -123,9 +129,9 @@ public MLModel(String name,
123129
this.modelConfig = modelConfig;
124130
this.createdTime = createdTime;
125131
this.lastUpdateTime = lastUpdateTime;
126-
this.lastUploadedTime = lastUploadedTime;
127-
this.lastLoadedTime = lastLoadedTime;
128-
this.lastUnloadedTime = lastUnloadedTime;
132+
this.lastRegisteredTime = lastRegisteredTime;
133+
this.lastDeployedTime = lastDeployedTime;
134+
this.lastUndeployedTime = lastUndeployedTime;
129135
this.modelId = modelId;
130136
this.chunkNumber = chunkNumber;
131137
this.totalChunks = totalChunks;
@@ -160,9 +166,9 @@ public MLModel(StreamInput input) throws IOException{
160166
}
161167
createdTime = input.readOptionalInstant();
162168
lastUpdateTime = input.readOptionalInstant();
163-
lastUploadedTime = input.readOptionalInstant();
164-
lastLoadedTime = input.readOptionalInstant();
165-
lastUnloadedTime = input.readOptionalInstant();
169+
lastRegisteredTime = input.readOptionalInstant();
170+
lastDeployedTime = input.readOptionalInstant();
171+
lastUndeployedTime = input.readOptionalInstant();
166172
modelId = input.readOptionalString();
167173
chunkNumber = input.readOptionalInt();
168174
totalChunks = input.readOptionalInt();
@@ -207,9 +213,9 @@ public void writeTo(StreamOutput out) throws IOException {
207213
}
208214
out.writeOptionalInstant(createdTime);
209215
out.writeOptionalInstant(lastUpdateTime);
210-
out.writeOptionalInstant(lastUploadedTime);
211-
out.writeOptionalInstant(lastLoadedTime);
212-
out.writeOptionalInstant(lastUnloadedTime);
216+
out.writeOptionalInstant(lastRegisteredTime);
217+
out.writeOptionalInstant(lastDeployedTime);
218+
out.writeOptionalInstant(lastUndeployedTime);
213219
out.writeOptionalString(modelId);
214220
out.writeOptionalInt(chunkNumber);
215221
out.writeOptionalInt(totalChunks);
@@ -261,14 +267,14 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
261267
if (lastUpdateTime != null) {
262268
builder.field(LAST_UPDATED_TIME_FIELD, lastUpdateTime.toEpochMilli());
263269
}
264-
if (lastUploadedTime != null) {
265-
builder.field(LAST_UPLOADED_TIME_FIELD, lastUploadedTime.toEpochMilli());
270+
if (lastRegisteredTime != null) {
271+
builder.field(LAST_REGISTERED_TIME_FIELD, lastRegisteredTime.toEpochMilli());
266272
}
267-
if (lastLoadedTime != null) {
268-
builder.field(LAST_LOADED_TIME_FIELD, lastLoadedTime.toEpochMilli());
273+
if (lastDeployedTime != null) {
274+
builder.field(LAST_DEPLOYED_TIME_FIELD, lastDeployedTime.toEpochMilli());
269275
}
270-
if (lastUnloadedTime != null) {
271-
builder.field(LAST_UNLOADED_TIME_FIELD, lastUnloadedTime.toEpochMilli());
276+
if (lastUndeployedTime != null) {
277+
builder.field(LAST_UNDEPLOYED_TIME_FIELD, lastUndeployedTime.toEpochMilli());
272278
}
273279
if (modelId != null) {
274280
builder.field(MODEL_ID_FIELD, modelId);
@@ -315,6 +321,9 @@ public static MLModel parse(XContentParser parser) throws IOException {
315321
Instant lastUploadedTime = null;
316322
Instant lastLoadedTime = null;
317323
Instant lastUnloadedTime = null;
324+
Instant lastRegisteredTime = null;
325+
Instant lastDeployedTime = null;
326+
Instant lastUndeployedTime = null;
318327
String modelId = null;
319328
Integer chunkNumber = null;
320329
Integer totalChunks = null;
@@ -407,6 +416,15 @@ public static MLModel parse(XContentParser parser) throws IOException {
407416
case LAST_UNLOADED_TIME_FIELD:
408417
lastUnloadedTime = Instant.ofEpochMilli(parser.longValue());
409418
break;
419+
case LAST_REGISTERED_TIME_FIELD:
420+
lastRegisteredTime = Instant.ofEpochMilli(parser.longValue());
421+
break;
422+
case LAST_DEPLOYED_TIME_FIELD:
423+
lastDeployedTime = Instant.ofEpochMilli(parser.longValue());
424+
break;
425+
case LAST_UNDEPLOYED_TIME_FIELD:
426+
lastUndeployedTime = Instant.ofEpochMilli(parser.longValue());
427+
break;
410428
default:
411429
parser.skipChildren();
412430
break;
@@ -426,9 +444,9 @@ public static MLModel parse(XContentParser parser) throws IOException {
426444
.modelConfig(modelConfig)
427445
.createdTime(createdTime)
428446
.lastUpdateTime(lastUpdateTime)
429-
.lastUploadedTime(lastUploadedTime)
430-
.lastLoadedTime(lastLoadedTime)
431-
.lastUnloadedTime(lastUnloadedTime)
447+
.lastRegisteredTime(lastRegisteredTime == null? lastUploadedTime : lastRegisteredTime)
448+
.lastDeployedTime(lastDeployedTime == null? lastLoadedTime : lastDeployedTime)
449+
.lastUndeployedTime(lastUndeployedTime == null? lastUnloadedTime : lastUndeployedTime)
432450
.modelId(modelId)
433451
.chunkNumber(chunkNumber)
434452
.totalChunks(totalChunks)

common/src/main/java/org/opensearch/ml/common/MLTaskType.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ public enum MLTaskType {
1010
PREDICTION,
1111
TRAINING_AND_PREDICTION,
1212
EXECUTION,
13+
@Deprecated
1314
UPLOAD_MODEL,
14-
LOAD_MODEL
15+
@Deprecated
16+
LOAD_MODEL,
17+
REGISTER_MODEL,
18+
DEPLOY_MODEL
1519
}

common/src/main/java/org/opensearch/ml/common/model/MLModelState.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,28 @@
77

88
public enum MLModelState {
99
TRAINED,
10+
@Deprecated
1011
UPLOADING,
12+
@Deprecated
1113
UPLOADED,
14+
@Deprecated
1215
LOADING,
16+
@Deprecated
1317
LOADED,
18+
@Deprecated
1419
PARTIALLY_LOADED,
20+
@Deprecated
1521
UNLOADED,
16-
LOAD_FAILED;
22+
@Deprecated
23+
LOAD_FAILED,
24+
25+
REGISTERING,
26+
REGISTERED,
27+
DEPLOYING,
28+
DEPLOYED,
29+
PARTIALLY_DEPLOYED,
30+
UNDEPLOYED,
31+
DEPLOY_FAILED;
1732

1833
public static MLModelState from(String value) {
1934
try {
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*
2+
* Copyright OpenSearch Contributors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
package org.opensearch.ml.common.transport.deploy;
7+
8+
import org.opensearch.action.ActionType;
9+
10+
public class MLDeployModelAction extends ActionType<MLDeployModelResponse> {
11+
public static MLDeployModelAction INSTANCE = new MLDeployModelAction();
12+
public static final String NAME = "cluster:admin/opensearch/ml/deploy_model";
13+
14+
private MLDeployModelAction() {
15+
super(NAME, MLDeployModelResponse::new);
16+
}
17+
18+
}

common/src/main/java/org/opensearch/ml/common/transport/load/LoadModelInput.java renamed to common/src/main/java/org/opensearch/ml/common/transport/deploy/MLDeployModelInput.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

6-
package org.opensearch.ml.common.transport.load;
6+
package org.opensearch.ml.common.transport.deploy;
77

88
import lombok.Builder;
99
import lombok.Data;
@@ -15,15 +15,15 @@
1515
import java.io.IOException;
1616

1717
@Data
18-
public class LoadModelInput implements Writeable {
18+
public class MLDeployModelInput implements Writeable {
1919
private String modelId;
2020
private String taskId;
2121
private String modelContentHash;
2222
private Integer nodeCount;
2323
private String coordinatingNodeId;
2424
private MLTask mlTask;
2525

26-
public LoadModelInput(StreamInput in) throws IOException {
26+
public MLDeployModelInput(StreamInput in) throws IOException {
2727
this.modelId = in.readString();
2828
this.taskId = in.readString();
2929
this.modelContentHash = in.readOptionalString();
@@ -33,7 +33,7 @@ public LoadModelInput(StreamInput in) throws IOException {
3333
}
3434

3535
@Builder
36-
public LoadModelInput(String modelId, String taskId, String modelContentHash, Integer nodeCount, String coordinatingNodeId, MLTask mlTask) {
36+
public MLDeployModelInput(String modelId, String taskId, String modelContentHash, Integer nodeCount, String coordinatingNodeId, MLTask mlTask) {
3737
this.modelId = modelId;
3838
this.taskId = taskId;
3939
this.modelContentHash = modelContentHash;
@@ -42,7 +42,7 @@ public LoadModelInput(String modelId, String taskId, String modelContentHash, In
4242
this.mlTask = mlTask;
4343
}
4444

45-
public LoadModelInput() {
45+
public MLDeployModelInput() {
4646
}
4747

4848
@Override

common/src/main/java/org/opensearch/ml/common/transport/load/LoadModelNodeRequest.java renamed to common/src/main/java/org/opensearch/ml/common/transport/deploy/MLDeployModelNodeRequest.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

6-
package org.opensearch.ml.common.transport.load;
6+
package org.opensearch.ml.common.transport.deploy;
77

88
import lombok.Getter;
99
import org.opensearch.transport.TransportRequest;
@@ -12,27 +12,27 @@
1212

1313
import java.io.IOException;
1414

15-
public class LoadModelNodeRequest extends TransportRequest {
15+
public class MLDeployModelNodeRequest extends TransportRequest {
1616
@Getter
17-
private LoadModelNodesRequest loadModelNodesRequest;
17+
private MLDeployModelNodesRequest MLDeployModelNodesRequest;
1818

19-
public LoadModelNodeRequest(StreamInput in) throws IOException {
19+
public MLDeployModelNodeRequest(StreamInput in) throws IOException {
2020
super(in);
21-
this.loadModelNodesRequest = new LoadModelNodesRequest(in);
21+
this.MLDeployModelNodesRequest = new MLDeployModelNodesRequest(in);
2222
}
2323

2424
/**
2525
* Constructor
2626
*
2727
* @param request MLStatsNodesRequest
2828
*/
29-
public LoadModelNodeRequest(LoadModelNodesRequest request) {
30-
this.loadModelNodesRequest = request;
29+
public MLDeployModelNodeRequest(MLDeployModelNodesRequest request) {
30+
this.MLDeployModelNodesRequest = request;
3131
}
3232

3333
@Override
3434
public void writeTo(StreamOutput out) throws IOException {
3535
super.writeTo(out);
36-
loadModelNodesRequest.writeTo(out);
36+
MLDeployModelNodesRequest.writeTo(out);
3737
}
3838
}

common/src/main/java/org/opensearch/ml/common/transport/load/LoadModelNodeResponse.java renamed to common/src/main/java/org/opensearch/ml/common/transport/deploy/MLDeployModelNodeResponse.java

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

6-
package org.opensearch.ml.common.transport.load;
6+
package org.opensearch.ml.common.transport.deploy;
77

88
import lombok.extern.log4j.Log4j2;
99
import org.opensearch.action.support.nodes.BaseNodeResponse;
@@ -16,58 +16,58 @@
1616
import java.io.IOException;
1717
import java.util.Map;
1818
@Log4j2
19-
public class LoadModelNodeResponse extends BaseNodeResponse implements ToXContentFragment {
19+
public class MLDeployModelNodeResponse extends BaseNodeResponse implements ToXContentFragment {
2020

2121
/**
2222
* Key is modelName + ":" + version
2323
*/
24-
private Map<String, String> modelLoadStatus;
24+
private Map<String, String> modelDeployStatus;
2525

26-
public LoadModelNodeResponse(DiscoveryNode node, Map<String, String> modelLoadStatus) {
26+
public MLDeployModelNodeResponse(DiscoveryNode node, Map<String, String> modelDeployStatus) {
2727
super(node);
28-
this.modelLoadStatus = modelLoadStatus;
28+
this.modelDeployStatus = modelDeployStatus;
2929
}
3030
/**
3131
* Constructor
3232
*
3333
* @param in StreamInput
3434
* @throws IOException throws an IO exception if the StreamInput cannot be read from
3535
*/
36-
public LoadModelNodeResponse(StreamInput in) throws IOException {
36+
public MLDeployModelNodeResponse(StreamInput in) throws IOException {
3737
super(in);
3838
if (in.readBoolean()) {
39-
this.modelLoadStatus = in.readMap(s -> s.readString(), s-> s.readString());
39+
this.modelDeployStatus = in.readMap(s -> s.readString(), s-> s.readString());
4040
}
4141

4242
}
4343

4444
/**
45-
* Creates a new UnloadNodeResponse object and read the stats from an input stream
45+
* Creates a new MLDeployModelNodeResponse object and read the stats from an input stream
4646
*
4747
* @param in StreamInput to read from
48-
* @return LoadModelNodeResponse object corresponding to the input stream
48+
* @return MLDeployModelNodeResponse object corresponding to the input stream
4949
* @throws IOException throws an IO exception if the StreamInput cannot be read from
5050
*/
51-
public static LoadModelNodeResponse readStats(StreamInput in) throws IOException {
52-
return new LoadModelNodeResponse(in);
51+
public static MLDeployModelNodeResponse readStats(StreamInput in) throws IOException {
52+
return new MLDeployModelNodeResponse(in);
5353
}
5454

5555
@Override
5656
public void writeTo(StreamOutput out) throws IOException {
5757
super.writeTo(out);
5858

59-
if (modelLoadStatus != null && modelLoadStatus.size() > 0) {
59+
if (modelDeployStatus != null && modelDeployStatus.size() > 0) {
6060
out.writeBoolean(true);
61-
out.writeMap(modelLoadStatus, (stream, v) -> stream.writeString(v), (stream, stats) -> stream.writeString(stats));
61+
out.writeMap(modelDeployStatus, (stream, v) -> stream.writeString(v), (stream, stats) -> stream.writeString(stats));
6262
} else {
6363
out.writeBoolean(false);
6464
}
6565
}
6666

6767
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
6868
builder.startObject("stats");
69-
if (modelLoadStatus != null && modelLoadStatus.size() > 0) {
70-
for (Map.Entry<String, String> stat : modelLoadStatus.entrySet()) {
69+
if (modelDeployStatus != null && modelDeployStatus.size() > 0) {
70+
for (Map.Entry<String, String> stat : modelDeployStatus.entrySet()) {
7171
builder.field(stat.getKey(), stat.getValue());
7272
}
7373
}

0 commit comments

Comments
 (0)