-
Notifications
You must be signed in to change notification settings - Fork 136
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Add a flag to control auto-deploy behavior Signed-off-by: Sicheng Song <[email protected]> * Fix compilation Signed-off-by: Sicheng Song <[email protected]> * Bump back schema version due to already bumped in guardrail pr Signed-off-by: Sicheng Song <[email protected]> --------- Signed-off-by: Sicheng Song <[email protected]> (cherry picked from commit 22fcaf0) Co-authored-by: Sicheng Song <[email protected]>
- Loading branch information
1 parent
4dbeb28
commit c5c4e61
Showing
10 changed files
with
345 additions
and
28 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
71 changes: 71 additions & 0 deletions
71
common/src/main/java/org/opensearch/ml/common/model/MLDeploySetting.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,71 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.opensearch.ml.common.model; | ||
|
||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.Setter; | ||
import org.opensearch.core.common.io.stream.Writeable; | ||
import org.opensearch.core.common.io.stream.StreamInput; | ||
import org.opensearch.core.common.io.stream.StreamOutput; | ||
import org.opensearch.core.xcontent.ToXContent; | ||
import org.opensearch.core.xcontent.ToXContentObject; | ||
import org.opensearch.core.xcontent.XContentBuilder; | ||
import org.opensearch.core.xcontent.XContentParser; | ||
|
||
import java.io.IOException; | ||
|
||
import static org.opensearch.core.xcontent.XContentParserUtils.ensureExpectedToken; | ||
|
||
@Setter | ||
@Getter | ||
public class MLDeploySetting implements ToXContentObject, Writeable { | ||
public static final String IS_AUTO_DEPLOY_ENABLED_FIELD = "is_auto_deploy_enabled"; | ||
|
||
private Boolean isAutoDeployEnabled; | ||
|
||
@Builder(toBuilder = true) | ||
public MLDeploySetting(Boolean isAutoDeployEnabled) { | ||
this.isAutoDeployEnabled = isAutoDeployEnabled; | ||
} | ||
|
||
public MLDeploySetting(StreamInput in) throws IOException { | ||
this.isAutoDeployEnabled = in.readOptionalBoolean(); | ||
} | ||
|
||
@Override | ||
public void writeTo(StreamOutput out) throws IOException { | ||
out.writeOptionalBoolean(isAutoDeployEnabled); | ||
} | ||
|
||
public static MLDeploySetting parse(XContentParser parser) throws IOException { | ||
Boolean isAutoDeployEnabled = null; | ||
ensureExpectedToken(XContentParser.Token.START_OBJECT, parser.currentToken(), parser); | ||
while (parser.nextToken() != XContentParser.Token.END_OBJECT) { | ||
String fieldName = parser.currentName(); | ||
parser.nextToken(); | ||
switch (fieldName) { | ||
case IS_AUTO_DEPLOY_ENABLED_FIELD: | ||
isAutoDeployEnabled = parser.booleanValue(); | ||
break; | ||
default: | ||
parser.skipChildren(); | ||
break; | ||
} | ||
} | ||
return new MLDeploySetting(isAutoDeployEnabled); | ||
} | ||
|
||
@Override | ||
public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws IOException { | ||
builder.startObject(); | ||
if (isAutoDeployEnabled != null) { | ||
builder.field(IS_AUTO_DEPLOY_ENABLED_FIELD, isAutoDeployEnabled); | ||
} | ||
builder.endObject(); | ||
return builder; | ||
} | ||
} |
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
Oops, something went wrong.